# How to save a whole ansible\_facts into a json file

**URL:** <https://forum.ansible.com/t/how-to-save-a-whole-ansible-facts-into-a-json-file/24441>\
**Category:** Ansible Project\
**Created:** [May 10, 2017, 2:24am UTC](https://forum.ansible.com/t/how-to-save-a-whole-ansible-facts-into-a-json-file/24441 "2017-05-10T02:24:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Kang](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@James\_Kang](https://forum.ansible.com/u/James_Kang)\
**Post date:** [May 10, 2017, 2:24am UTC](https://forum.ansible.com/t/how-to-save-a-whole-ansible-facts-into-a-json-file/24441/1 "2017-05-10T02:24:21Z")

</div>

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.

```auto
---
- 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"

```
