diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2018-05-11 13:59:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-11 13:59:54 -0400 |
commit | 95655fae5c3097ec126474a1c5cbe27649b9966a (patch) | |
tree | 4a0c65c06454ced1f570bbdd4ed44ff6686b82ec /test/integration/targets | |
parent | 7c510a2549ff7076c4613f5daa4ca84a9adb85a1 (diff) | |
download | ansible-95655fae5c3097ec126474a1c5cbe27649b9966a.tar.gz |
Configurable list of facts modules (#31783)
* configurable list of facts modules
- 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
Diffstat (limited to 'test/integration/targets')
-rw-r--r-- | test/integration/targets/gathering/aliases | 1 | ||||
-rw-r--r-- | test/integration/targets/gathering/explicit.yml | 14 | ||||
-rw-r--r-- | test/integration/targets/gathering/implicit.yml | 23 | ||||
-rwxr-xr-x | test/integration/targets/gathering/runme.sh | 7 | ||||
-rw-r--r-- | test/integration/targets/gathering/smart.yml | 23 | ||||
-rw-r--r-- | test/integration/targets/gathering/uuid.fact | 10 | ||||
-rw-r--r-- | test/integration/targets/pull/pull-integration-test/local.yml | 1 |
7 files changed, 79 insertions, 0 deletions
diff --git a/test/integration/targets/gathering/aliases b/test/integration/targets/gathering/aliases new file mode 100644 index 0000000000..79d8b9285e --- /dev/null +++ b/test/integration/targets/gathering/aliases @@ -0,0 +1 @@ +posix/ci/group3 diff --git a/test/integration/targets/gathering/explicit.yml b/test/integration/targets/gathering/explicit.yml new file mode 100644 index 0000000000..453dfb6aa0 --- /dev/null +++ b/test/integration/targets/gathering/explicit.yml @@ -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 diff --git a/test/integration/targets/gathering/implicit.yml b/test/integration/targets/gathering/implicit.yml new file mode 100644 index 0000000000..f1ea965d32 --- /dev/null +++ b/test/integration/targets/gathering/implicit.yml @@ -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 diff --git a/test/integration/targets/gathering/runme.sh b/test/integration/targets/gathering/runme.sh new file mode 100755 index 0000000000..1c0832c5a9 --- /dev/null +++ b/test/integration/targets/gathering/runme.sh @@ -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 "$@" diff --git a/test/integration/targets/gathering/smart.yml b/test/integration/targets/gathering/smart.yml new file mode 100644 index 0000000000..735cb461be --- /dev/null +++ b/test/integration/targets/gathering/smart.yml @@ -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 diff --git a/test/integration/targets/gathering/uuid.fact b/test/integration/targets/gathering/uuid.fact new file mode 100644 index 0000000000..79e3f62677 --- /dev/null +++ b/test/integration/targets/gathering/uuid.fact @@ -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()))) diff --git a/test/integration/targets/pull/pull-integration-test/local.yml b/test/integration/targets/pull/pull-integration-test/local.yml index f251b43473..a7f3a188d1 100644 --- a/test/integration/targets/pull/pull-integration-test/local.yml +++ b/test/integration/targets/pull/pull-integration-test/local.yml @@ -1,5 +1,6 @@ - name: test playbook for ansible-pull hosts: all + gather_facts: False tasks: - name: debug output debug: msg="test task" |