-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_vlans_v2.yml
31 lines (26 loc) · 925 Bytes
/
get_vlans_v2.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
---
- name: "Get VLANs with NAPALM"
hosts: "all"
tasks:
- name: "Ensure the 'state/' directory exists"
ansible.builtin.file:
path: "{{ playbook_dir }}/state"
state: "directory"
delegate_to: "localhost"
run_once: true
- name: "Collect VLANs from switches"
napalm.napalm.get_facts:
filter: "vlans"
optional_args:
timeout: 15
register: "raw_vlans"
- name: "Print"
ansible.builtin.debug:
msg: "{{ raw_vlans }}"
- name: "Restructure raw VLANs into proper validation format"
ansible.builtin.set_fact:
reformed_vlans: "{{ raw_vlans | reform_vlans(strict_mode=strict_mode) }}"
- name: "Generate validation file based on current state"
ansible.builtin.copy:
content: "{{ reformed_vlans | to_nice_yaml(indent=2) }}"
dest: "{{ playbook_dir }}/state/{{ inventory_hostname }}_vlans.yml"