summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/ansible-pull
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/ansible-pull')
-rw-r--r--test/integration/targets/ansible-pull/aliases2
-rw-r--r--test/integration/targets/ansible-pull/cleanup.yml16
-rw-r--r--test/integration/targets/ansible-pull/pull-integration-test/ansible.cfg2
-rw-r--r--test/integration/targets/ansible-pull/pull-integration-test/inventory2
-rw-r--r--test/integration/targets/ansible-pull/pull-integration-test/local.yml20
-rw-r--r--test/integration/targets/ansible-pull/pull-integration-test/multi_play_1.yml6
-rw-r--r--test/integration/targets/ansible-pull/pull-integration-test/multi_play_2.yml6
-rwxr-xr-xtest/integration/targets/ansible-pull/runme.sh87
-rw-r--r--test/integration/targets/ansible-pull/setup.yml11
9 files changed, 152 insertions, 0 deletions
diff --git a/test/integration/targets/ansible-pull/aliases b/test/integration/targets/ansible-pull/aliases
new file mode 100644
index 0000000..1d28bdb
--- /dev/null
+++ b/test/integration/targets/ansible-pull/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group5
+context/controller
diff --git a/test/integration/targets/ansible-pull/cleanup.yml b/test/integration/targets/ansible-pull/cleanup.yml
new file mode 100644
index 0000000..32a6602
--- /dev/null
+++ b/test/integration/targets/ansible-pull/cleanup.yml
@@ -0,0 +1,16 @@
+- hosts: localhost
+ vars:
+ git_install: '{{ lookup("file", lookup("env", "OUTPUT_DIR") + "/git_install.json") }}'
+ tasks:
+ - name: remove unwanted packages
+ package:
+ name: git
+ state: absent
+ when: git_install.changed
+
+ - name: remove auto-installed packages from FreeBSD
+ package:
+ name: git
+ state: absent
+ autoremove: yes
+ when: git_install.changed and ansible_distribution == "FreeBSD"
diff --git a/test/integration/targets/ansible-pull/pull-integration-test/ansible.cfg b/test/integration/targets/ansible-pull/pull-integration-test/ansible.cfg
new file mode 100644
index 0000000..f8fc6cd
--- /dev/null
+++ b/test/integration/targets/ansible-pull/pull-integration-test/ansible.cfg
@@ -0,0 +1,2 @@
+[defaults]
+inventory = inventory
diff --git a/test/integration/targets/ansible-pull/pull-integration-test/inventory b/test/integration/targets/ansible-pull/pull-integration-test/inventory
new file mode 100644
index 0000000..72644ce
--- /dev/null
+++ b/test/integration/targets/ansible-pull/pull-integration-test/inventory
@@ -0,0 +1,2 @@
+testhost1.example.com
+localhost
diff --git a/test/integration/targets/ansible-pull/pull-integration-test/local.yml b/test/integration/targets/ansible-pull/pull-integration-test/local.yml
new file mode 100644
index 0000000..d358ee8
--- /dev/null
+++ b/test/integration/targets/ansible-pull/pull-integration-test/local.yml
@@ -0,0 +1,20 @@
+- name: test playbook for ansible-pull
+ hosts: all
+ gather_facts: False
+ tasks:
+ - name: debug output
+ debug: msg="test task"
+ - name: check for correct inventory
+ debug: msg="testing for inventory content"
+ failed_when: "'testhost1.example.com' not in groups['all']"
+ - name: check for correct limit
+ debug: msg="testing for limit"
+ failed_when: "'testhost1.example.com' == inventory_hostname"
+ - name: final task, has to be reached for the test to succeed
+ debug: msg="MAGICKEYWORD"
+
+ - name: check that extra vars are correclty passed
+ assert:
+ that:
+ - docker_registries_login is defined
+ tags: ['never', 'test_ev']
diff --git a/test/integration/targets/ansible-pull/pull-integration-test/multi_play_1.yml b/test/integration/targets/ansible-pull/pull-integration-test/multi_play_1.yml
new file mode 100644
index 0000000..0ec0da6
--- /dev/null
+++ b/test/integration/targets/ansible-pull/pull-integration-test/multi_play_1.yml
@@ -0,0 +1,6 @@
+- name: test multiple playbooks for ansible-pull
+ hosts: all
+ gather_facts: False
+ tasks:
+ - name: debug output
+ debug: msg="test multi_play_1"
diff --git a/test/integration/targets/ansible-pull/pull-integration-test/multi_play_2.yml b/test/integration/targets/ansible-pull/pull-integration-test/multi_play_2.yml
new file mode 100644
index 0000000..1fe5a58
--- /dev/null
+++ b/test/integration/targets/ansible-pull/pull-integration-test/multi_play_2.yml
@@ -0,0 +1,6 @@
+- name: test multiple playbooks for ansible-pull
+ hosts: all
+ gather_facts: False
+ tasks:
+ - name: debug output
+ debug: msg="test multi_play_2"
diff --git a/test/integration/targets/ansible-pull/runme.sh b/test/integration/targets/ansible-pull/runme.sh
new file mode 100755
index 0000000..347971a
--- /dev/null
+++ b/test/integration/targets/ansible-pull/runme.sh
@@ -0,0 +1,87 @@
+#!/usr/bin/env bash
+
+set -eux
+set -o pipefail
+
+# http://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x
+temp_dir=$(shell mktemp -d 2>/dev/null || mktemp -d -t 'ansible-testing-XXXXXXXXXX')
+trap 'rm -rf "${temp_dir}"' EXIT
+
+repo_dir="${temp_dir}/repo"
+pull_dir="${temp_dir}/pull"
+temp_log="${temp_dir}/pull.log"
+
+ansible-playbook setup.yml -i ../../inventory
+
+cleanup="$(pwd)/cleanup.yml"
+
+trap 'ansible-playbook "${cleanup}" -i ../../inventory' EXIT
+
+cp -av "pull-integration-test" "${repo_dir}"
+cd "${repo_dir}"
+(
+ git init
+ git config user.email "ansible@ansible.com"
+ git config user.name "Ansible Test Runner"
+ git add .
+ git commit -m "Initial commit."
+)
+
+function pass_tests {
+ # test for https://github.com/ansible/ansible/issues/13688
+ if ! grep MAGICKEYWORD "${temp_log}"; then
+ cat "${temp_log}"
+ echo "Missing MAGICKEYWORD in output."
+ exit 1
+ fi
+
+ # test for https://github.com/ansible/ansible/issues/13681
+ if grep -E '127\.0\.0\.1.*ok' "${temp_log}"; then
+ cat "${temp_log}"
+ echo "Found host 127.0.0.1 in output. Only localhost should be present."
+ exit 1
+ fi
+ # make sure one host was run
+ if ! grep -E 'localhost.*ok' "${temp_log}"; then
+ cat "${temp_log}"
+ echo "Did not find host localhost in output."
+ exit 1
+ fi
+}
+
+function pass_tests_multi {
+ # test for https://github.com/ansible/ansible/issues/72708
+ if ! grep 'test multi_play_1' "${temp_log}"; then
+ cat "${temp_log}"
+ echo "Did not run multiple playbooks"
+ exit 1
+ fi
+ if ! grep 'test multi_play_2' "${temp_log}"; then
+ cat "${temp_log}"
+ echo "Did not run multiple playbooks"
+ exit 1
+ fi
+}
+
+export ANSIBLE_INVENTORY
+export ANSIBLE_HOST_PATTERN_MISMATCH
+
+unset ANSIBLE_INVENTORY
+unset ANSIBLE_HOST_PATTERN_MISMATCH
+
+ANSIBLE_CONFIG='' ansible-pull -d "${pull_dir}" -U "${repo_dir}" "$@" | tee "${temp_log}"
+
+pass_tests
+
+# ensure complex extra vars work
+PASSWORD='test'
+USER=${USER:-'broken_docker'}
+JSON_EXTRA_ARGS='{"docker_registries_login": [{ "docker_password": "'"${PASSWORD}"'", "docker_username": "'"${USER}"'", "docker_registry_url":"repository-manager.company.com:5001"}], "docker_registries_logout": [{ "docker_password": "'"${PASSWORD}"'", "docker_username": "'"${USER}"'", "docker_registry_url":"repository-manager.company.com:5001"}] }'
+
+ANSIBLE_CONFIG='' ansible-pull -d "${pull_dir}" -U "${repo_dir}" -e "${JSON_EXTRA_ARGS}" "$@" --tags untagged,test_ev | tee "${temp_log}"
+
+pass_tests
+
+ANSIBLE_CONFIG='' ansible-pull -d "${pull_dir}" -U "${repo_dir}" "$@" multi_play_1.yml multi_play_2.yml | tee "${temp_log}"
+
+pass_tests_multi \ No newline at end of file
diff --git a/test/integration/targets/ansible-pull/setup.yml b/test/integration/targets/ansible-pull/setup.yml
new file mode 100644
index 0000000..ebd5a1c
--- /dev/null
+++ b/test/integration/targets/ansible-pull/setup.yml
@@ -0,0 +1,11 @@
+- hosts: localhost
+ tasks:
+ - name: install git
+ package:
+ name: git
+ when: ansible_distribution not in ["MacOSX", "Alpine"]
+ register: git_install
+ - name: save install result
+ copy:
+ content: '{{ git_install }}'
+ dest: '{{ lookup("env", "OUTPUT_DIR") }}/git_install.json'