summaryrefslogtreecommitdiff
path: root/test/integration/targets/eos_interface/tests/cli/basic.yaml
blob: 14aca747fe22b736e0e79800f6843baa4e9fd1ca (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
221
222
223
224
225
226
227
228
229
---
- debug: msg="START eos_interface cli/basic.yaml on connection={{ ansible_connection }}"

- name: Set test interface
  set_fact:
    test_interface_1: ethernet1
    test_interface_2: ethernet2

- name: Configure interface (setup)
  eos_interface:
    name: "{{ test_interface_1 }}"
    description: test-interface-1
    mtu: 1800
    state: present
  become: yes
  register: result

- name: Configure interface
  eos_interface:
    name: "{{ test_interface_1 }}"
    description: test-interface-initial
    state: present
  become: yes
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"interface {{ test_interface_1 }}" in result.commands'
      - '"description test-interface-initial" in result.commands'

- name: Confgure interface (idempotent)
  eos_interface:
    name: "{{ test_interface_1 }}"
    description: test-interface-initial
    state: present
  become: yes
  register: result

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

- name: Confgure interface parameters
  eos_interface:
    name: "{{ test_interface_1 }}"
    description: test-interface
    mtu: 2000
    state: present
  become: yes
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"interface {{ test_interface_1 }}" in result.commands'
      - '"description test-interface" in result.commands'
      - '"mtu 2000" in result.commands'

- name: Change interface parameters
  eos_interface:
    name: "{{ test_interface_1 }}"
    description: test-interface-1
    mtu: 1800
    state: present
  become: yes
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"interface {{ test_interface_1 }}" in result.commands'
      - '"description test-interface-1" in result.commands'
      - '"mtu 1800" in result.commands'

- name: Disable interface
  eos_interface:
    name: "{{ test_interface_1 }}"
    enabled: False
  become: yes
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"interface {{ test_interface_1 }}" in result.commands'
      - '"shutdown" in result.commands'

- name: Enable interface
  eos_interface:
    name: "{{ test_interface_1 }}"
    enabled: True
  become: yes
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"interface {{ test_interface_1 }}" in result.commands'
      - '"no shutdown" in result.commands'

- name: Confgure second interface (setup)
  eos_interface:
    name: "{{ test_interface_2 }}"
    description: test-interface-initial
    mtu: 1800
    state: present
  become: yes
  register: result

- name: Add interface aggregate
  eos_interface:
    aggregate:
    - { name: "{{ test_interface_1 }}", mtu: 2000, description: test-interface-1 }
    - { name: "{{ test_interface_2 }}", mtu: 2000, description: test-interface-2 }
    state: present
  become: yes
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"interface {{ test_interface_1 }}" in result.commands'
      - '"mtu 2000" in result.commands'
      - '"interface {{ test_interface_2 }}" in result.commands'
      - '"description test-interface-2" in result.commands'
      - '"mtu 2000" in result.commands'

- name: Add interface aggregate (idempotent)
  eos_interface:
    aggregate:
    - { name: "{{ test_interface_1 }}", mtu: 2000, description: test-interface-1 }
    - { name: "{{ test_interface_2 }}", mtu: 2000, description: test-interface-2 }
    state: present
  become: yes
  register: result

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

- name: Disable interface aggregate
  eos_interface:
    aggregate:
    - { name: "{{ test_interface_1 }}" }
    - { name: "{{ test_interface_2 }}" }
    enabled: False
    state: present
  become: yes
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"interface {{ test_interface_1 }}" in result.commands'
      - '"shutdown" in result.commands'
      - '"interface {{ test_interface_2 }}" in result.commands'
      - '"shutdown" in result.commands'

- name: Enable interface aggregate
  eos_interface:
    aggregate:
    - { name: "{{ test_interface_1 }}" }
    - { name: "{{ test_interface_2 }}" }
    enabled: True
    state: present
  become: yes
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"interface {{ test_interface_1 }}" in result.commands'
      - '"no shutdown" in result.commands'
      - '"interface {{ test_interface_2 }}" in result.commands'
      - '"no shutdown" in result.commands'

- name: loopback interface setup
  eos_interface:
    aggregate:
    - name: loopback9
    - name: loopback10
    state: absent
  become: yes

- name: Create loopback interface aggregate
  eos_interface:
    aggregate:
    - name: loopback9
    - name: loopback10
    state: present
  become: yes
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"interface loopback9" in result.commands'
      - '"interface loopback10" in result.commands'

- name: Delete loopback interface aggregate
  eos_interface:
    aggregate:
    - name: loopback9
    - name: loopback10
    state: absent
  become: yes
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"no interface loopback9" in result.commands'
      - '"no interface loopback10" in result.commands'

- name: Delete loopback interface aggregate (idempotent)
  eos_interface:
    aggregate:
    - name: loopback9
    - name: loopback10
    state: absent
  become: yes
  register: result

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

- debug: msg="END eos_interface cli/basic.yaml on connection={{ ansible_connection }}"