This repository has been archived by the owner on Jul 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaudit_report.j2
261 lines (218 loc) · 9.75 KB
/
audit_report.j2
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# Report for device {{ inventory_hostname }}.{{ domain_name }}
## Device details ({{ inventory_hostname }})
### HW model
{# The expected hw model is defined in yaml #}
{# The actual hw model should be equal to the expected model #}
{% set hw_model = registered_version.stdout_lines.0.modelName %}
{% if (hw_model == model) %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| Expected model | Actual model | Result |
| :-----: | :-----: | :-----: |
| {{ model }} | {{ hw_model }} | {{ result | default('FAIL') }} |
### SW version
{# The expected EOS version is defined in yaml #}
{# The actual EOS version should be equal to the expected EOS version #}
{% set eos_version = registered_version.stdout_lines.0.version %}
{% if (eos_version == version) %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| Expected version | Actual version | Result |
| :-----: | :-----: | :-----: |
| {{ version }} | {{ eos_version }} | {{ result | default('FAIL') }} |
## Environment ({{ inventory_hostname }})
### Power
| Power Supply | State | Result |
| :-----: | :-----: | :-----: |
{%- for key, value in registered_power.stdout_lines.0.powerSupplies.items() %}
{% set ps = key %}
{% set ps_state = value.state %}
{% if ps_state == 'ok' %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| {{ ps }} | {{ ps_state }} | {{ result | default('FAIL')}} |
{%- endfor %}
### Temperature
{% set temperature_status = registered_temperature.stdout_lines.0.systemStatus %}
{% if (temperature_status == 'temperatureOk') %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| System temperature status| Result |
| :-----: | :-----: |
| {{ temperature_status }} | {{ result | default('FAIL') }} |
### Cooling
#### Power supplies
| Power Supply | Fans status | Result |
| :-----: | :-----: | :-----: |
{%- for item in registered_fan.stdout_lines.0.powerSupplySlots %}
{% set ps_tmp_status = item.status %}
{% set ps = item.label %}
{% if ps_tmp_status == 'ok' %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| {{ ps }} | {{ ps_tmp_status }} | {{ result | default('FAIL')}} |
{%- endfor %}
#### Fan trays
| Fan tray | Fans status | Result |
| :-----: | :-----: | :-----: |
{%- for item in registered_fan.stdout_lines.0.fanTraySlots %}
{% set fan_tray_tmp_status = item.status %}
{% set fan_tray = item.label %}
{% if fan_tray_tmp_status == 'ok' %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| {{ fan_tray }} | {{ fan_tray_tmp_status }} | {{ result | default('FAIL')}} |
{%- endfor %}
## Interfaces admin and operationnal status ({{ inventory_hostname }})
### interfaces connected to other devices
{# Interfaces between devices are described in YAML files. Their actual state should be up/up #}
| Interface | Admin status | Operationnal Status | Result |
| :-----: | :-----: | :-----: | :-----: |
{%- for item in registered_interfaces.results %}
{% set interface = item.item.interface %}
{% set admin_status = item.stdout.0.interfaceDescriptions[item.item.interface].interfaceStatus %}
{% set op_status = item.stdout.0.interfaceDescriptions[item.item.interface].lineProtocolStatus %}
{% if (admin_status |upper == 'UP') and (op_status |upper == 'UP') %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| {{ interface }} | {{ admin_status }} | {{ op_status }} | {{ result | default('FAIL') }}
{%- endfor %}
## LLDP topology ({{ inventory_hostname }})
{# The topology is described in YAML files. The collected lldp details should match the topology described #}
| Interface | Expected neighbor | Actual neighbor | Expected neighbor interface | Actual neighbor interface | Result |
| :-----: | :-----: | :-----: | :-----: | :-----: | :-----: |
{%- for item in registered_lldp.results %}
{% set interface = item.item.interface %}
{% set actual_neighbor = item.stdout.0.lldpNeighbors[0].neighborDevice %}
{% set expected_neighbor = item.item.lldp_neighbor + '.' + hostvars[item.item.lldp_neighbor]['domain_name'] %}
{% set expected_neighbor_interface = item.item.lldp_neighbor_interface %}
{% set actual_neighbor_interface = item.stdout.0.lldpNeighbors[0].neighborPort %}
{% if (actual_neighbor |upper == expected_neighbor |upper) and (actual_neighbor_interface == expected_neighbor_interface) %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| {{ interface }} | {{ expected_neighbor }} | {{ actual_neighbor }} | {{ expected_neighbor_interface }} | {{ actual_neighbor_interface }} | {{ result | default('FAIL')}} |
{%- endfor %}
## BGP ({{ inventory_hostname }})
### EBGP sessions state
{# EBGP neighbors described in YAML files. BGP sessions should be established #}
| EBGP Peer | Session state | Result |
| :-----: | :-----: | :-----: |
{%- for item in registered_bgp.results %}
{% set peer = item.item.ebgp_peer_ip %}
{% set state = item.stdout.0.vrfs.default.peerList[0].state %}
{% if state |upper == 'ESTABLISHED' %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| {{ peer }} | {{ state }} | {{ result | default('FAIL')}} |
{%- endfor %}
### IPv4 prefixes sent to EBGP peer
{# EBGP neighbors described in YAML files #}
{# Some IPv4 prefixes should be sent to each EBGP neighbors #}
| EBGP Peer | IPv4 Prefixes sent | Result |
| :-----: | :-----: | :-----: |
{%- for item in registered_bgp.results %}
{% set peer = item.item.ebgp_peer_ip %}
{% set prefixes_sent = item.stdout.0.vrfs.default.peerList[0].prefixesSent %}
{% if (prefixes_sent >= 1) %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| {{ peer }} | {{ prefixes_sent }} | {{ result | default('FAIL')}} |
{%- endfor %}
### IPv4 prefixes received from EBGP peer
{# EBGP neighbors described in YAML files #}
{# Some IPv4 prefixes should be received from each BGP neighbors #}
| EBGP Peer | IPv4 Prefixes received | Result |
| :-----: | :-----: | :-----: |
{%- for item in registered_bgp.results %}
{% set peer = item.item.ebgp_peer_ip %}
{% set prefixes_received = item.stdout.0.vrfs.default.peerList[0].prefixesReceived %}
{% if (prefixes_received >= 1) %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| {{ peer }} | {{ prefixes_received }} | {{ result | default('FAIL')}}
{%- endfor %}
## Routing table ({{ inventory_hostname }})
{# loopback address of each EBGP neighbor is defined in YAML #}
{# Validate the routing table (including the "via nexthop" and the "via interface") for this address #}
| Destination (EBGP peer loopback) | via next hop | via interface | Result |
| :-----: | :-----: | :-----: | :-----: |
{%- for item in registered_routing.results %}
{% set address = item.item.ebgp_peer_loopback + ('/32') %}
{% set via_interface = item['stdout'][0]['vrfs']['default']['routes'][address]['vias'][0]['interface'] %}
{% set via_next_hop = item['stdout'][0]['vrfs']['default']['routes'][address]['vias'][0]['nexthopAddr'] %}
{% if (via_interface |upper == item.item.interface |upper) and (via_next_hop == item.item.ebgp_peer_ip) %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| {{ address }} | {{ via_next_hop }} | {{ via_interface }} | {{ result | default('FAIL')}} |
{%- endfor %}
## IP reachability ({{ inventory_hostname }})
### Ping EBGP peers from {{ inventory_hostname }} interfaces
{# EBGP neighbors described in YAML files #}
{# The devices should be able to ping their EBGP neighbors #}
| source interface | IP source | IP destination (EBGP peer) | Result |
| :-----: | :-----: | :-----: | :-----: |
{%- for item in registered_icmp_ebgp.results %}
{% set source = item.item.ip %}
{% set destination = item.item.ebgp_peer_ip %}
{% set interface = item.item.interface %}
{% if "1 received" in item.stdout.0 %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| {{ interface }} | {{ source }} | {{ destination }} | {{ result | default('FAIL')}} |
{%- endfor %}
### Ping EBGP peers loopback from {{ inventory_hostname }} interfaces
{# loopback address of each EBGP neighbor is defined in YAML #}
{# The devices should be able to ping their EBGP neighbors #}
| source interface | IP source | IP destination (EBGP peer loopback) | Result |
| :-----: | :-----: | :-----: | :-----: |
{%- for item in registered_icmp_from_loopback_to_ebgp_loopback.results %}
{% set source = item.item.ip %}
{% set destination = item.item.ebgp_peer_loopback %}
{% set interface = item.item.interface %}
{% if "1 received" in item.stdout.0 %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| {{ interface }} | {{ source }} | {{ destination }} | {{ result | default('FAIL')}} |
{%- endfor %}
### Ping EBGP peers loopback from {{ inventory_hostname }} loopback
{# loopback address of each EBGP neighbor is defined in YAML. The devices should be able to ping their EBGP neighbors #}
| IP source | IP destination (EBGP peer loopback) | Result |
| :-----: | :-----: | :-----: |
{%- for item in registered_icmp_from_loopback_to_ebgp_loopback.results %}
{% set source = hostvars[inventory_hostname]['loopback'] %}
{% set destination = item.item.ebgp_peer_loopback %}
{% if "1 received" in item.stdout.0 %}
{% set result = 'PASS' %}
{% else %}
{% set result = 'FAIL' %}
{% endif %}
| {{ source }} | {{ destination }} | {{ result | default('FAIL')}} |
{%- endfor %}