diff options
author | Matt Clay <matt@mystile.com> | 2016-10-12 14:57:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-12 14:57:53 -0700 |
commit | 80a5c70ad795f3cd1e6e3edde7077a8dfd65470b (patch) | |
tree | 50ab0ad670d2631fa32cad47019d9a970ed81596 /test/integration/targets/hash | |
parent | bf3d546d9a48cf5391a91002733d4a6ea62b1a0c (diff) | |
download | ansible-80a5c70ad795f3cd1e6e3edde7077a8dfd65470b.tar.gz |
Split integration tests out from Makefile. (#17976)
Diffstat (limited to 'test/integration/targets/hash')
7 files changed, 133 insertions, 0 deletions
diff --git a/test/integration/targets/hash/roles/test_hash_behavior/defaults/main.yml b/test/integration/targets/hash/roles/test_hash_behavior/defaults/main.yml new file mode 100644 index 0000000000..10cc09f31c --- /dev/null +++ b/test/integration/targets/hash/roles/test_hash_behavior/defaults/main.yml @@ -0,0 +1,21 @@ +# test code for the hash variable behavior +# (c) 2014, James Cammarata <jcammarata@ansible.com> + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +--- +test_hash: + default_vars: "this is in role defaults/main.yml" diff --git a/test/integration/targets/hash/roles/test_hash_behavior/meta/main.yml b/test/integration/targets/hash/roles/test_hash_behavior/meta/main.yml new file mode 100644 index 0000000000..c3dcf7aaf9 --- /dev/null +++ b/test/integration/targets/hash/roles/test_hash_behavior/meta/main.yml @@ -0,0 +1,18 @@ +# test code for the hash variable behavior +# (c) 2014, James Cammarata <jcammarata@ansible.com> + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + diff --git a/test/integration/targets/hash/roles/test_hash_behavior/tasks/main.yml b/test/integration/targets/hash/roles/test_hash_behavior/tasks/main.yml new file mode 100644 index 0000000000..463141edd3 --- /dev/null +++ b/test/integration/targets/hash/roles/test_hash_behavior/tasks/main.yml @@ -0,0 +1,42 @@ +# test code for the hash variable behavior +# (c) 2014, James Cammarata <jcammarata@ansible.com> + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +- name: get the hash behavior env setting + shell: env | grep ^ANSIBLE_HASH_BEHAVIOUR'=' | cut -f2- -d'=' + register: hash_behavior + # This only works with the local connection. The way this test is run means the + connection: local + delegate_to: localhost + + +- name: debug hash behavior result + debug: var=hash_behavior.stdout + +- name: assert hash behavior is merge or replace + assert: + that: + - "hash_behavior.stdout in ('merge', 'replace')" + +- name: debug test_hash var + debug: var=test_hash + +- name: assert the dictionary values match + assert: + that: + - "hash_behavior.stdout == 'merge' and test_hash == merged_hash or hash_behavior.stdout == 'replace' and test_hash == replaced_hash" + diff --git a/test/integration/targets/hash/roles/test_hash_behavior/vars/main.yml b/test/integration/targets/hash/roles/test_hash_behavior/vars/main.yml new file mode 100644 index 0000000000..2068e9fbaf --- /dev/null +++ b/test/integration/targets/hash/roles/test_hash_behavior/vars/main.yml @@ -0,0 +1,21 @@ +# test code for the hash variable behavior +# (c) 2014, James Cammarata <jcammarata@ansible.com> + +# This file is part of Ansible +# +# Ansible is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Ansible is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Ansible. If not, see <http://www.gnu.org/licenses/>. + +--- +test_hash: + role_vars: "this is in role vars/main.yml" diff --git a/test/integration/targets/hash/runme.sh b/test/integration/targets/hash/runme.sh new file mode 100755 index 0000000000..9448e4e098 --- /dev/null +++ b/test/integration/targets/hash/runme.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +set -eux + +JSON_ARG='{"test_hash":{"extra_args":"this is an extra arg"}}' + +ANSIBLE_HASH_BEHAVIOUR=replace ansible-playbook test_hash.yml -i ../../inventory -v "$@" -e "${JSON_ARG}" +ANSIBLE_HASH_BEHAVIOUR=merge ansible-playbook test_hash.yml -i ../../inventory -v "$@" -e "${JSON_ARG}" diff --git a/test/integration/targets/hash/test_hash.yml b/test/integration/targets/hash/test_hash.yml new file mode 100644 index 0000000000..271563355b --- /dev/null +++ b/test/integration/targets/hash/test_hash.yml @@ -0,0 +1,20 @@ +--- +- hosts: testhost + vars_files: + - vars/test_hash_vars.yml + vars: + test_hash: + playbook_vars: "this is a playbook variable" + replaced_hash: + extra_args: "this is an extra arg" + merged_hash: + default_vars: "this is in role defaults/main.yml" + extra_args: "this is an extra arg" + group_vars_all: "this is in group_vars/all" + host_vars_testhost: "this is in host_vars/testhost" + playbook_vars: "this is a playbook variable" + role_argument: "this is a role argument variable" + role_vars: "this is in role vars/main.yml" + vars_file: "this is in a vars_file" + roles: + - { role: test_hash_behavior, test_hash: {'role_argument':'this is a role argument variable'} } diff --git a/test/integration/targets/hash/vars/test_hash_vars.yml b/test/integration/targets/hash/vars/test_hash_vars.yml new file mode 100644 index 0000000000..e25f8576c3 --- /dev/null +++ b/test/integration/targets/hash/vars/test_hash_vars.yml @@ -0,0 +1,3 @@ +--- +test_hash: + vars_file: "this is in a vars_file" |