summaryrefslogtreecommitdiff
path: root/test/integration/targets/delegate_to
diff options
context:
space:
mode:
authorMatt Clay <matt@mystile.com>2016-10-12 14:57:53 -0700
committerGitHub <noreply@github.com>2016-10-12 14:57:53 -0700
commit80a5c70ad795f3cd1e6e3edde7077a8dfd65470b (patch)
tree50ab0ad670d2631fa32cad47019d9a970ed81596 /test/integration/targets/delegate_to
parentbf3d546d9a48cf5391a91002733d4a6ea62b1a0c (diff)
downloadansible-80a5c70ad795f3cd1e6e3edde7077a8dfd65470b.tar.gz
Split integration tests out from Makefile. (#17976)
Diffstat (limited to 'test/integration/targets/delegate_to')
-rw-r--r--test/integration/targets/delegate_to/roles/test_template/templates/foo.j23
-rwxr-xr-xtest/integration/targets/delegate_to/runme.sh5
-rw-r--r--test/integration/targets/delegate_to/test_delegate_to.yml56
3 files changed, 64 insertions, 0 deletions
diff --git a/test/integration/targets/delegate_to/roles/test_template/templates/foo.j2 b/test/integration/targets/delegate_to/roles/test_template/templates/foo.j2
new file mode 100644
index 0000000000..22187f9130
--- /dev/null
+++ b/test/integration/targets/delegate_to/roles/test_template/templates/foo.j2
@@ -0,0 +1,3 @@
+{{ templated_var }}
+
+{{ templated_dict | to_nice_json }}
diff --git a/test/integration/targets/delegate_to/runme.sh b/test/integration/targets/delegate_to/runme.sh
new file mode 100755
index 0000000000..782ec0902e
--- /dev/null
+++ b/test/integration/targets/delegate_to/runme.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ANSIBLE_HOST_KEY_CHECKING=false ansible-playbook test_delegate_to.yml -i ../../inventory -v "$@"
diff --git a/test/integration/targets/delegate_to/test_delegate_to.yml b/test/integration/targets/delegate_to/test_delegate_to.yml
new file mode 100644
index 0000000000..d75857cc6c
--- /dev/null
+++ b/test/integration/targets/delegate_to/test_delegate_to.yml
@@ -0,0 +1,56 @@
+- hosts: testhost3
+ vars:
+ - template_role: ./roles/test_template
+ - output_dir: "{{ playbook_dir }}"
+ - templated_var: foo
+ - templated_dict: { 'hello': 'world' }
+ tasks:
+ - name: Test no delegate_to
+ setup:
+ register: setup_results
+
+ - assert:
+ that:
+ - '"127.0.0.3" in setup_results.ansible_facts.ansible_env["SSH_CONNECTION"]'
+
+ - name: Test delegate_to with host in inventory
+ setup:
+ register: setup_results
+ delegate_to: testhost4
+
+ - assert:
+ that:
+ - '"127.0.0.4" in setup_results.ansible_facts.ansible_env["SSH_CONNECTION"]'
+
+ - name: Test delegate_to with host not in inventory
+ setup:
+ register: setup_results
+ delegate_to: 127.0.0.254
+
+ - assert:
+ that:
+ - '"127.0.0.254" in setup_results.ansible_facts.ansible_env["SSH_CONNECTION"]'
+#
+# Smoketest some other modules do not error as a canary
+#
+ - name: Test file works with delegate_to and a host in inventory
+ file: path={{ output_dir }}/foo.txt mode=0644 state=touch
+ delegate_to: testhost4
+
+ - name: Test file works with delegate_to and a host not in inventory
+ file: path={{ output_dir }}/tmp.txt mode=0644 state=touch
+ delegate_to: 127.0.0.254
+
+ - name: Test template works with delegate_to and a host in inventory
+ template: src={{ template_role }}/templates/foo.j2 dest={{ output_dir }}/foo.txt
+ delegate_to: testhost4
+
+ - name: Test template works with delegate_to and a host not in inventory
+ template: src={{ template_role }}/templates/foo.j2 dest={{ output_dir }}/foo.txt
+ delegate_to: 127.0.0.254
+
+ - name: remove test file
+ file: path={{ output_dir }}/foo.txt state=absent
+
+ - name: remove test file
+ file: path={{ output_dir }}/tmp.txt state=absent