summaryrefslogtreecommitdiff
path: root/test/integration/targets/gathering
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2018-05-11 13:59:54 -0400
committerGitHub <noreply@github.com>2018-05-11 13:59:54 -0400
commit95655fae5c3097ec126474a1c5cbe27649b9966a (patch)
tree4a0c65c06454ced1f570bbdd4ed44ff6686b82ec /test/integration/targets/gathering
parent7c510a2549ff7076c4613f5daa4ca84a9adb85a1 (diff)
downloadansible-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/gathering')
-rw-r--r--test/integration/targets/gathering/aliases1
-rw-r--r--test/integration/targets/gathering/explicit.yml14
-rw-r--r--test/integration/targets/gathering/implicit.yml23
-rwxr-xr-xtest/integration/targets/gathering/runme.sh7
-rw-r--r--test/integration/targets/gathering/smart.yml23
-rw-r--r--test/integration/targets/gathering/uuid.fact10
6 files changed, 78 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())))