diff --git a/test/integration/targets/blocks/main.yml b/test/integration/targets/blocks/main.yml index ea61d058694..012d5ab2703 100644 --- a/test/integration/targets/blocks/main.yml +++ b/test/integration/targets/blocks/main.yml @@ -84,7 +84,7 @@ - debug: msg="TEST COMPLETE" - name: block with includes - hosts: localhost + hosts: testhost gather_facts: yes strategy: "{{test_strategy|default('linear')}}" vars: diff --git a/test/integration/targets/check_mode/check_mode-not-on-cli.yml b/test/integration/targets/check_mode/check_mode-not-on-cli.yml index 0c7af038e19..1b0c734b98b 100644 --- a/test/integration/targets/check_mode/check_mode-not-on-cli.yml +++ b/test/integration/targets/check_mode/check_mode-not-on-cli.yml @@ -1,6 +1,6 @@ --- # Run withhout --check -- hosts: localhost +- hosts: testhost gather_facts: False tasks: - command: 'echo ran' @@ -12,7 +12,7 @@ that: - '"ran" in command_out["stdout"]' -- hosts: localhost +- hosts: testhost gather_facts: False check_mode: True tasks: @@ -24,7 +24,7 @@ that: - '"check mode" in command_out["msg"]' -- hosts: localhost +- hosts: testhost gather_facts: False tasks: - command: 'echo ran' diff --git a/test/integration/targets/check_mode/check_mode-on-cli.yml b/test/integration/targets/check_mode/check_mode-on-cli.yml index 8091198bb7a..0af34b83c04 100644 --- a/test/integration/targets/check_mode/check_mode-on-cli.yml +++ b/test/integration/targets/check_mode/check_mode-on-cli.yml @@ -1,6 +1,6 @@ --- # Run with --check -- hosts: localhost +- hosts: testhost gather_facts: False tasks: - command: 'echo ran' @@ -11,7 +11,7 @@ that: - '"check mode" in command_out["msg"]' -- hosts: localhost +- hosts: testhost gather_facts: False check_mode: False tasks: @@ -23,7 +23,7 @@ that: - '"ran" in command_out["stdout"]' -- hosts: localhost +- hosts: testhost gather_facts: False tasks: - command: 'echo ran' diff --git a/test/integration/targets/environment/test_environment.yml b/test/integration/targets/environment/test_environment.yml index f8e49ac8d08..43f9c74eb67 100644 --- a/test/integration/targets/environment/test_environment.yml +++ b/test/integration/targets/environment/test_environment.yml @@ -1,3 +1,10 @@ +- hosts: testhost + gather_facts: no + tasks: + - name: get PATH from target + command: echo $PATH + register: target_path + - hosts: testhost vars: - test1: @@ -9,7 +16,7 @@ - name: ensure special case with ansible_env is skipped but others still work assert: that: - - lookup('env', 'PATH') == ansible_env.PATH + - target_path.stdout == ansible_env.PATH - "'/lola' not in ansible_env.PATH" - ansible_env.lola == 'ido' diff --git a/test/integration/targets/get_url/tasks/main.yml b/test/integration/targets/get_url/tasks/main.yml index e6d6d9c6147..53789848fd9 100644 --- a/test/integration/targets/get_url/tasks/main.yml +++ b/test/integration/targets/get_url/tasks/main.yml @@ -396,8 +396,8 @@ - name: Test headers string assert: that: - - (result["content"] | b64decode | from_json).headers.get('Foo') == 'bar' - - (result["content"] | b64decode | from_json).headers.get('Baz') == 'qux' + - (result.content | b64decode | from_json).headers.get('Foo') == 'bar' + - (result.content | b64decode | from_json).headers.get('Baz') == 'qux' - name: Test headers string invalid format get_url: @@ -425,8 +425,8 @@ - name: Test headers dict assert: that: - - (result["content"] | b64decode | from_json).headers.get('Foo') == 'bar' - - (result["content"] | b64decode | from_json).headers.get('Baz') == 'qux' + - (result.content | b64decode | from_json).headers.get('Foo') == 'bar' + - (result.content | b64decode | from_json).headers.get('Baz') == 'qux' - name: Test client cert auth, with certs get_url: @@ -444,5 +444,5 @@ - name: Assert that the ssl_client_verify file contains the correct content assert: that: - - '(result["content"] | b64decode) == "ansible.http.tests:SUCCESS"' + - '(result.content | b64decode) == "ansible.http.tests:SUCCESS"' when: has_httptester diff --git a/test/integration/targets/git/tasks/depth.yml b/test/integration/targets/git/tasks/depth.yml index 37b6ecdfefc..547f84f7b55 100644 --- a/test/integration/targets/git/tasks/depth.yml +++ b/test/integration/targets/git/tasks/depth.yml @@ -169,7 +169,7 @@ - name: DEPTH | check update arrived assert: that: - - "{{ a_file['content'] | b64decode | trim }} == 3" + - "{{ a_file.content | b64decode | trim }} == 3" - git_fetch is changed - name: DEPTH | clear checkout_dir diff --git a/test/integration/targets/git/tasks/localmods.yml b/test/integration/targets/git/tasks/localmods.yml index 083ec3f2afc..09a1326d58c 100644 --- a/test/integration/targets/git/tasks/localmods.yml +++ b/test/integration/targets/git/tasks/localmods.yml @@ -47,7 +47,7 @@ - name: LOCALMODS | check update arrived assert: that: - - "{{ a_file['content'] | b64decode | trim }} == 2" + - "{{ a_file.content | b64decode | trim }} == 2" - git_fetch_force is changed - name: LOCALMODS | clear checkout_dir @@ -105,7 +105,7 @@ - name: LOCALMODS | check update arrived assert: that: - - "{{ a_file['content'] | b64decode | trim }} == 2" + - "{{ a_file.content | b64decode | trim }} == 2" - git_fetch_force is changed - name: LOCALMODS | clear checkout_dir diff --git a/test/integration/targets/hash/roles/test_hash_behaviour/tasks/main.yml b/test/integration/targets/hash/roles/test_hash_behaviour/tasks/main.yml index 03c8af7abd0..bc63549808c 100644 --- a/test/integration/targets/hash/roles/test_hash_behaviour/tasks/main.yml +++ b/test/integration/targets/hash/roles/test_hash_behaviour/tasks/main.yml @@ -18,13 +18,13 @@ - name: debug hash behaviour result debug: - var: ansible_env.ANSIBLE_HASH_BEHAVIOUR + var: "{{ lookup('env', 'ANSIBLE_HASH_BEHAVIOUR') }}" verbosity: 2 - name: assert hash behaviour is merge or replace assert: that: - - ansible_env.ANSIBLE_HASH_BEHAVIOUR in ('merge', 'replace') + - lookup('env', 'ANSIBLE_HASH_BEHAVIOUR') in ('merge', 'replace') - name: debug test_hash var debug: @@ -34,4 +34,4 @@ - name: assert the dictionary values match assert: that: - - "ansible_env.ANSIBLE_HASH_BEHAVIOUR == 'merge' and test_hash == merged_hash or ansible_env.ANSIBLE_HASH_BEHAVIOUR == 'replace' and test_hash == replaced_hash" + - "lookup('env', 'ANSIBLE_HASH_BEHAVIOUR') == 'merge' and test_hash == merged_hash or lookup('env', 'ANSIBLE_HASH_BEHAVIOUR') == 'replace' and test_hash == replaced_hash" diff --git a/test/integration/targets/ini_file/meta/main.yml b/test/integration/targets/ini_file/meta/main.yml new file mode 100644 index 00000000000..1810d4bec98 --- /dev/null +++ b/test/integration/targets/ini_file/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_remote_tmp_dir diff --git a/test/integration/targets/ini_file/tasks/main.yml b/test/integration/targets/ini_file/tasks/main.yml index 4c44d918d0f..c54b905ab2c 100644 --- a/test/integration/targets/ini_file/tasks/main.yml +++ b/test/integration/targets/ini_file/tasks/main.yml @@ -18,7 +18,7 @@ # along with Ansible. If not, see . - name: record the output directory - set_fact: output_file={{output_dir}}/foo.ini + set_fact: output_file={{ remote_tmp_dir }}/foo.ini - name: add "fav=lemonade" is in section "[drinks]" in specified file ini_file: @@ -34,13 +34,18 @@ - result1.changed == True - result1.msg == 'section and option added' +- name: read content from output file + slurp: + src: "{{ output_file }}" + register: output_content + - name: set expected content and get current ini file content set_fact: - expected1: |- + expected1: | [drinks] fav = lemonade - content1: "{{ lookup('file', output_file) }}" + content1: "{{ output_content.content | b64decode }}" - name: Verify content of ini file is as expected assert: @@ -69,14 +74,19 @@ value: coke register: result3 +- name: read content from output file + slurp: + src: "{{ output_file }}" + register: output_content + - name: set expected content and get current ini file content set_fact: - expected3: |- + expected3: | [drinks] fav = lemonade beverage = coke - content3: "{{ lookup('file', output_file) }}" + content3: "{{ output_content.content | b64decode }}" - name: assert 'changed' is true and content is OK assert: @@ -93,9 +103,14 @@ state: absent register: result4 +- name: read content from output file + slurp: + src: "{{ output_file }}" + register: output_content + - name: get ini file content set_fact: - content4: "{{ lookup('file', output_file) }}" + content4: "{{ output_content.content | b64decode }}" - name: assert changed and content is as expected assert: @@ -111,16 +126,21 @@ state: absent register: result5 +- name: read content from output file + slurp: + src: "{{ output_file }}" + register: output_content + - name: get current ini file content set_fact: - content5: "{{ lookup('file', output_file) }}" + content5: "{{ output_content.content | b64decode }}" - name: assert changed and content is empty assert: that: - result5.changed == True - result5.msg == 'section removed' - - content5 == "" + - content5 == "\n" # allow_no_value @@ -163,11 +183,16 @@ - { o: "skip-name-resolve", v: null } - { o: "max_connections", v: "500" } +- name: read content from output file + slurp: + src: "{{ output_file }}" + register: output_content + - name: set expected content and get current ini file content set_fact: - content7: "{{ lookup('file', output_file) }}" - expected7: |- - + content7: "{{ output_content.content | b64decode }}" + expected7: | + [mysqld] skip-name skip-name-resolve @@ -186,11 +211,16 @@ value: myvalue register: result8 +- name: read content from output file + slurp: + src: "{{ output_file }}" + register: output_content + - name: set expected content and get current ini file content set_fact: - content8: "{{ lookup('file', output_file) }}" - expected8: |- - + content8: "{{ output_content.content | b64decode }}" + expected8: | + [mysqld] skip-name = myvalue skip-name-resolve @@ -211,11 +241,16 @@ allow_no_value: yes register: result9 +- name: read content from output file + slurp: + src: "{{ output_file }}" + register: output_content + - name: set expected content and get current ini file content set_fact: - content9: "{{ lookup('file', output_file) }}" - expected9: |- - + content9: "{{ output_content.content | b64decode }}" + expected9: | + [mysqld] skip-name skip-name-resolve @@ -236,11 +271,16 @@ state: absent register: result10 +- name: read content from output file + slurp: + src: "{{ output_file }}" + register: output_content + - name: set expected content and get current ini file content set_fact: - content10: "{{ lookup('file', output_file) }}" - expected10: |- - + content10: "{{ output_content.content | b64decode }}" + expected10: | + [mysqld] skip-name max_connections = 500 @@ -266,10 +306,15 @@ value: coke register: result11 +- name: read content from output file + slurp: + src: "{{ output_file }}" + register: output_content + - name: set expected content and get current ini file content set_fact: - expected11: "beverage = coke" - content11: "{{ lookup('file', output_file) }}" + expected11: "beverage = coke\n\n" + content11: "{{ output_content.content | b64decode }}" - name: assert 'changed' is true and content is OK (no section) assert: @@ -286,11 +331,16 @@ section: register: result12 +- name: read content from output file + slurp: + src: "{{ output_file }}" + register: output_content + - name: set expected content and get current ini file content set_fact: - expected12: "beverage = water" + expected12: "beverage = water\n\n" - content12: "{{ lookup('file', output_file) }}" + content12: "{{ output_content.content | b64decode }}" - name: assert 'changed' is true and content is OK (no section) assert: @@ -307,16 +357,21 @@ state: absent register: result13 +- name: read content from output file + slurp: + src: "{{ output_file }}" + register: output_content + - name: get current ini file content set_fact: - content13: "{{ lookup('file', output_file) }}" + content13: "{{ output_content.content | b64decode }}" - name: assert changed (no section) assert: that: - result13 is changed - result13.msg == 'option changed' - - content13 == "" + - content13 == "\n" - name: Check add option without section before existing section block: @@ -333,14 +388,19 @@ option: like value: tea +- name: read content from output file + slurp: + src: "{{ output_file }}" + register: output_content + - name: set expected content and get current ini file content set_fact: - expected14: |- + expected14: | like = tea [drinks] beverage = water - content14: "{{ lookup('file', output_file) }}" + content14: "{{ output_content.content | b64decode }}" - name: Verify content of ini file is as expected assert: diff --git a/test/integration/targets/iterators/files/bar1 b/test/integration/targets/iterators/files/bar1 new file mode 100644 index 00000000000..5716ca5987c --- /dev/null +++ b/test/integration/targets/iterators/files/bar1 @@ -0,0 +1 @@ +bar diff --git a/test/integration/targets/iterators/files/foo1 b/test/integration/targets/iterators/files/foo1 new file mode 100644 index 00000000000..257cc5642cb --- /dev/null +++ b/test/integration/targets/iterators/files/foo1 @@ -0,0 +1 @@ +foo diff --git a/test/integration/targets/iterators/tasks/main.yml b/test/integration/targets/iterators/tasks/main.yml index 969caa95ccf..917d97357c8 100644 --- a/test/integration/targets/iterators/tasks/main.yml +++ b/test/integration/targets/iterators/tasks/main.yml @@ -201,25 +201,19 @@ # WITH_FIRST_FOUND -- name: create file for test - shell: echo "foo" > {{ output_dir }}/foo1 - -- name: create file for test - shell: echo "bar" > {{ output_dir }}/bar1 - - name: test with_first_found #shell: echo {{ item }} set_fact: "first_found={{ item }}" with_first_found: - - "{{ output_dir + '/does_not_exist' }}" - - "{{ output_dir + '/foo1' }}" - - "{{ output_dir + '/bar1' }}" + - "{{ role_path + '/files/does_not_exist' }}" + - "{{ role_path + '/files/foo1' }}" + - "{{ role_path + '/files/bar1' }}" - name: set expected - set_fact: first_expected="{{ output_dir | expanduser + '/foo1' }}" + set_fact: first_expected="{{ role_path + '/files/foo1' }}" - name: set unexpected - set_fact: first_unexpected="{{ output_dir | expanduser + '/bar1' }}" + set_fact: first_unexpected="{{ role_path + '/files/bar1' }}" - name: verify with_first_found results assert: diff --git a/test/integration/targets/module_precedence/modules_test.yml b/test/integration/targets/module_precedence/modules_test.yml index ab783fdbaa8..cf3e8886ad5 100644 --- a/test/integration/targets/module_precedence/modules_test.yml +++ b/test/integration/targets/module_precedence/modules_test.yml @@ -1,4 +1,4 @@ -- hosts: localhost +- hosts: testhost gather_facts: no tasks: - name: Use standard ping module diff --git a/test/integration/targets/module_precedence/modules_test_envvar.yml b/test/integration/targets/module_precedence/modules_test_envvar.yml index 5b6338a3753..f52e2f914fd 100644 --- a/test/integration/targets/module_precedence/modules_test_envvar.yml +++ b/test/integration/targets/module_precedence/modules_test_envvar.yml @@ -1,4 +1,4 @@ -- hosts: localhost +- hosts: testhost gather_facts: no tasks: - name: Use ping from library path diff --git a/test/integration/targets/module_precedence/modules_test_multiple_roles.yml b/test/integration/targets/module_precedence/modules_test_multiple_roles.yml index 855afb7710a..f4bd264957f 100644 --- a/test/integration/targets/module_precedence/modules_test_multiple_roles.yml +++ b/test/integration/targets/module_precedence/modules_test_multiple_roles.yml @@ -1,4 +1,4 @@ -- hosts: localhost +- hosts: testhost gather_facts: no vars: expected_location: "role: foo" diff --git a/test/integration/targets/module_precedence/modules_test_multiple_roles_reverse_order.yml b/test/integration/targets/module_precedence/modules_test_multiple_roles_reverse_order.yml index 5c57801566d..5403ae238c2 100644 --- a/test/integration/targets/module_precedence/modules_test_multiple_roles_reverse_order.yml +++ b/test/integration/targets/module_precedence/modules_test_multiple_roles_reverse_order.yml @@ -1,4 +1,4 @@ -- hosts: localhost +- hosts: testhost gather_facts: no vars: expected_location: "role: bar" diff --git a/test/integration/targets/module_precedence/modules_test_role.yml b/test/integration/targets/module_precedence/modules_test_role.yml index 9a71598875e..ccbe31d88b6 100644 --- a/test/integration/targets/module_precedence/modules_test_role.yml +++ b/test/integration/targets/module_precedence/modules_test_role.yml @@ -1,4 +1,4 @@ -- hosts: localhost +- hosts: testhost gather_facts: no roles: - foo diff --git a/test/integration/targets/module_utils/module_utils_envvar.yml b/test/integration/targets/module_utils/module_utils_envvar.yml index edd55d53b46..8d97e0eb9d3 100644 --- a/test/integration/targets/module_utils/module_utils_envvar.yml +++ b/test/integration/targets/module_utils/module_utils_envvar.yml @@ -1,4 +1,4 @@ -- hosts: localhost +- hosts: testhost gather_facts: no tasks: - name: Use a specially crafted module to see if things were imported correctly diff --git a/test/integration/targets/module_utils/module_utils_test.yml b/test/integration/targets/module_utils/module_utils_test.yml index 4359d24421e..cf0672bc30f 100644 --- a/test/integration/targets/module_utils/module_utils_test.yml +++ b/test/integration/targets/module_utils/module_utils_test.yml @@ -1,4 +1,4 @@ -- hosts: localhost +- hosts: testhost gather_facts: no tasks: - name: Use a specially crafted module to see if things were imported correctly diff --git a/test/integration/targets/old_style_modules_posix/meta/main.yml b/test/integration/targets/old_style_modules_posix/meta/main.yml new file mode 100644 index 00000000000..1810d4bec98 --- /dev/null +++ b/test/integration/targets/old_style_modules_posix/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_remote_tmp_dir diff --git a/test/integration/targets/old_style_modules_posix/tasks/main.yml b/test/integration/targets/old_style_modules_posix/tasks/main.yml index ba56de5bfc4..a7882171b61 100644 --- a/test/integration/targets/old_style_modules_posix/tasks/main.yml +++ b/test/integration/targets/old_style_modules_posix/tasks/main.yml @@ -27,8 +27,13 @@ that: - 'goodbye_ansible.msg == "Goodbye, Ansible!"' +- name: Copy module to remote + copy: + src: "{{ role_path }}/library/helloworld.sh" + dest: "{{ remote_tmp_dir }}/helloworld.sh" + - name: Execute module directly - command: '/bin/sh {{ role_path }}/library/helloworld.sh' + command: '/bin/sh {{ remote_tmp_dir }}/helloworld.sh' register: direct ignore_errors: true diff --git a/test/integration/targets/omit/48673.yml b/test/integration/targets/omit/48673.yml index b6d4f31b103..d25c8cf2a32 100644 --- a/test/integration/targets/omit/48673.yml +++ b/test/integration/targets/omit/48673.yml @@ -1,4 +1,4 @@ -- hosts: localhost +- hosts: testhost serial: "{{ testing_omitted_variable | default(omit) }}" tasks: - debug: diff --git a/test/integration/targets/pause/aliases b/test/integration/targets/pause/aliases index 447c957881a..6b71e884a14 100644 --- a/test/integration/targets/pause/aliases +++ b/test/integration/targets/pause/aliases @@ -1,2 +1,2 @@ -setup/always/setup_pexpect +needs/target/setup_pexpect shippable/posix/group3 diff --git a/test/integration/targets/pause/pause-1.yml b/test/integration/targets/pause/pause-1.yml index 493036895f4..44c9960c4b5 100644 --- a/test/integration/targets/pause/pause-1.yml +++ b/test/integration/targets/pause/pause-1.yml @@ -1,5 +1,5 @@ - name: Test pause module in default state - hosts: testhost + hosts: localhost become: no gather_facts: no diff --git a/test/integration/targets/pause/pause-2.yml b/test/integration/targets/pause/pause-2.yml index e3d900ec47f..81a7fda59bd 100644 --- a/test/integration/targets/pause/pause-2.yml +++ b/test/integration/targets/pause/pause-2.yml @@ -1,5 +1,5 @@ - name: Test pause module with custom prompt - hosts: testhost + hosts: localhost become: no gather_facts: no diff --git a/test/integration/targets/pause/pause-3.yml b/test/integration/targets/pause/pause-3.yml index 8daf0610541..8f8c72ed100 100644 --- a/test/integration/targets/pause/pause-3.yml +++ b/test/integration/targets/pause/pause-3.yml @@ -1,5 +1,5 @@ - name: Test pause module with pause - hosts: testhost + hosts: localhost become: no gather_facts: no diff --git a/test/integration/targets/pause/pause-4.yml b/test/integration/targets/pause/pause-4.yml index 01bd06a20c2..f16c7d6763e 100644 --- a/test/integration/targets/pause/pause-4.yml +++ b/test/integration/targets/pause/pause-4.yml @@ -1,5 +1,5 @@ - name: Test pause module with pause and custom prompt - hosts: testhost + hosts: localhost become: no gather_facts: no diff --git a/test/integration/targets/pause/pause-5.yml b/test/integration/targets/pause/pause-5.yml index 2a2b1548207..22955cd03d7 100644 --- a/test/integration/targets/pause/pause-5.yml +++ b/test/integration/targets/pause/pause-5.yml @@ -1,5 +1,5 @@ - name: Test pause module echo output - hosts: testhost + hosts: localhost become: no gather_facts: no diff --git a/test/integration/targets/pause/runme.sh b/test/integration/targets/pause/runme.sh index 5b2038541bd..932f49ec2d8 100755 --- a/test/integration/targets/pause/runme.sh +++ b/test/integration/targets/pause/runme.sh @@ -2,10 +2,12 @@ set -eux +ANSIBLE_ROLES_PATH=../ ansible-playbook setup.yml + # Test pause module when no tty and non-interactive. This is to prevent playbooks # from hanging in cron and Tower jobs. /usr/bin/env bash << EOF -ansible-playbook test-pause-no-tty.yml -i ../../inventory 2>&1 | \ +ansible-playbook test-pause-no-tty.yml 2>&1 | \ grep '\[WARNING\]: Not waiting for response to prompt as stdin is not interactive' && { echo 'Successfully skipped pause in no TTY mode' >&2 exit 0 @@ -17,12 +19,12 @@ EOF # Test redirecting stdout # Issue #41717 -ansible-playbook pause-3.yml -i ../../inventory > /dev/null \ +ansible-playbook pause-3.yml > /dev/null \ && echo "Successfully redirected stdout" \ || echo "Failure when attempting to redirect stdout" # Test pause with seconds and minutes specified -ansible-playbook test-pause.yml -i ../../inventory "$@" +ansible-playbook test-pause.yml "$@" # Interactively test pause -python test-pause.py -i ../../inventory "$@" +python test-pause.py "$@" diff --git a/test/integration/targets/pause/setup.yml b/test/integration/targets/pause/setup.yml new file mode 100644 index 00000000000..9f6ab117412 --- /dev/null +++ b/test/integration/targets/pause/setup.yml @@ -0,0 +1,4 @@ +- hosts: localhost + gather_facts: no + roles: + - setup_pexpect diff --git a/test/integration/targets/pause/test-pause-no-tty.yml b/test/integration/targets/pause/test-pause-no-tty.yml index f7a2b36cbc3..6e0e4027100 100644 --- a/test/integration/targets/pause/test-pause-no-tty.yml +++ b/test/integration/targets/pause/test-pause-no-tty.yml @@ -1,5 +1,5 @@ - name: Test pause - hosts: testhost + hosts: localhost gather_facts: no become: no diff --git a/test/integration/targets/pause/test-pause.yml b/test/integration/targets/pause/test-pause.yml index cfe9f324270..2703eed434b 100644 --- a/test/integration/targets/pause/test-pause.yml +++ b/test/integration/targets/pause/test-pause.yml @@ -1,5 +1,5 @@ - name: Test pause - hosts: testhost + hosts: localhost gather_facts: no become: no diff --git a/test/integration/targets/read_csv/tasks/main.yml b/test/integration/targets/read_csv/tasks/main.yml index e00d2a6ed21..a3dcf8a5efe 100644 --- a/test/integration/targets/read_csv/tasks/main.yml +++ b/test/integration/targets/read_csv/tasks/main.yml @@ -61,7 +61,6 @@ unique: no delimiter: ';' register: users_nonunique - delegate_to: localhost - assert: that: @@ -96,7 +95,6 @@ dag,500,500,Dag Wieƫrs jeroen,501,500,Jeroen Hoekx dest: users_noheader.csv - delegate_to: localhost # Read a CSV file and access user 'dag' - name: Read users from CSV file and return a dictionary diff --git a/test/integration/targets/script/tasks/main.yml b/test/integration/targets/script/tasks/main.yml index e7913c9a9e8..441d7406912 100644 --- a/test/integration/targets/script/tasks/main.yml +++ b/test/integration/targets/script/tasks/main.yml @@ -45,7 +45,6 @@ assert: that: - "script_result0.rc == 0" - - "script_result0.stderr == ''" - "script_result0.stdout == 'win'" - name: Execute a script with a space in the path diff --git a/test/integration/targets/sensu_client/aliases b/test/integration/targets/sensu_client/aliases index a6dafcf8cd8..5dcaaac61cb 100644 --- a/test/integration/targets/sensu_client/aliases +++ b/test/integration/targets/sensu_client/aliases @@ -1 +1,2 @@ shippable/posix/group1 +needs/root diff --git a/test/integration/targets/sensu_client/tasks/main.yml b/test/integration/targets/sensu_client/tasks/main.yml index c15685ad81d..387a7c1e226 100644 --- a/test/integration/targets/sensu_client/tasks/main.yml +++ b/test/integration/targets/sensu_client/tasks/main.yml @@ -22,24 +22,23 @@ - default register: client -- name: Retrieve configuration file stat - stat: - path: "{{ client_file }}" - register: client_stat +- name: Retrieve configuration file + slurp: + src: "{{ client_file }}" + register: client_config - name: Assert that client data was set successfully and properly assert: that: - "client is successful" - "client is changed" - - "client_stat.stat.exists == true" - "client['config']['name'] == 'client'" - "'default' in client['config']['subscriptions']" - "client['file'] == client_file" - name: Assert that the client configuration file is actually configured properly vars: - config: "{{ lookup('file', client_file) | from_json }}" + config: "{{ client_config.content | b64decode | from_json }}" assert: that: - "config['client']['keepalives'] == true" @@ -129,10 +128,10 @@ occurrences: "3" register: client_twice -- name: Retrieve configuration file stat - stat: - path: "{{ client_file }}" - register: client_stat +- name: Retrieve configuration file + slurp: + src: "{{ client_file }}" + register: client_config - name: Assert that client data was set successfully and properly assert: @@ -141,7 +140,6 @@ - "client is changed" - "client_twice is successful" - "client_twice is not changed" - - "client_stat.stat.exists == true" - "client['config']['name'] == 'custom'" - "client['config']['address'] == 'host.fqdn'" - "'default' in client['config']['subscriptions']" @@ -155,7 +153,7 @@ - name: Assert that the client configuration file is actually configured properly vars: - config: "{{ lookup('file', client_file) | from_json }}" + config: "{{ client_config.content | b64decode | from_json }}" assert: that: - "config['client']['name'] == 'custom'" diff --git a/test/integration/targets/sensu_handler/aliases b/test/integration/targets/sensu_handler/aliases index a6dafcf8cd8..5dcaaac61cb 100644 --- a/test/integration/targets/sensu_handler/aliases +++ b/test/integration/targets/sensu_handler/aliases @@ -1 +1,2 @@ shippable/posix/group1 +needs/root diff --git a/test/integration/targets/sensu_handler/tasks/main.yml b/test/integration/targets/sensu_handler/tasks/main.yml index e85543f20b9..0c0b56d23e9 100644 --- a/test/integration/targets/sensu_handler/tasks/main.yml +++ b/test/integration/targets/sensu_handler/tasks/main.yml @@ -28,10 +28,10 @@ state: "present" register: handler_twice -- name: Retrieve configuration file stat - stat: - path: "{{ handler['file'] }}" - register: handler_stat +- name: Retrieve configuration file + slurp: + src: "{{ handler['file'] }}" + register: handler_config - name: Assert that handler data was set successfully and properly assert: @@ -40,7 +40,6 @@ - "handler is changed" - "handler_twice is successful" - "handler_twice is not changed" - - "handler_stat.stat.exists == true" - "handler['name'] == 'handler'" - "handler['file'] == '/etc/sensu/conf.d/handlers/handler.json'" - "handler['config']['type'] == 'pipe'" @@ -51,7 +50,7 @@ - name: Assert that the handler configuration file is actually configured properly vars: - config: "{{ lookup('file', handler['file']) | from_json }}" + config: "{{ handler_config.content | b64decode | from_json }}" assert: that: - "'handler' in config['handlers']" diff --git a/test/integration/targets/sensu_handler/tasks/set.yml b/test/integration/targets/sensu_handler/tasks/set.yml index 27908b76ca7..393d711dc3b 100644 --- a/test/integration/targets/sensu_handler/tasks/set.yml +++ b/test/integration/targets/sensu_handler/tasks/set.yml @@ -19,17 +19,16 @@ - anotherhandler register: handler -- name: Retrieve configuration file stat - stat: - path: "{{ handler['file'] }}" - register: handler_stat +- name: Retrieve configuration file + slurp: + src: "{{ handler['file'] }}" + register: handler_config - name: Validate set handler return data assert: that: - "handler is successful" - "handler is changed" - - "handler_stat.stat.exists == true" - "handler['name'] == 'set'" - "handler['file'] == '/etc/sensu/conf.d/handlers/set.json'" - "handler['config']['type'] == 'set'" @@ -39,7 +38,7 @@ - name: Assert that the handler configuration file is actually configured properly vars: - config: "{{ lookup('file', handler['file']) | from_json }}" + config: "{{ handler_config.content | b64decode | from_json }}" assert: that: - "'set' in config['handlers']" diff --git a/test/integration/targets/sensu_handler/tasks/tcp.yml b/test/integration/targets/sensu_handler/tasks/tcp.yml index f318e3b8c95..076ea14e1ee 100644 --- a/test/integration/targets/sensu_handler/tasks/tcp.yml +++ b/test/integration/targets/sensu_handler/tasks/tcp.yml @@ -20,17 +20,16 @@ port: 8000 register: handler -- name: Retrieve configuration file stat - stat: - path: "{{ handler['file'] }}" - register: handler_stat +- name: Retrieve configuration file + slurp: + src: "{{ handler['file'] }}" + register: handler_config - name: Validate tcp handler return data assert: that: - "handler is successful" - "handler is changed" - - "handler_stat.stat.exists == true" - "handler['name'] == 'tcp'" - "handler['file'] == '/etc/sensu/conf.d/handlers/tcp.json'" - "handler['config']['type'] == 'tcp'" @@ -41,7 +40,7 @@ - name: Assert that the handler configuration file is actually configured properly vars: - config: "{{ lookup('file', handler['file']) | from_json }}" + config: "{{ handler_config.content | b64decode | from_json }}" assert: that: - "'tcp' in config['handlers']" diff --git a/test/integration/targets/sensu_handler/tasks/transport.yml b/test/integration/targets/sensu_handler/tasks/transport.yml index c40ee56202c..34816194faa 100644 --- a/test/integration/targets/sensu_handler/tasks/transport.yml +++ b/test/integration/targets/sensu_handler/tasks/transport.yml @@ -20,17 +20,16 @@ name: "transport_handler" register: handler -- name: Retrieve configuration file stat - stat: - path: "{{ handler['file'] }}" - register: handler_stat +- name: Retrieve configuration file + slurp: + src: "{{ handler['file'] }}" + register: handler_config - name: Validate transport handler return data assert: that: - "handler is successful" - "handler is changed" - - "handler_stat.stat.exists == true" - "handler['name'] == 'transport'" - "handler['file'] == '/etc/sensu/conf.d/handlers/transport.json'" - "handler['config']['type'] == 'transport'" @@ -41,7 +40,7 @@ - name: Assert that the handler configuration file is actually configured properly vars: - config: "{{ lookup('file', handler['file']) | from_json }}" + config: "{{ handler_config.content | b64decode | from_json }}" assert: that: - "'transport' in config['handlers']" diff --git a/test/integration/targets/sensu_handler/tasks/udp.yml b/test/integration/targets/sensu_handler/tasks/udp.yml index 1c9bb4360a4..8f13a2a25e5 100644 --- a/test/integration/targets/sensu_handler/tasks/udp.yml +++ b/test/integration/targets/sensu_handler/tasks/udp.yml @@ -20,17 +20,16 @@ port: 8000 register: handler -- name: Retrieve configuration file stat - stat: - path: "{{ handler['file'] }}" - register: handler_stat +- name: Retrieve configuration file + slurp: + src: "{{ handler['file'] }}" + register: handler_config - name: Validate udp handler return data assert: that: - "handler is successful" - "handler is changed" - - "handler_stat.stat.exists == true" - "handler['name'] == 'udp'" - "handler['file'] == '/etc/sensu/conf.d/handlers/udp.json'" - "handler['config']['type'] == 'udp'" @@ -41,7 +40,7 @@ - name: Assert that the handler configuration file is actually configured properly vars: - config: "{{ lookup('file', handler['file']) | from_json }}" + config: "{{ handler_config.content | b64decode | from_json }}" assert: that: - "'udp' in config['handlers']" diff --git a/test/integration/targets/task_ordering/meta/main.yml b/test/integration/targets/task_ordering/meta/main.yml new file mode 100644 index 00000000000..1810d4bec98 --- /dev/null +++ b/test/integration/targets/task_ordering/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_remote_tmp_dir diff --git a/test/integration/targets/task_ordering/tasks/main.yml b/test/integration/targets/task_ordering/tasks/main.yml index 281b8370787..4a7828bf425 100644 --- a/test/integration/targets/task_ordering/tasks/main.yml +++ b/test/integration/targets/task_ordering/tasks/main.yml @@ -1,12 +1,15 @@ -- shell: mktemp - register: temppath +- set_fact: + temppath: "{{ remote_tmp_dir }}/output.txt" + - include: taskorder-include.yml with_items: - 1 - 2 - 3 -- assert: - that: lookup('file', temppath.stdout) == "one.1.two.1.three.1.four.1.one.2.two.2.three.2.four.2.one.3.two.3.three.3.four.3." +- slurp: + src: "{{ temppath }}" + register: tempout -- file: path="{{temppath.stdout}}" state=absent +- assert: + that: tempout.content | b64decode == "one.1.two.1.three.1.four.1.one.2.two.2.three.2.four.2.one.3.two.3.three.3.four.3." diff --git a/test/integration/targets/task_ordering/tasks/taskorder-include.yml b/test/integration/targets/task_ordering/tasks/taskorder-include.yml index 4e64b7e9276..228e897e4d6 100644 --- a/test/integration/targets/task_ordering/tasks/taskorder-include.yml +++ b/test/integration/targets/task_ordering/tasks/taskorder-include.yml @@ -2,9 +2,9 @@ # There have been regressions where included tasks and # nested blocks ran out of order... -- shell: printf one.{{ item }}. >> {{ temppath.stdout }} +- shell: printf one.{{ item }}. >> {{ temppath }} - block: - - shell: printf two.{{ item }}. >> {{ temppath.stdout }} + - shell: printf two.{{ item }}. >> {{ temppath }} - block: - - shell: printf three.{{ item }}. >> {{ temppath.stdout }} -- shell: printf four.{{ item }}. >> {{ temppath.stdout }} + - shell: printf three.{{ item }}. >> {{ temppath }} +- shell: printf four.{{ item }}. >> {{ temppath }} diff --git a/test/integration/targets/templating_settings/test_templating_settings.yml b/test/integration/targets/templating_settings/test_templating_settings.yml index d00300bdc22..7fdd1fb85b2 100644 --- a/test/integration/targets/templating_settings/test_templating_settings.yml +++ b/test/integration/targets/templating_settings/test_templating_settings.yml @@ -1,6 +1,6 @@ --- - name: 'Test templating in name' - hosts: localhost + hosts: testhost connection: local vars: a_list: diff --git a/test/integration/targets/want_json_modules_posix/meta/main.yml b/test/integration/targets/want_json_modules_posix/meta/main.yml new file mode 100644 index 00000000000..1810d4bec98 --- /dev/null +++ b/test/integration/targets/want_json_modules_posix/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - setup_remote_tmp_dir diff --git a/test/integration/targets/want_json_modules_posix/tasks/main.yml b/test/integration/targets/want_json_modules_posix/tasks/main.yml index 59ad0b7ca1e..27e9f781b6a 100644 --- a/test/integration/targets/want_json_modules_posix/tasks/main.yml +++ b/test/integration/targets/want_json_modules_posix/tasks/main.yml @@ -27,8 +27,13 @@ that: - 'goodbye_ansible.msg == "Goodbye, Ansible!"' +- name: Copy module to remote + copy: + src: "{{ role_path }}/library/helloworld.py" + dest: "{{ remote_tmp_dir }}/helloworld.py" + - name: Execute module directly - command: '{{ ansible_python_interpreter|default(ansible_playbook_python) }} {{ role_path }}/library/helloworld.py' + command: '{{ ansible_python_interpreter|default(ansible_playbook_python) }} {{ remote_tmp_dir }}/helloworld.py' register: direct ignore_errors: true