2014-02-20 21:23:51 +01:00
|
|
|
# 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
|
2016-04-05 20:06:17 +02:00
|
|
|
shell: env | grep ^ANSIBLE_HASH_BEHAVIOUR'=' | cut -f2- -d'='
|
2014-02-20 21:23:51 +01:00
|
|
|
register: hash_behavior
|
2016-04-05 20:06:17 +02:00
|
|
|
# This only works with the local connection. The way this test is run means the
|
|
|
|
connection: local
|
|
|
|
delegate_to: localhost
|
|
|
|
|
2014-02-20 21:23:51 +01:00
|
|
|
|
|
|
|
- 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"
|
|
|
|
|