summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/pull
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/pull')
-rw-r--r--test/integration/targets/pull/aliases2
-rw-r--r--test/integration/targets/pull/cleanup.yml16
-rw-r--r--test/integration/targets/pull/pull-integration-test/ansible.cfg2
-rw-r--r--test/integration/targets/pull/pull-integration-test/inventory2
-rw-r--r--test/integration/targets/pull/pull-integration-test/local.yml20
-rwxr-xr-xtest/integration/targets/pull/runme.sh69
-rw-r--r--test/integration/targets/pull/setup.yml11
7 files changed, 122 insertions, 0 deletions
diff --git a/test/integration/targets/pull/aliases b/test/integration/targets/pull/aliases
new file mode 100644
index 00000000..757c9966
--- /dev/null
+++ b/test/integration/targets/pull/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group3
+skip/aix
diff --git a/test/integration/targets/pull/cleanup.yml b/test/integration/targets/pull/cleanup.yml
new file mode 100644
index 00000000..68686964
--- /dev/null
+++ b/test/integration/targets/pull/cleanup.yml
@@ -0,0 +1,16 @@
+- hosts: localhost
+ vars:
+ git_install: '{{ lookup("file", lookup("env", "OUTPUT_DIR") + "/git_install.json") | from_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/pull/pull-integration-test/ansible.cfg b/test/integration/targets/pull/pull-integration-test/ansible.cfg
new file mode 100644
index 00000000..f8fc6cdb
--- /dev/null
+++ b/test/integration/targets/pull/pull-integration-test/ansible.cfg
@@ -0,0 +1,2 @@
+[defaults]
+inventory = inventory
diff --git a/test/integration/targets/pull/pull-integration-test/inventory b/test/integration/targets/pull/pull-integration-test/inventory
new file mode 100644
index 00000000..72644cef
--- /dev/null
+++ b/test/integration/targets/pull/pull-integration-test/inventory
@@ -0,0 +1,2 @@
+testhost1.example.com
+localhost
diff --git a/test/integration/targets/pull/pull-integration-test/local.yml b/test/integration/targets/pull/pull-integration-test/local.yml
new file mode 100644
index 00000000..d358ee86
--- /dev/null
+++ b/test/integration/targets/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/pull/runme.sh b/test/integration/targets/pull/runme.sh
new file mode 100755
index 00000000..dcadc495
--- /dev/null
+++ b/test/integration/targets/pull/runme.sh
@@ -0,0 +1,69 @@
+#!/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
+}
+
+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
diff --git a/test/integration/targets/pull/setup.yml b/test/integration/targets/pull/setup.yml
new file mode 100644
index 00000000..a82d02ae
--- /dev/null
+++ b/test/integration/targets/pull/setup.yml
@@ -0,0 +1,11 @@
+- hosts: localhost
+ tasks:
+ - name: install git
+ package:
+ name: git
+ when: ansible_distribution != "MacOSX"
+ register: git_install
+ - name: save install result
+ copy:
+ content: '{{ git_install }}'
+ dest: '{{ lookup("env", "OUTPUT_DIR") }}/git_install.json'