-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PRE - Role: ansible - Local fact management optimisation #2
- Loading branch information
Showing
4 changed files
with
26 additions
and
54 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1 @@ | ||
--- | ||
- name: Settle local facts on host if changed | ||
become: true | ||
ansible.builtin.template: | ||
src: "{{ ansible__local_fact_template }}" | ||
dest: "{{ ansible__local_fact_file }}" | ||
backup: "{{ ansible__local_fact_backup | default(omit) | bool }}" | ||
register: ansible__settle_local_facts | ||
listen: "ansible__settle_local_facts" | ||
when: | ||
- linux_role_ansible_enabled | bool | ||
- linux_role_ansible_manage_local_facts | bool | ||
--- |
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
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 |
---|---|---|
@@ -1,5 +1,11 @@ | ||
{% if ansible_local[ansible__local_fact_name] is defined and ansible__update_local_facts is defined %} | ||
{% set facts_ansible_settled = ansible_local[ansible__local_fact_name] | default({}) %} | ||
{% set facts_role_update_settled = ansible__update_local_facts.ansible_local[ansible__local_fact_name] | default({}) %} | ||
{% set list_merge_strategy = ansible__local_fact_list_merge_strategy | default('prepend') %} | ||
{% set final_local_facts = facts_ansible_settled | combine(facts_role_update_settled, recursive=true, list_merge=list_merge_strategy) %} | ||
{{ final_local_facts | to_nice_json }} | ||
{{ final_local_facts | to_nice_json }} | ||
{% else %} | ||
{ | ||
"init": "{{ now().utcnow().strftime('%Y-%m-%dT%H:%M:%S.%fZ') }}" | ||
} | ||
{% endif %} |