blob: 946728db6752b60d919d706a6a0bee7d9046481b (
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
|
---
- debug: msg="START cli/intent.yaml on connection={{ ansible_connection }}" #"
# To be able to run the lldp test we need to have a neighbor configured to talk to
# In DCI & Zuul we (currently) only spin up a single network VM, so we can't configure a neighbor
# In the future when we have multi-network-nodes running we can run these tests again
# https://github.com/ansible/ansible/issues/39667
- name: Detect if we have existing lldp neighbors configured
vyos.vyos.vyos_command:
commands:
- show lldp neighbors detail
register: neighbors_out
- name: Should we run lldp tests?
set_fact:
run_lldp_tests: "'PortDescr: eth0' in neighbors_out.stdout[0]"
- name: Enable LLDP service
vyos.vyos.vyos_lldp:
state: present
when: run_lldp_tests
- name: Create LLDP configuration
vyos.vyos.vyos_lldp_interface:
name: eth1
state: present
when: run_lldp_tests
- name: Setup (interface is up)
vyos.vyos.vyos_interface:
name: eth1
enabled: True
state: present
register: result
- name: Check intent arguments
vyos.vyos.vyos_interface:
name: eth1
state: up
register: result
- assert:
that:
- "result.failed == false"
- name: Check lldp neighbors intent arguments
vyos.vyos.vyos_interface:
name: eth0
neighbors:
- port: eth0
when: run_lldp_tests
register: result
- assert:
that:
- "result.failed == false"
when: run_lldp_tests
- name: Check intent arguments (failed condition)
vyos.vyos.vyos_interface:
name: eth1
state: down
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == true"
- "'state eq(down)' in result.failed_conditions"
- name: Check lldp neighbors intent arguments (failed)
vyos.vyos.vyos_interface:
name: eth0
neighbors:
- port: dummy_port
host: dummy_host
ignore_errors: yes
when: run_lldp_tests
register: result
- assert:
that:
- "result.failed == true"
- "'host dummy_host' in result.failed_conditions"
- "'port dummy_port' in result.failed_conditions"
when: run_lldp_tests
- name: Config + intent
vyos.vyos.vyos_interface:
name: eth1
enabled: False
state: down
register: result
- assert:
that:
- "result.failed == false"
- name: Config + intent (fail)
vyos.vyos.vyos_interface:
name: eth1
enabled: False
state: up
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == true"
- "'state eq(up)' in result.failed_conditions"
- name: Aggregate config + intent (pass)
vyos.vyos.vyos_interface:
aggregate:
- name: eth1
enabled: True
state: up
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == false"
- name: Check lldp neighbors intent aggregate arguments
vyos.vyos.vyos_interface:
aggregate:
- name: eth0
neighbors:
- port: eth0
when: run_lldp_tests
register: result
- assert:
that:
- "result.failed == false"
when: run_lldp_tests
- name: Check lldp neighbors intent aggregate arguments (failed)
vyos.vyos.vyos_interface:
aggregate:
- name: eth0
neighbors:
- port: eth0
- port: dummy_port
host: dummy_host
ignore_errors: yes
when: run_lldp_tests
register: result
- assert:
that:
- "result.failed == true"
- "'host dummy_host' in result.failed_conditions"
- "'port dummy_port' in result.failed_conditions"
when: run_lldp_tests
|