-
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.
Ansible local fact management strategy change
- Loading branch information
Showing
7 changed files
with
72 additions
and
81 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,46 +1,9 @@ | ||
ansible__role_enabled: true | ||
ansible__manage_local_facts: true | ||
|
||
ansible__local_fact_template: aybarsm_linux.json.fact.j2 | ||
ansible__local_fact_backup: true | ||
ansible__local_facts_dir: "{{ (not lookup('config', 'DEFAULT_FACT_PATH')) | ternary('/etc/ansible/facts.d', lookup('config', 'DEFAULT_FACT_PATH')) }}" | ||
ansible__local_fact_file: "{{ ansible__local_facts_dir }}/aybarsm_linux.fact" | ||
ansible__local_fact_name: aybarsm_linux | ||
ansible__local_fact_file: "{{ ansible__local_facts_dir }}/{{ ansible__local_fact_name }}.fact" | ||
ansible__local_fact_template: "{{ ansible__local_fact_name }}.json.fact.j2" | ||
|
||
__ansible__config: | ||
modules: | ||
ansible_builtin_apt: | ||
uniques: ['name'] | ||
aliases: | ||
allow_downgrade: ['allow-downgrade', 'allow_downgrades', 'allow-downgrades'] | ||
allow_unauthenticated: ['allow-unauthenticated'] | ||
default_release: ['default-release'] | ||
install_recommends: ['install-recommends'] | ||
name: ['package', 'pkg'] | ||
update_cache: ['update-cache'] | ||
ansible_builtin_apt_repository: | ||
uniques: ['repo'] | ||
aliases: | ||
update_cache: ['update-cache'] | ||
ansible_builtin_apt_key: | ||
uniques: ['keyserver', 'url', 'id', 'file'] | ||
ansible_builtin_dnf: | ||
uniques: ['name'] | ||
aliases: | ||
name: ['package', 'pkg'] | ||
update_cache: ['expire-cache'] | ||
ansible_builtin_yum_repository: | ||
uniques: ['name'] | ||
aliases: | ||
attributes: ['attr'] | ||
sslcacert: ['ca_cert'] | ||
sslclientcert: ['client_cert'] | ||
sslclientkey: ['client_key'] | ||
sslverify: ['validate_certs'] | ||
ansible_builtin_copy: | ||
uniques: ['dest'] | ||
aliases: | ||
attributes: ['attr'] | ||
ansible_builtin_template: | ||
uniques: ['dest'] | ||
aliases: | ||
attributes: ['attr'] |
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,7 +1,36 @@ | ||
--- | ||
# REVIEW: Execute the handler without when control, let the task decide to notify or not | ||
- 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 }}" | ||
vars: | ||
on_host: "{{ ansible_local[ansible__local_fact_name] | default({}) | b64encode }}" | ||
on_runtime: "{{ ansible__local_facts | default({}) | b64encode }}" | ||
ansible_callback_diy_runner_on_skipped_msg: | | ||
skipping: [{{ inventory_hostname }}] | ||
msg: {{ (not ansible_check_mode and on_host != on_runtime) | ternary("Host local facts not changed.", "DRY-RUN") }} | ||
ansible_callback_diy_runner_on_skipped_msg_color: green | ||
when: on_host != on_runtime | ||
register: ansible__local_facts_settle | ||
listen: "ansible__local_facts_settle" | ||
notify: "ansible__local_facts_reread" | ||
|
||
- name: Re-read local facts on the host | ||
become: true | ||
ansible.builtin.setup: | ||
filter: ansible_local | ||
register: ansible__local_facts_reread | ||
listen: "ansible__local_facts_reread" | ||
notify: ansible__local_facts_assign | ||
|
||
- name: Assign host local facts to ansible facts | ||
ansible.builtin.set_fact: | ||
ansible__local_facts: "{{ ansible_local[ansible__local_fact_name] }}" | ||
register: ansible__local_facts_assign | ||
listen: "ansible__local_facts_assign" | ||
when: | ||
- ansible__local_fact_name is defined | ||
- ansible_local[ansible__local_fact_name] is defined |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,38 @@ | ||
__ansible__config: | ||
modules: | ||
ansible_builtin_apt: | ||
uniques: ['name'] | ||
aliases: | ||
allow_downgrade: ['allow-downgrade', 'allow_downgrades', 'allow-downgrades'] | ||
allow_unauthenticated: ['allow-unauthenticated'] | ||
default_release: ['default-release'] | ||
install_recommends: ['install-recommends'] | ||
name: ['package', 'pkg'] | ||
update_cache: ['update-cache'] | ||
ansible_builtin_apt_repository: | ||
uniques: ['repo'] | ||
aliases: | ||
update_cache: ['update-cache'] | ||
ansible_builtin_apt_key: | ||
uniques: ['keyserver', 'url', 'id', 'file'] | ||
ansible_builtin_dnf: | ||
uniques: ['name'] | ||
aliases: | ||
name: ['package', 'pkg'] | ||
update_cache: ['expire-cache'] | ||
ansible_builtin_yum_repository: | ||
uniques: ['name'] | ||
aliases: | ||
attributes: ['attr'] | ||
sslcacert: ['ca_cert'] | ||
sslclientcert: ['client_cert'] | ||
sslclientkey: ['client_key'] | ||
sslverify: ['validate_certs'] | ||
ansible_builtin_copy: | ||
uniques: ['dest'] | ||
aliases: | ||
attributes: ['attr'] | ||
ansible_builtin_template: | ||
uniques: ['dest'] | ||
aliases: | ||
attributes: ['attr'] |