mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Split integration tests out from Makefile. (#17976)
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
# test code for the always_run option
|
||||
# (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/>.
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
# test code for the always_run option
|
||||
# (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: run a command while in check mode
|
||||
shell: echo "running"
|
||||
check_mode: no
|
||||
register: result
|
||||
|
||||
- name: assert that the command was run
|
||||
assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- "result.stdout == 'running'"
|
||||
- "result.rc == 0"
|
||||
@@ -1,2 +0,0 @@
|
||||
dependencies:
|
||||
- { role: prepare_tests }
|
||||
@@ -1,56 +0,0 @@
|
||||
# test code for the ping module
|
||||
# (c) 2014, Michael DeHaan <michael@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/>.
|
||||
|
||||
# the following tests all raise errors, to use them in a Makefile, we run them with different flags, as
|
||||
# otherwise ansible stops at the first one and we want to ensure STOP conditions for each
|
||||
|
||||
- set_fact:
|
||||
test_file: "{{ output_dir }}/ansible_test_file" # FIXME, use set tempdir
|
||||
test_input: "owner=test"
|
||||
bad_var: "{{ output_dir }}' owner=test"
|
||||
chdir: "mom chdir=/tmp"
|
||||
tags: common
|
||||
|
||||
- file: name={{test_file}} state=touch
|
||||
tags: common
|
||||
|
||||
- name: include test that we cannot insert arguments
|
||||
include: scenario1.yml
|
||||
tags: scenario1
|
||||
|
||||
- name: include test that we cannot duplicate arguments
|
||||
include: scenario2.yml
|
||||
tags: scenario2
|
||||
|
||||
- name: include test that we can't do this for the shell module
|
||||
include: scenario3.yml
|
||||
tags: scenario3
|
||||
|
||||
- name: include test that we can't go all Little Bobby Droptables on a quoted var to add more
|
||||
include: scenario4.yml
|
||||
tags: scenario4
|
||||
|
||||
- name: test that a missing/malformed jinja2 filter fails
|
||||
debug: msg="{{output_dir|badfiltername}}"
|
||||
tags: scenario5
|
||||
register: filter_fail
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- filter_fail|failed
|
||||
@@ -1,5 +0,0 @@
|
||||
- name: test that we cannot insert arguments
|
||||
file: path={{ test_file }} {{ test_input }}
|
||||
failed_when: False # ignore the module, just test the parser
|
||||
tags: scenario1
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
- name: test that we cannot duplicate arguments
|
||||
file: path={{ test_file }} owner=test2 {{ test_input }}
|
||||
failed_when: False # ignore the module, just test the parser
|
||||
tags: scenario2
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
- name: test that we can't do this for the shell module
|
||||
shell: echo hi {{ chdir }}
|
||||
failed_when: False
|
||||
tags: scenario3
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
- name: test that we can't go all Little Bobby Droptables on a quoted var to add more
|
||||
file: "name={{ bad_var }}"
|
||||
failed_when: False
|
||||
tags: scenario4
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
- debug: var=ansible_system
|
||||
|
||||
- name: ping
|
||||
ping:
|
||||
when: ansible_system != 'Win32NT'
|
||||
|
||||
- name: win_ping
|
||||
win_ping:
|
||||
when: ansible_system == 'Win32NT'
|
||||
|
||||
- name: Hello, World!
|
||||
action: "helloworld_{{ ansible_system|lower }}"
|
||||
register: hello_world
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'hello_world.msg == "Hello, World!"'
|
||||
|
||||
- name: Hello, Ansible!
|
||||
action: "helloworld_{{ ansible_system|lower }}"
|
||||
args:
|
||||
name: Ansible
|
||||
register: hello_ansible
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'hello_ansible.msg == "Hello, Ansible!"'
|
||||
|
||||
- name: Async Hello, World!
|
||||
action: "helloworld_{{ ansible_system|lower }}"
|
||||
async: 10
|
||||
poll: 1
|
||||
when: ansible_system != 'Win32NT'
|
||||
register: async_hello_world
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'async_hello_world.msg == "Hello, World!"'
|
||||
when: not async_hello_world|skipped
|
||||
|
||||
- name: Async Hello, Ansible!
|
||||
action: "helloworld_{{ ansible_system|lower }}"
|
||||
args:
|
||||
name: Ansible
|
||||
async: 10
|
||||
poll: 1
|
||||
when: ansible_system != 'Win32NT'
|
||||
register: async_hello_ansible
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'async_hello_ansible.msg == "Hello, Ansible!"'
|
||||
when: not async_hello_ansible|skipped
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
templated_var_loaded
|
||||
@@ -1,3 +0,0 @@
|
||||
dependencies:
|
||||
- prepare_tests
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
# test code for the template module
|
||||
# (c) 2014, Michael DeHaan <michael.dehaan@gmail.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: fill in a basic template in check mode
|
||||
template: src=foo.j2 dest={{output_dir}}/checkmode_foo.templated mode=0644
|
||||
register: template_result
|
||||
|
||||
- name: check whether file exists
|
||||
stat: path={{output_dir}}/checkmode_foo.templated
|
||||
register: foo
|
||||
|
||||
- name: verify that the file was marked as changed in check mode
|
||||
assert:
|
||||
that:
|
||||
- "template_result|changed"
|
||||
- "not foo.stat.exists"
|
||||
|
||||
- name: Actually create the file, disable check mode
|
||||
template: src=foo.j2 dest={{output_dir}}/checkmode_foo.templated2 mode=0644
|
||||
check_mode: no
|
||||
register: checkmode_disabled
|
||||
|
||||
- name: fill in template with new content
|
||||
template: src=foo.j2 dest={{output_dir}}/checkmode_foo.templated2 mode=0644
|
||||
register: template_result2
|
||||
|
||||
- name: verify that the file was not changed
|
||||
assert:
|
||||
that:
|
||||
- "checkmode_disabled|changed"
|
||||
- "not template_result2|changed"
|
||||
@@ -1 +0,0 @@
|
||||
{{ templated_var }}
|
||||
@@ -1 +0,0 @@
|
||||
templated_var: templated_var_loaded
|
||||
@@ -1,2 +0,0 @@
|
||||
- name: echoing handler
|
||||
command: echo CALLED_HANDLER_{{ inventory_hostname }}
|
||||
@@ -1,26 +0,0 @@
|
||||
---
|
||||
|
||||
# We notify for A and B, and hosts B and C fail.
|
||||
# When forcing, we expect A and B to run handlers
|
||||
# When not forcing, we expect only B to run handlers
|
||||
|
||||
- name: notify the handler for host A and B
|
||||
shell: echo
|
||||
notify:
|
||||
- echoing handler
|
||||
when: inventory_hostname == 'A' or inventory_hostname == 'B'
|
||||
|
||||
- name: EXPECTED FAILURE fail task for all
|
||||
fail: msg="Fail All"
|
||||
when: fail_all is defined and fail_all
|
||||
|
||||
- name: EXPECTED FAILURE fail task for A
|
||||
fail: msg="Fail A"
|
||||
when: inventory_hostname == 'A'
|
||||
|
||||
- name: EXPECTED FAILURE fail task for C
|
||||
fail: msg="Fail C"
|
||||
when: inventory_hostname == 'C'
|
||||
|
||||
- name: echo after A and C have failed
|
||||
command: echo CALLED_TASK_{{ inventory_hostname }}
|
||||
@@ -1,204 +0,0 @@
|
||||
# test code for the ping module
|
||||
# (c) 2014, Michael DeHaan <michael@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/>.
|
||||
|
||||
# various tests of things that should not cause parsing problems
|
||||
|
||||
- set_fact:
|
||||
test_input: "a=1 a=2 a=3"
|
||||
|
||||
- set_fact:
|
||||
multi_line: |
|
||||
echo old
|
||||
echo mcdonald
|
||||
echo had
|
||||
echo a
|
||||
echo farm
|
||||
|
||||
- shell: echo "dog"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
result.cmd == 'echo "dog"'
|
||||
|
||||
- shell: echo 'dog'
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
result.cmd == 'echo \'dog\''
|
||||
|
||||
- name: a quoted argument is not sent to the shell module as anything but a string parameter
|
||||
shell: echo 'dog' 'executable=/usr/bin/python'
|
||||
register: result
|
||||
|
||||
- debug: var=result.cmd
|
||||
|
||||
- assert:
|
||||
that:
|
||||
result.cmd == "echo 'dog' 'executable=/usr/bin/python'"
|
||||
|
||||
- name: it is valid to pass multiple key=value arguments because the shell doesn't check key=value arguments
|
||||
shell: echo quackquack=here quackquack=everywhere
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
result.cmd == 'echo quackquack=here quackquack=everywhere'
|
||||
|
||||
- name: the same is true with quoting
|
||||
shell: echo "quackquack=here quackquack=everywhere"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
result.cmd == 'echo "quackquack=here quackquack=everywhere"'
|
||||
|
||||
- name: the same is true with quoting (B)
|
||||
shell: echo "quackquack=here" "quackquack=everywhere"
|
||||
register: result
|
||||
|
||||
- name: the same is true with quoting (C)
|
||||
shell: echo "quackquack=here" 'quackquack=everywhere'
|
||||
register: result
|
||||
|
||||
- name: the same is true with quoting (D)
|
||||
shell: echo "quackquack=here" 'quackquack=everywhere'
|
||||
register: result
|
||||
|
||||
- name: the same is true with quoting (E)
|
||||
shell: echo {{ test_input }}
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
result.cmd == "echo a=1 a=2 a=3"
|
||||
|
||||
- name: more shell duplicates
|
||||
shell: echo foo=bar foo=bar
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
result.cmd == "echo foo=bar foo=bar"
|
||||
|
||||
- name: raw duplicates, noop
|
||||
raw: env true foo=bar foo=bar
|
||||
|
||||
- name: multi-line inline shell commands (should use script module but hey) are a thing
|
||||
shell: "{{ multi_line }}"
|
||||
register: result
|
||||
|
||||
- debug: var=result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
result.stdout_lines == [ 'old', 'mcdonald', 'had', 'a', 'farm' ]
|
||||
|
||||
- name: passing same arg to shell command is legit
|
||||
shell: echo foo --arg=a --arg=b
|
||||
failed_when: False # just catch the exit code, parse error is what I care about, but should register and compare result
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
# command shouldn't end in spaces, amend test once fixed
|
||||
- result.cmd == "echo foo --arg=a --arg=b"
|
||||
|
||||
- name: test includes with params
|
||||
include: test_include.yml fact_name=include_params param="{{ test_input }}"
|
||||
|
||||
- name: assert the include set the correct fact for the param
|
||||
assert:
|
||||
that:
|
||||
- include_params == test_input
|
||||
|
||||
- name: test includes with quoted params
|
||||
include: test_include.yml fact_name=double_quoted_param param="this is a param with double quotes"
|
||||
|
||||
- name: assert the include set the correct fact for the double quoted param
|
||||
assert:
|
||||
that:
|
||||
- double_quoted_param == "this is a param with double quotes"
|
||||
|
||||
- name: test includes with single quoted params
|
||||
include: test_include.yml fact_name=single_quoted_param param='this is a param with single quotes'
|
||||
|
||||
- name: assert the include set the correct fact for the single quoted param
|
||||
assert:
|
||||
that:
|
||||
- single_quoted_param == "this is a param with single quotes"
|
||||
|
||||
- name: test includes with quoted params in complex args
|
||||
include: test_include.yml
|
||||
vars:
|
||||
fact_name: complex_param
|
||||
param: "this is a param in a complex arg with double quotes"
|
||||
|
||||
- name: assert the include set the correct fact for the params in complex args
|
||||
assert:
|
||||
that:
|
||||
- complex_param == "this is a param in a complex arg with double quotes"
|
||||
|
||||
- name: test variable module name
|
||||
action: "{{ variable_module_name }} msg='this should be debugged'"
|
||||
register: result
|
||||
|
||||
- name: assert the task with variable module name ran
|
||||
assert:
|
||||
that:
|
||||
- result.msg == "this should be debugged"
|
||||
|
||||
- name: test conditional includes
|
||||
include: test_include_conditional.yml
|
||||
when: false
|
||||
|
||||
- name: assert the nested include from test_include_conditional was not set
|
||||
assert:
|
||||
that:
|
||||
- nested_include_var is undefined
|
||||
|
||||
- name: test omit in complex args
|
||||
set_fact:
|
||||
foo: bar
|
||||
spam: "{{ omit }}"
|
||||
should_not_omit: "prefix{{ omit }}"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- foo == 'bar'
|
||||
- spam is undefined
|
||||
- should_not_omit is defined
|
||||
|
||||
- name: test omit in module args
|
||||
set_fact: >
|
||||
yo=whatsup
|
||||
eggs="{{ omit }}"
|
||||
default_omitted="{{ not_exists|default(omit) }}"
|
||||
should_not_omit_1="prefix{{ omit }}"
|
||||
should_not_omit_2="{{ omit }}suffix"
|
||||
should_not_omit_3="__omit_place_holder__afb6b9bc3d20bfeaa00a1b23a5930f89"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- yo == 'whatsup'
|
||||
- eggs is undefined
|
||||
- default_omitted is undefined
|
||||
- should_not_omit_1 is defined
|
||||
- should_not_omit_2 is defined
|
||||
- should_not_omit_3 == "__omit_place_holder__afb6b9bc3d20bfeaa00a1b23a5930f89"
|
||||
@@ -1 +0,0 @@
|
||||
- set_fact: "{{fact_name}}='{{param}}'"
|
||||
@@ -1 +0,0 @@
|
||||
- include: test_include_nested.yml
|
||||
@@ -1,2 +0,0 @@
|
||||
- name: set the nested include fact
|
||||
set_fact: nested_include_var=1
|
||||
@@ -1,2 +0,0 @@
|
||||
---
|
||||
variable_module_name: debug
|
||||
@@ -1,5 +0,0 @@
|
||||
- name: set handler fact
|
||||
set_fact:
|
||||
handler_called: True
|
||||
- name: test handler
|
||||
debug: msg="handler called"
|
||||
@@ -1,2 +0,0 @@
|
||||
dependencies: []
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
# test code for the async keyword
|
||||
# (c) 2014, James Tanner <tanner.jc@gmail.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: reset handler_called variable to false for all hosts
|
||||
set_fact:
|
||||
handler_called: False
|
||||
tags: scenario1
|
||||
|
||||
- name: notify the handler for host A only
|
||||
shell: echo
|
||||
notify:
|
||||
- set handler fact
|
||||
when: inventory_hostname == 'A'
|
||||
tags: scenario1
|
||||
|
||||
- name: force handler execution now
|
||||
meta: "flush_handlers"
|
||||
tags: scenario1
|
||||
|
||||
- debug: var=handler_called
|
||||
tags: scenario1
|
||||
|
||||
- name: validate the handler only ran on one host
|
||||
assert:
|
||||
that:
|
||||
- "inventory_hostname == 'A' and handler_called == True or handler_called == False"
|
||||
tags: scenario1
|
||||
|
||||
- name: 'test notify with loop'
|
||||
debug: msg='a task'
|
||||
changed_when: item == 1
|
||||
notify: test handler
|
||||
with_items:
|
||||
- 1
|
||||
- 2
|
||||
tags: scenario2
|
||||
@@ -1,7 +0,0 @@
|
||||
- name: set_handler_fact_1
|
||||
set_fact:
|
||||
handler1_called: True
|
||||
|
||||
- name: set_handler_fact_2
|
||||
set_fact:
|
||||
handler2_called: True
|
||||
@@ -1,3 +0,0 @@
|
||||
dependencies:
|
||||
- prepare_tests
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
# test code for the async keyword
|
||||
# (c) 2014, James Tanner <tanner.jc@gmail.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: notify the first handler
|
||||
shell: echo
|
||||
notify:
|
||||
- set_handler_fact_1
|
||||
|
||||
- name: force handler execution now
|
||||
meta: "flush_handlers"
|
||||
|
||||
- name: assert handler1 ran and not handler2
|
||||
assert:
|
||||
that:
|
||||
- "handler1_called is defined"
|
||||
- "handler2_called is not defined"
|
||||
|
||||
- name: reset handler1_called
|
||||
set_fact:
|
||||
handler1_called: False
|
||||
|
||||
- name: notify the second handler
|
||||
shell: echo
|
||||
notify:
|
||||
- set_handler_fact_2
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
# 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"
|
||||
@@ -1,18 +0,0 @@
|
||||
# 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/>.
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
# 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"
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
# 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"
|
||||
@@ -1,2 +0,0 @@
|
||||
- include: more_handlers.yml
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
- name: included_handler
|
||||
set_fact:
|
||||
ca: 4001
|
||||
cb: 4002
|
||||
cc: 4003
|
||||
|
||||
- name: verify_handler
|
||||
assert:
|
||||
that:
|
||||
- "ca == 4001"
|
||||
- "cb == 4002"
|
||||
- "cc == 4003"
|
||||
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
- set_fact:
|
||||
ca: "{{ a }}"
|
||||
- debug: var=ca
|
||||
- set_fact:
|
||||
cb: "{{b}}"
|
||||
- debug: var=cb
|
||||
- set_fact:
|
||||
cc: "{{ c }}"
|
||||
- debug: var=cc
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
# test code for the ping module
|
||||
# (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/>.
|
||||
|
||||
|
||||
- include: included_task1.yml a=1 b=2 c=3
|
||||
|
||||
- name: verify non-variable include params
|
||||
assert:
|
||||
that:
|
||||
- "ca == '1'"
|
||||
- "cb == '2'"
|
||||
- "cc == '3'"
|
||||
|
||||
- set_fact:
|
||||
a: 101
|
||||
b: 102
|
||||
c: 103
|
||||
|
||||
- include: included_task1.yml a={{a}} b={{b}} c=103
|
||||
|
||||
- name: verify variable include params
|
||||
assert:
|
||||
that:
|
||||
- "ca == 101"
|
||||
- "cb == 102"
|
||||
- "cc == 103"
|
||||
|
||||
# Test that strings are not turned into numbers
|
||||
- set_fact:
|
||||
a: "101"
|
||||
b: "102"
|
||||
c: "103"
|
||||
|
||||
- include: included_task1.yml a={{a}} b={{b}} c=103
|
||||
|
||||
- name: verify variable include params
|
||||
assert:
|
||||
that:
|
||||
- "ca == '101'"
|
||||
- "cb == '102'"
|
||||
- "cc == '103'"
|
||||
|
||||
# now try long form includes
|
||||
|
||||
- include: included_task1.yml
|
||||
vars:
|
||||
a: 201
|
||||
b: 202
|
||||
c: 203
|
||||
|
||||
- debug: var=a
|
||||
- debug: var=b
|
||||
- debug: var=c
|
||||
|
||||
- name: verify long-form include params
|
||||
assert:
|
||||
that:
|
||||
- "ca == 201"
|
||||
- "cb == 202"
|
||||
- "cc == 203"
|
||||
|
||||
- name: test handlers with includes
|
||||
shell: echo 1
|
||||
notify:
|
||||
# both these via a handler include
|
||||
- included_handler
|
||||
- verify_handler
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
- set_fact:
|
||||
ca: 33000
|
||||
cb: 33001
|
||||
cc: 33002
|
||||
@@ -1,4 +0,0 @@
|
||||
dependencies:
|
||||
- { role: test_var_precedence_role1, param_var: "param_var_role1" }
|
||||
- { role: test_var_precedence_role2, param_var: "param_var_role2" }
|
||||
- { role: test_var_precedence_role3, param_var: "param_var_role3" }
|
||||
@@ -1,10 +0,0 @@
|
||||
- debug: var=extra_var
|
||||
- debug: var=vars_var
|
||||
- debug: var=vars_files_var
|
||||
- debug: var=vars_files_var_role
|
||||
- assert:
|
||||
that:
|
||||
- 'extra_var == "extra_var"'
|
||||
- 'vars_var == "vars_var"'
|
||||
- 'vars_files_var == "vars_files_var"'
|
||||
- 'vars_files_var_role == "vars_files_var_role3"'
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
# should be overridden by vars_files in the main play
|
||||
vars_files_var: "BAD!"
|
||||
# should be seen in role1 (no override)
|
||||
defaults_file_var_role1: "defaults_file_var_role1"
|
||||
@@ -1,14 +0,0 @@
|
||||
- debug: var=extra_var
|
||||
- debug: var=param_var
|
||||
- debug: var=vars_var
|
||||
- debug: var=vars_files_var
|
||||
- debug: var=vars_files_var_role
|
||||
- debug: var=defaults_file_var_role1
|
||||
- assert:
|
||||
that:
|
||||
- 'extra_var == "extra_var"'
|
||||
- 'param_var == "param_var_role1"'
|
||||
- 'vars_var == "vars_var"'
|
||||
- 'vars_files_var == "vars_files_var"'
|
||||
- 'vars_files_var_role == "vars_files_var_dep"'
|
||||
- 'defaults_file_var_role1 == "defaults_file_var_role1"'
|
||||
@@ -1,4 +0,0 @@
|
||||
---
|
||||
# should override the global vars_files_var since it's local to the role
|
||||
# but will be set to the value in the last role included which defines it
|
||||
vars_files_var_role: "vars_files_var_dep"
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
- debug: var=foo
|
||||
- assert:
|
||||
that:
|
||||
- 'foo == "bar"'
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
# should be overridden by vars_files in the main play
|
||||
vars_files_var: "BAD!"
|
||||
# should be seen in role1 (no override)
|
||||
defaults_file_var_role1: "defaults_file_var_role1"
|
||||
@@ -1,2 +0,0 @@
|
||||
dependencies:
|
||||
- test_var_precedence_dep
|
||||
@@ -1,14 +0,0 @@
|
||||
- debug: var=extra_var
|
||||
- debug: var=param_var
|
||||
- debug: var=vars_var
|
||||
- debug: var=vars_files_var
|
||||
- debug: var=vars_files_var_role
|
||||
- debug: var=defaults_file_var_role1
|
||||
- assert:
|
||||
that:
|
||||
- 'extra_var == "extra_var"'
|
||||
- 'param_var == "param_var_role1"'
|
||||
- 'vars_var == "vars_var"'
|
||||
- 'vars_files_var == "vars_files_var"'
|
||||
- 'vars_files_var_role == "vars_files_var_role1"'
|
||||
- 'defaults_file_var_role1 == "defaults_file_var_role1"'
|
||||
@@ -1,4 +0,0 @@
|
||||
---
|
||||
# should override the global vars_files_var since it's local to the role
|
||||
# but will be set to the value in the last role included which defines it
|
||||
vars_files_var_role: "vars_files_var_role1"
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
# should be overridden by vars_files in the main play
|
||||
vars_files_var: "BAD!"
|
||||
# should be overridden by the vars file in role2
|
||||
defaults_file_var_role2: "BAD!"
|
||||
@@ -1,14 +0,0 @@
|
||||
- debug: var=extra_var
|
||||
- debug: var=param_var
|
||||
- debug: var=vars_var
|
||||
- debug: var=vars_files_var
|
||||
- debug: var=vars_files_var_role
|
||||
- debug: var=defaults_file_var_role1
|
||||
- assert:
|
||||
that:
|
||||
- 'extra_var == "extra_var"'
|
||||
- 'param_var == "param_var_role2"'
|
||||
- 'vars_var == "vars_var"'
|
||||
- 'vars_files_var == "vars_files_var"'
|
||||
- 'vars_files_var_role == "vars_files_var_role2"'
|
||||
- 'defaults_file_var_role2 == "overridden by role vars"'
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
# should override the global vars_files_var since it's local to the role
|
||||
vars_files_var_role: "vars_files_var_role2"
|
||||
# should override the value in defaults/main.yml for role 2
|
||||
defaults_file_var_role2: "overridden by role vars"
|
||||
@@ -1,7 +0,0 @@
|
||||
---
|
||||
# should be overridden by vars_files in the main play
|
||||
vars_files_var: "BAD!"
|
||||
# should override the defaults var for role 1 and 2
|
||||
defaults_file_var: "last one wins"
|
||||
# should be overridden from the inventory value
|
||||
defaults_file_var_role3: "BAD!"
|
||||
@@ -1,14 +0,0 @@
|
||||
- debug: var=extra_var
|
||||
- debug: var=param_var
|
||||
- debug: var=vars_var
|
||||
- debug: var=vars_files_var
|
||||
- debug: var=vars_files_var_role
|
||||
- debug: var=defaults_file_var_role1
|
||||
- assert:
|
||||
that:
|
||||
- 'extra_var == "extra_var"'
|
||||
- 'param_var == "param_var_role3"'
|
||||
- 'vars_var == "vars_var"'
|
||||
- 'vars_files_var == "vars_files_var"'
|
||||
- 'vars_files_var_role == "vars_files_var_role3"'
|
||||
- 'defaults_file_var_role3 == "overridden from inventory"'
|
||||
@@ -1,3 +0,0 @@
|
||||
---
|
||||
# should override the global vars_files_var since it's local to the role
|
||||
vars_files_var_role: "vars_files_var_role3"
|
||||
@@ -1,7 +0,0 @@
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'secret_var == "secret"'
|
||||
|
||||
|
||||
- copy: src=vault-secret.txt dest={{output_dir}}/secret.txt
|
||||
@@ -1,9 +0,0 @@
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
31626536666232643662346539623662393436386162643439643434656231343435653936343235
|
||||
6139346364396166336636383734333430373763336434310a303137623539653939336132626234
|
||||
64613232396532313731313935333433353330666466646663303233323331636234326464643166
|
||||
6538653264636166370a613161313064653566323037393962643032353230396536313865326362
|
||||
34396262303130326632623162623230346238633932393938393766313036643835613936356233
|
||||
33323730373331386337353339613165373064323134343930333031623036326164353534646631
|
||||
31313963666234623731316238656233396638643331306231373539643039383434373035306233
|
||||
30386230363730643561
|
||||
@@ -1,14 +0,0 @@
|
||||
---
|
||||
- name: Assert that a embedded vault of a string with no newline works
|
||||
assert:
|
||||
that:
|
||||
- '"{{ vault_encrypted_one_line_var }}" == "Setec Astronomy"'
|
||||
|
||||
- name: Assert that a multi line embedded vault works, including new line
|
||||
assert:
|
||||
that:
|
||||
- vault_encrypted_var == "Setec Astronomy\n"
|
||||
|
||||
# TODO: add a expected fail here
|
||||
# - debug: var=vault_encrypted_one_line_var_with_embedded_template
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
# If you use normal 'ansible-vault create' or edit, files always have at least one new line
|
||||
# so c&p from a vault encrypted that wasn't specifically created sans new line ends up with one.
|
||||
# (specifically created, as in 'echo -n "just one line" > my_secret.yml'
|
||||
vault_encrypted_var: !vault-encrypted |
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
66386439653236336462626566653063336164663966303231363934653561363964363833313662
|
||||
6431626536303530376336343832656537303632313433360a626438346336353331386135323734
|
||||
62656361653630373231613662633962316233633936396165386439616533353965373339616234
|
||||
3430613539666330390a313736323265656432366236633330313963326365653937323833366536
|
||||
34623731376664623134383463316265643436343438623266623965636363326136
|
||||
vault_encrypted_one_line_var: !vault-encrypted |
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
33363965326261303234626463623963633531343539616138316433353830356566396130353436
|
||||
3562643163366231316662386565383735653432386435610a306664636137376132643732393835
|
||||
63383038383730306639353234326630666539346233376330303938323639306661313032396437
|
||||
6233623062366136310a633866373936313238333730653739323461656662303864663666653563
|
||||
3138
|
||||
Reference in New Issue
Block a user