mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Configurable and parallel gather facts (#49399)
* Configurable list of facts modules (#31783) - allow for args dict for specific modules - add way to pass parameters - avoid facts poluting test - move to 'facts gathered' flag - add 'gathering' setting tests - allow parallel option in case serialization is too slow - added support to automatically map network facts uses "smart" connection mapping
This commit is contained in:
parent
90bcff3d92
commit
8940732b58
12 changed files with 268 additions and 3 deletions
1
test/integration/targets/gathering/aliases
Normal file
1
test/integration/targets/gathering/aliases
Normal file
|
@ -0,0 +1 @@
|
|||
shippable/posix/group3
|
14
test/integration/targets/gathering/explicit.yml
Normal file
14
test/integration/targets/gathering/explicit.yml
Normal file
|
@ -0,0 +1,14 @@
|
|||
- hosts: testhost
|
||||
tasks:
|
||||
- name: ensure facts have not been collected
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts is undefined or not 'fqdn' in ansible_facts
|
||||
|
||||
- hosts: testhost
|
||||
gather_facts: True
|
||||
tasks:
|
||||
- name: ensure facts have been collected
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts is defined and 'fqdn' in ansible_facts
|
23
test/integration/targets/gathering/implicit.yml
Normal file
23
test/integration/targets/gathering/implicit.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
- hosts: testhost
|
||||
tasks:
|
||||
- name: check that facts were gathered but no local facts exist
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts is defined and 'fqdn' in ansible_facts
|
||||
- not 'uuid' in ansible_local
|
||||
- name: create 'local facts' for next gathering
|
||||
copy:
|
||||
src: uuid.fact
|
||||
dest: /etc/ansible/facts.d/
|
||||
mode: 0755
|
||||
|
||||
- hosts: testhost
|
||||
tasks:
|
||||
- name: ensure facts are gathered and includes the new 'local facts' created above
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts is defined and 'fqdn' in ansible_facts
|
||||
- "'uuid' in ansible_local"
|
||||
|
||||
- name: cleanup 'local facts' from target
|
||||
file: path=/etc/ansible/facts.d/uuid.fact state=absent
|
7
test/integration/targets/gathering/runme.sh
Executable file
7
test/integration/targets/gathering/runme.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eux
|
||||
|
||||
ANSIBLE_GATHERING=smart ansible-playbook smart.yml --flush-cache -i ../../inventory -v "$@"
|
||||
ANSIBLE_GATHERING=implicit ansible-playbook implicit.yml --flush-cache -i ../../inventory -v "$@"
|
||||
ANSIBLE_GATHERING=explicit ansible-playbook explicit.yml --flush-cache -i ../../inventory -v "$@"
|
23
test/integration/targets/gathering/smart.yml
Normal file
23
test/integration/targets/gathering/smart.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
- hosts: testhost
|
||||
tasks:
|
||||
- name: ensure facts are gathered but no local exists
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts is defined and 'fqdn' in ansible_facts
|
||||
- not 'uuid' in ansible_local
|
||||
- name: create local facts for latter test
|
||||
copy:
|
||||
src: uuid.fact
|
||||
dest: /etc/ansible/facts.d/
|
||||
mode: 0755
|
||||
|
||||
- hosts: testhost
|
||||
tasks:
|
||||
- name: ensure we still have facts, but didnt pickup new local ones
|
||||
assert:
|
||||
that:
|
||||
- ansible_facts is defined and 'fqdn' in ansible_facts
|
||||
- not 'uuid' in ansible_local
|
||||
|
||||
- name: remove local facts file
|
||||
file: path=/etc/ansible/facts.d/uuid.fact state=absent
|
10
test/integration/targets/gathering/uuid.fact
Normal file
10
test/integration/targets/gathering/uuid.fact
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
|
||||
# return a random string
|
||||
print(json.dumps(str(uuid.uuid4())))
|
|
@ -1,5 +1,6 @@
|
|||
- name: test playbook for ansible-pull
|
||||
hosts: all
|
||||
gather_facts: False
|
||||
tasks:
|
||||
- name: debug output
|
||||
debug: msg="test task"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue