summaryrefslogtreecommitdiff
path: root/test/integration/targets/nxos_linkagg/tests/common/sanity.yaml
blob: a25c70571956fbca07439675c31c1c2ffb693627 (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
---
- debug: msg="START connection={{ ansible_connection }} nxos_linkagg sanity test"

- set_fact: testint1="{{ nxos_int1 }}"
- set_fact: testint2="{{ nxos_int2 }}"

- name: "Enable feature LACP"
  nxos_feature:
    feature: lacp
    state: enabled
  ignore_errors: yes

- name: setup - remove config used in test(part1)
  nxos_config:
    lines:
      - no interface port-channel 20
      - no interface port-channel 100

- name: setup - remove config used in test(part2)
  nxos_config:
    lines:
      - no channel-group 20
    parents: "{{ item }}"
  ignore_errors: yes
  loop:
    - "interface {{ testint1 }}"
    - "interface {{ testint2 }}"

- name: Put interface in L2 mode
  nxos_interface:
    aggregate:
    - { name: "{{testint1}}" }
    - { name: "{{testint2}}" }
    mode: layer2
  when: platform is match("N35")

- name: create linkagg
  nxos_linkagg: &create
    group: 20
    state: present
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"interface port-channel 20" in result.commands'

- name: create linkagg(Idempotence)
  nxos_linkagg: *create
  register: result

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

- name: set link aggregation group to members declaratively
  nxos_linkagg: &configure_member
    group: 20
    mode: active
    force: True
    members:
      - "{{ testint1 }}"
      - "{{ testint2 }}"
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"interface {{ testint1 }}" in result.commands'
      - '"channel-group 20 force mode active" in result.commands'
      - '"interface {{ testint2 }}" in result.commands'
      - '"channel-group 20 force mode active" in result.commands'

- name: set link aggregation group to members(Idempotence)
  nxos_linkagg: *configure_member
  register: result

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

- name: remove link aggregation group from member declaratively
  nxos_linkagg: &remove_member
    group: 20
    mode: active
    force: True
    members:
      - "{{ testint2 }}"
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"interface {{ testint1 }}" in result.commands'
      - '"no channel-group 20" in result.commands'

- name: remove link aggregation group from member(Idempotence)
  nxos_linkagg: *remove_member
  register: result

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

- name: remove linkagg
  nxos_linkagg: &remove
    group: 20
    state: absent
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"no interface port-channel 20" in result.commands'

- name: remove linkagg(Idempotence)
  nxos_linkagg: *remove
  register: result

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

- name: create aggregate of linkagg definitions
  nxos_linkagg: &create_agg
    aggregate:
      - { group: 20, min_links: 3 }
      - { group: 100, min_links: 4 }
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"interface port-channel 20" in result.commands'
      - '"lacp min-links 3" in result.commands'
      - '"interface port-channel 100" in result.commands'
      - '"lacp min-links 4" in result.commands'

- name: create aggregate of linkagg definitions(Idempotence)
  nxos_linkagg: *create_agg
  register: result

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

- name: remove aggregate of linkagg definitions
  nxos_linkagg: &remove_agg
    aggregate:
      - { group: 20, min_links: 3 }
      - { group: 100, min_links: 4 }
    state: absent
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"no interface port-channel 20" in result.commands'
      - '"no interface port-channel 100" in result.commands'

- name: remove aggregate of linkagg definitions(Idempotence)
  nxos_linkagg: *remove_agg
  register: result

- assert:
    that:
      - 'result.changed == false'
 
- name: teardown - remove config used in test(part1)
  nxos_config:
    lines:
      - no interface port-channel 20
      - no interface port-channel 100

- name: teardown - remove config used in test(part2)
  nxos_config:
    lines:
      - no channel-group 20
    parents: "{{ item }}"
  ignore_errors: yes
  loop:
    - "interface {{ testint1 }}"
    - "interface {{ testint2 }}"

- name: "Disable feature LACP"
  nxos_feature:
    feature: lacp
    state: disabled

- debug: msg="END connection={{ ansible_connection }} nxos_linkagg sanity test"