mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Configurable fact path (#18147)
* Make fact_path configurable * Add docs for fact_path * Add tests for localfacts * Default fact gathering settings in PlayContext
This commit is contained in:
committed by
Brian Coca
parent
f078946ed3
commit
1b2ad94496
@@ -5,7 +5,7 @@ testhost2 ansible_ssh_host=127.0.0.1 ansible_connection=local
|
||||
testhost3 ansible_ssh_host=127.0.0.3
|
||||
testhost4 ansible_ssh_host=127.0.0.4
|
||||
# For testing fact gathering
|
||||
facthost[0:8] ansible_host=1270.0.0.1 ansible_connection=local
|
||||
facthost[0:9] ansible_host=1270.0.0.1 ansible_connection=local
|
||||
|
||||
[binary_modules]
|
||||
testhost_binary_modules ansible_host=127.0.0.1 ansible_connection=local
|
||||
|
||||
@@ -129,3 +129,48 @@
|
||||
- 'ansible_interfaces|default("UNDEF_NET") != "UNDEF_NET"'
|
||||
- 'ansible_mounts|default("UNDEF_HW") == "UNDEF_HW"'
|
||||
- 'ansible_virtualization_role|default("UNDEF_VIRT") == "UNDEF_VIRT"'
|
||||
|
||||
- hosts: facthost9
|
||||
tags: [ 'fact_local']
|
||||
connection: local
|
||||
gather_facts: no
|
||||
tasks:
|
||||
- name: Create fact directories
|
||||
become: true
|
||||
with_items:
|
||||
- /etc/ansible/facts.d
|
||||
- /tmp/custom_facts.d
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ item }}"
|
||||
mode: '0777'
|
||||
- name: Deploy local facts
|
||||
with_items:
|
||||
- path: /etc/ansible/facts.d/testfact.fact
|
||||
content: '{ "fact_dir": "default" }'
|
||||
- path: /tmp/custom_facts.d/testfact.fact
|
||||
content: '{ "fact_dir": "custom" }'
|
||||
copy:
|
||||
dest: "{{ item.path }}"
|
||||
content: "{{ item.content }}"
|
||||
|
||||
- hosts: facthost9
|
||||
tags: [ 'fact_local']
|
||||
connection: local
|
||||
gather_facts: yes
|
||||
tasks:
|
||||
- name: Test reading facts from default fact_path
|
||||
assert:
|
||||
that:
|
||||
- '"{{ ansible_local.testfact.fact_dir }}" == "default"'
|
||||
|
||||
- hosts: facthost9
|
||||
tags: [ 'fact_local']
|
||||
connection: local
|
||||
gather_facts: yes
|
||||
fact_path: /tmp/custom_facts.d
|
||||
tasks:
|
||||
- name: Test reading facts from custom fact_path
|
||||
assert:
|
||||
that:
|
||||
- '"{{ ansible_local.testfact.fact_dir }}" == "custom"'
|
||||
|
||||
Reference in New Issue
Block a user