-
Notifications
You must be signed in to change notification settings - Fork 46
/
nots_playbook.yml
70 lines (61 loc) · 2.38 KB
/
nots_playbook.yml
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
---
# nots_playbook.yaml
- name: "Collect network information and perform device-specific tests"
hosts: "ospf_routers"
tasks:
- name: "BLOCK >> Perform logging preparation"
block:
- name: "LOG >> Get ansible date/time facts"
setup:
filter: "ansible_date_time"
gather_subset: "!all"
- name: "LOG >> Store DTG as fact"
set_fact:
DTG: "{{ ansible_date_time.iso8601_basic_short }}"
- name: "LOG >> Ensure output logging directory exists"
file:
path: "logs"
state: "directory"
changed_when: false
- name: "LOG >> Store the log directory for this run"
set_fact:
LOG_PATH: "logs/nots_{{ DTG }}/"
- name: "LOG >> Build logging directory with path {{ LOG_PATH }}"
file:
path: "{{ LOG_PATH }}"
state: "directory"
changed_when: false
when: "log"
run_once: true
- name: "SYS >> Ensure mandatory keys are specified"
assert:
that:
- "process.id is defined"
- "process.id | int > 0 and process.id < 65536"
- "my_areas is defined and my_areas | length > 0"
- "all_areas is defined and all_areas.keys() | length > 0"
msg: "Mandatory keys incorrectly formatted or omitted (see README.md)"
- name: "INCLUDE >> Load commands for {{ ansible_network_os }} device"
include_tasks: "devices/{{ ansible_network_os }}/main.yml"
- name: "BLOCK >> Perform network-wide validation tests"
block:
- name: "SYS >> Store empty OSPF RID list for future comparison"
set_fact:
OSPF_RIDS: []
- name: "SYS >> Build OSPF RID list by iterating through hostvars"
set_fact:
OSPF_RIDS: "{{ OSPF_RIDS + [item.value.OSPF_BASIC.process.rid] }}"
when: >-
item.key in groups.ospf_routers and
item.value.OSPF_BASIC is defined
loop: "{{ dict(hostvars) | dict2items }}"
loop_control:
label: "host:{{ item.key }}"
- name: "SYS >> Assert that there are no duplicate OSPF RIDs"
assert:
that: "OSPF_RIDS | unique | length == OSPF_RIDS | length"
msg: |-
OSPF_RIDS contained duplicates. Check the logs to find bad nodes.
{{ OSPF_RIDS | to_nice_json }}
run_once: true
...