- Create a new playbook, pb_jnpr_facts.yml, with the following task to collect the facts:
$ cat pb_jnpr_facts.yml
---
- name: Collect and Validate Juniper Facts
hosts: junos
tasks:
- name: Collect Juniper Facts
junos_facts:
- Update the pb_jnpr_facts.yml playbook with the following tasks to create a facts report for each node in our inventory:
- name: Create Facts Folder
file: path=device_facts state=directory
run_once: yes
- name: Create Basic Device Facts Report
blockinfile:
path: "device_facts/{{ inventory_hostname }}.txt"
block: |
device_name: {{ Ansible_net_hostname }}
model: {{ Ansible_net_system }} {{ Ansible_net_model }}
os_version: {{ Ansible_net_version }}
serial_number: {{ Ansible_net_serialnum }}
create: yes
- Update the playbook with the following task to validate the operational state for the core interfaces:
- name: Validate all Core Interface are Operational
assert:
that:
- Ansible_net_interfaces[item.port]['oper-status'] == 'up'
fail_msg: "Interface {{item.port}} is not Operational "
loop: "{{ p2p_ip[inventory_hostname] }}"