facts to txt file

Hi all

Is there a way to store facts like (mem,CPU,HD etc ) to a txt file ?

Thanks !
Marcio X

use ansible-cmdb.
https://ansible-cmdb.readthedocs.io/en/latest/#:~:text=Ansible-cmdb%20takes%20the%20output,by%20Ansible%20with%20custom%20data.

Something like this could do the trick

  • name: Dump vars
    hosts: all
    connection: local
    gather_facts: True
    tasks:
  • name: Dump hostvars
    delegate_to: localhost
    copy:
    content: “{{ hostvars[inventory_hostname] | to_nice_json }}”
    dest: /tmp/setup-{{ inventory_hostname }}.json
    when:
  • debug_mode | d(True) | bool

If debug_mode is enabled, it will generate a /tmp/setup-$(hostname).json file with facts gathered in the ansible control machine.

Regards,

fact cache plugins can be used, the JSON one is particularly useful
for this case.

https://docs.ansible.com/ansible/latest/plugins/cache.html

Perfect ! :innocent:

I am so thankful for you helping guys !
Have a great weekend

Marcio Xavier