On Saturday, 17 February 2018 11.34.19 CET YvanM wrote:
> 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:

Look into the facts caching feature of Ansible, that will only store the 
gathered facts and not inventory in one file per host.
https://docs.ansible.com/ansible/latest/playbooks_variables.html#fact-caching


>   - 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…

This will also only store the gathered facts and not inventory

  - setup:
    register: setupvar

  - copy:
      content: '{{ setupvar.ansible_facts }}'
      dest: /some/directory/{{ ansible_fqdn }}
    delegate_to: localhost


-- 
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/2922326.VB83n7Fvbj%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to