Hi,
I am trying to save Arista switches inventory information in json format per switch.
But I could not figure it out - I was only able to access individual sub variable like “ansible_net_config”.
What is want is the whole ansible_facts provided by the module.
Any idea?
I am trying to avoid either saving to multiple files per fact or more complex aggregation.
Thanks in advance.
Below is the sample playbook I use.
---
- hosts: "{{ target | default('None')}}"
connection: local
vars:
playbookname: get-arista-facts.yml
destination_dir: "./Configs/Switches"
cli:
username: admin
password: mypasswd
authorize: yes
host: "{{ inventory_hostname }}"
transport: cli
tasks:
- eos_facts:
gather_subset: "all"
provider: "{{ cli }}"
- local_action: copy content="{{ ansible_net_config }}" dest="{{ destination_dir }}/{{ inventory_hostname }}.config"
- local_action: copy content="{{ ansible_net_model }}" dest="{{ destination_dir }}/{{ inventory_hostname }}.ansible_net_model.json"
- local_action: copy content="{{ ansible_net_hostname }}" dest="{{ destination_dir }}/{{ inventory_hostname }}.ansible_net_hostname.json"
- local_action: copy content="{{ ansible_net_serialnum }}" dest="{{ destination_dir }}/{{ inventory_hostname }}.ansible_net_serialnum.json"
- local_action: copy content="{{ ansible_net_gather_subset }}" dest="{{ destination_dir }}/{{ inventory_hostname }}.ansible_net_gather_subset.json"
- local_action: copy content="{{ ansible_net_interfaces }}" dest="{{ destination_dir }}/{{ inventory_hostname }}.ansible_net_interfaces.json"