-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add save_ansible_facts.yml playbook for saving facts "in-tree"
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
# .. vim: foldmarker=[[[,]]]:foldmethod=marker | ||
|
||
- name: Save Ansible facts | ||
hosts: [ 'all_managed_hosts' ] | ||
become: False | ||
gather_facts: False | ||
|
||
tasks: | ||
|
||
- name: Write Ansible facts to facts directory | ||
command: ansible -m setup --tree {{ inventory_facts_path|d((inventory_dir | realpath) + "/../../facts") | quote }} {{ inventory_hostname }} --become | ||
become: False | ||
delegate_to: 'localhost' | ||
|
||
- name: Remove often changing facts to make facts deterministic and suitable to be put under version control | ||
shell: jq '{{ inventory_facts_jq_filter|d("del(.ansible_facts.ansible_date_time, .ansible_facts.ansible_env.SUDO_COMMAND, .ansible_facts.ansible_uptime_seconds)") }}' --sort-keys {{ (inventory_hostname) | quote }} > {{ (inventory_hostname + ".tmp") | quote }} && mv {{ (inventory_hostname + ".tmp") | quote }} {{ (inventory_hostname) | quote }}; | ||
args: | ||
chdir: '{{ inventory_facts_path|d((inventory_dir | realpath) + "/../../facts") }}' | ||
become: False | ||
delegate_to: 'localhost' |