Thanks for the hint!
I forgot to say that I want to save all Ansible facts *host by host*, so
"{{ vars }}" contains to much data for me. Here is what I found to remove
vars from master and other hosts:
- name: save all facts to host specific file
copy:
content: "{{ ansible_delegated_vars[inventory_hostname].vars |
to_nice_json }}"
dest: "/some/directory/{{ ansible_fqdn }}"
delegate_to: localhost
This still contains variables from inventory, but it is better than nothing…
Le samedi 17 février 2018 10:20:14 UTC+1, Kai Stian Olstad a écrit :
>
> On Saturday, 17 February 2018 09.38.24 CET YvanM wrote:
> > Running Ansible 2.4, I am trying to save *all* Ansible facts to a file,
> > with a task like this:
> >
> > - name: save all facts to host specific file
> > copy:
> > content: "{{ ansible_facts }}"
> > dest: "/some/directory/{{ ansible_fqdn }}"
> > delegate_to: localhost
> >
> > However it fails with the error "'ansible_facts' is undefined".
> >
> > Do you think there is a workaround? I really do not want to have to
> select
> > facts one by one…
>
> The facts is not stored under "ansible_facts" but "vars" so use
>
> content: '{{ vars }}'
>
>
> --
> Kai Stian Olstad
>
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/67bf7b8b-0d23-4391-8616-26c514d6234a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.