summaryrefslogtreecommitdiff
path: root/test/integration/targets/vyos_interface/tests/cli/basic.yaml
blob: 9e1f9dc68a7865714fd7e1a796801f0c897a16ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
---
- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}"

- name: Run vyos lsmod command
  vyos_command:
    commands:
      - lsmod
  register: lsmod_out

- name: Set up - delete interface
  vyos_interface:
    name: eth1
    state: absent

- name: Set up - Create interface
  vyos_interface:
    name: eth1
    state: present
    description: test-interface
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"set interfaces ethernet eth1" in result.commands'
      - '"set interfaces ethernet eth1 description ''test-interface''" in result.commands'

- name: Configure interface params
  vyos_interface:
    name: eth1
    state: present
    description: test-interface-1
    speed: 100
    duplex: half
    mtu: 256
  when: "'virtio_net' not in lsmod_out.stdout[0]"
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"set interfaces ethernet eth1 description ''test-interface-1''" in result.commands'
      - '"set interfaces ethernet eth1 speed 100" in result.commands'
      - '"set interfaces ethernet eth1 duplex half" in result.commands'
      - '"set interfaces ethernet eth1 mtu 256" in result.commands'
  when: "'virtio_net' not in lsmod_out.stdout[0]"

- name: Configure interface params (idempotent)
  vyos_interface:
    name: eth1
    state: present
    description: test-interface-1
    speed: 100
    duplex: half
    mtu: 256
  register: result
  when: "'virtio_net' not in lsmod_out.stdout[0]"

- assert:
    that:
      - 'result.changed == false'
  when: "'virtio' not in lsmod_out.stdout[0]"

- name: Change interface params
  vyos_interface:
    name: eth1
    state: present
    description: test-interface-2
    speed: 1000
    duplex: full
    mtu: 512
  register: result
  when: "'virtio_net' not in lsmod_out.stdout[0]"

- assert:
    that:
      - 'result.changed == true'
      - '"set interfaces ethernet eth1 description ''test-interface-2''" in result.commands'
      - '"set interfaces ethernet eth1 speed 1000" in result.commands'
      - '"set interfaces ethernet eth1 duplex full" in result.commands'
      - '"set interfaces ethernet eth1 mtu 512" in result.commands'
  when: "'virtio_net' not in lsmod_out.stdout[0]"

- name: Disable interface
  vyos_interface:
    name: eth1
    enabled: false
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"set interfaces ethernet eth1 disable" in result.commands'

- name: Enable interface
  vyos_interface:
    name: eth1
    enabled: true
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"delete interfaces ethernet eth1 disable" in result.commands'

- name: Delete interface
  vyos_interface:
    name: eth1
    state: absent
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"delete interfaces ethernet eth1" in result.commands'

- name: Delete interface (idempotent)
  vyos_interface:
    name: eth1
    state: absent
  register: result

- assert:
    that:
      - 'result.changed == false'

- name: Aggregate setup- delete interface
  vyos_interface:
    name: eth2
    state: absent
  register: result

- name: Set interface on aggregate
  vyos_interface:
    aggregate:
      - {name: eth1, description: test-interface-1, speed: 100, duplex: half, mtu: 512}
      - {name: eth2, description: test-interface-2, speed: 1000, duplex: full, mtu: 256}
  register: result
  when: "'virtio_net' not in lsmod_out.stdout[0]"

- assert:
    that:
      - 'result.changed == true'
      - '"set interfaces ethernet eth1 description ''test-interface-1''" in result.commands'
      - '"set interfaces ethernet eth1 speed 100" in result.commands'
      - '"set interfaces ethernet eth1 duplex half" in result.commands'
      - '"set interfaces ethernet eth1 mtu 512" in result.commands'
      - '"set interfaces ethernet eth2 description ''test-interface-2''" in result.commands'
      - '"set interfaces ethernet eth2 speed 1000" in result.commands'
      - '"set interfaces ethernet eth2 duplex full" in result.commands'
      - '"set interfaces ethernet eth2 mtu 256" in result.commands'
  when: "'virtio_net' not in lsmod_out.stdout[0]"

- name: Set interface on aggregate (idempotent)
  vyos_interface:
    aggregate:
      - {name: eth1, description: test-interface-1, speed: 100, duplex: half, mtu: 512}
      - {name: eth2, description: test-interface-2, speed: 1000, duplex: full, mtu: 256}
  register: result
  when: "'virtio_net' not in lsmod_out.stdout[0]"

- assert:
    that:
      - 'result.changed == false'
  when: "'virtio_net' not in lsmod_out.stdout[0]"

- name: Disable interface on aggregate
  vyos_interface:
    aggregate:
      - name: eth1
      - name: eth2
    description: test-interface
    enabled: false
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"set interfaces ethernet eth1 disable" in result.commands'
      - '"set interfaces ethernet eth2 disable" in result.commands'

- name: Enable interface on aggregate
  vyos_interface:
    aggregate:
      - name: eth1
      - name: eth2
    enabled: true
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"delete interfaces ethernet eth1 disable" in result.commands'
      - '"delete interfaces ethernet eth2 disable" in result.commands'

- name: Delete interface aggregate
  vyos_interface:
    aggregate:
      - name: eth1
      - name: eth2
    state: absent
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"delete interfaces ethernet eth1" in result.commands'
      - '"delete interfaces ethernet eth2" in result.commands'

- name: Delete interface aggregate (idempotent)
  vyos_interface:
    aggregate:
      - name: eth1
      - name: eth2
    state: absent
  register: result

- assert:
    that:
      - 'result.changed == false'