I know I can use the command below to save all ansible facts to a file:
ansible all -m setup --tree facts.d/
But I want to do this within a playbook. Currently I have:
- name: Collect facts
setup:
fact_path: facts.d
But nothing is collected when I run the task. Am I missing something?
- name: save all facts to host specific file
copy:
content: "{{ ansible_delegated_vars[inventory_hostname].vars | to_nice_json }}"
dest: "{{ playbook_dir }}/{{ ansible_fqdn }}"
delegate_to: localhost
This will create a file per host at playbook dir.
Reference : https://groups.google.com/g/ansible-project/c/HI65wOUIrx4?pli=1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With