diff --git a/test/integration/targets/ansible-galaxy-collection-scm/aliases b/test/integration/targets/ansible-galaxy-collection-scm/aliases index 1d28bdb2aa3..2fb819759d0 100644 --- a/test/integration/targets/ansible-galaxy-collection-scm/aliases +++ b/test/integration/targets/ansible-galaxy-collection-scm/aliases @@ -1,2 +1,3 @@ shippable/posix/group5 context/controller +needs/root diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/requirements.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/requirements.yml index 10070f1a052..022a35cf951 100644 --- a/test/integration/targets/ansible-galaxy-collection-scm/tasks/requirements.yml +++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/requirements.yml @@ -26,7 +26,7 @@ that: - result.failed - >- - "ERROR! Neither the collection requirement entry key 'name', + "Neither the collection requirement entry key 'name', nor 'source' point to a concrete resolvable collection artifact. Also 'name' is not an FQCN. A valid collection name must be in the format .. Please make sure that the @@ -44,7 +44,7 @@ that: - result.failed - >- - result.stderr is search("ERROR! Collections requirement 'source' + result.stderr is search("Collections requirement 'source' entry should contain a valid Galaxy API URL but it does not: git\+file:///.*/amazon.aws/.git is not an HTTP URL.") @@ -59,7 +59,7 @@ that: - result.failed - >- - result.stderr is search("ERROR! Failed to clone a Git repository + result.stderr is search("Failed to clone a Git repository from `file:///.*/.git`.") - >- result.stderr is search("fatal: '/.*/amazon.aws/.git' does not diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/scm_dependency_deduplication.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/scm_dependency_deduplication.yml index f200be18032..959149a022b 100644 --- a/test/integration/targets/ansible-galaxy-collection-scm/tasks/scm_dependency_deduplication.yml +++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/scm_dependency_deduplication.yml @@ -12,23 +12,23 @@ 'Starting collection install process' in command.stdout_lines - >- - "Installing 'namespace_1.collection_1:1.0.0' to - '{{ install_path }}/namespace_1/collection_1'" + "Installing 'namespace_1.collection_1:1.0.0' to '" + + install_path + "/namespace_1/collection_1'" in command.stdout_lines - >- - 'Created collection for namespace_1.collection_1:1.0.0 at - {{ install_path }}/namespace_1/collection_1' + 'Created collection for namespace_1.collection_1:1.0.0 at ' + + install_path + '/namespace_1/collection_1' in command.stdout_lines - >- 'namespace_1.collection_1:1.0.0 was installed successfully' in command.stdout_lines - >- - "Installing 'namespace_2.collection_2:1.0.0' to - '{{ install_path }}/namespace_2/collection_2'" + "Installing 'namespace_2.collection_2:1.0.0' to '" + + install_path + "/namespace_2/collection_2'" in command.stdout_lines - >- - 'Created collection for namespace_2.collection_2:1.0.0 at - {{ install_path }}/namespace_2/collection_2' + 'Created collection for namespace_2.collection_2:1.0.0 at ' + + install_path + '/namespace_2/collection_2' in command.stdout_lines - >- 'namespace_2.collection_2:1.0.0 was installed successfully' @@ -57,23 +57,23 @@ 'Starting collection install process' in command.stdout_lines - >- - "Installing 'namespace_1.collection_1:1.0.0' to - '{{ install_path }}/namespace_1/collection_1'" + "Installing 'namespace_1.collection_1:1.0.0' to '" + + install_path + "/namespace_1/collection_1'" in command.stdout_lines - >- - 'Created collection for namespace_1.collection_1:1.0.0 at - {{ install_path }}/namespace_1/collection_1' + 'Created collection for namespace_1.collection_1:1.0.0 at ' + + install_path + '/namespace_1/collection_1' in command.stdout_lines - >- 'namespace_1.collection_1:1.0.0 was installed successfully' in command.stdout_lines - >- - "Installing 'namespace_2.collection_2:1.0.0' to - '{{ install_path }}/namespace_2/collection_2'" + "Installing 'namespace_2.collection_2:1.0.0' to '" + + install_path + "/namespace_2/collection_2'" in command.stdout_lines - >- - 'Created collection for namespace_2.collection_2:1.0.0 at - {{ install_path }}/namespace_2/collection_2' + 'Created collection for namespace_2.collection_2:1.0.0 at ' + + install_path + '/namespace_2/collection_2' in command.stdout_lines - >- 'namespace_2.collection_2:1.0.0 was installed successfully' diff --git a/test/integration/targets/ansible-galaxy-collection/library/setup_collections.py b/test/integration/targets/ansible-galaxy-collection/library/setup_collections.py index 9efd7bbef60..eb7c5a94dcf 100644 --- a/test/integration/targets/ansible-galaxy-collection/library/setup_collections.py +++ b/test/integration/targets/ansible-galaxy-collection/library/setup_collections.py @@ -78,9 +78,11 @@ RETURN = """ import datetime import os +import random import subprocess import tarfile import tempfile +import time import yaml from ansible.module_utils.basic import AnsibleModule @@ -100,6 +102,8 @@ def publish_collection(module, collection): dependencies = collection['dependencies'] use_symlink = collection['use_symlink'] + time.sleep(random.random()) # inject some time wobble into parallel publish operations since Galaxy publish DB key generation is not mutex'd + result = {} collection_dir = os.path.join(module.tmpdir, "%s-%s-%s" % (namespace, name, version)) b_collection_dir = to_bytes(collection_dir, errors='surrogate_or_strict') diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/install.yml b/test/integration/targets/ansible-galaxy-collection/tasks/install.yml index f6055b660c8..18f56e96033 100644 --- a/test/integration/targets/ansible-galaxy-collection/tasks/install.yml +++ b/test/integration/targets/ansible-galaxy-collection/tasks/install.yml @@ -232,7 +232,7 @@ vars: error: "{{ result.stderr | regex_replace('\\n', ' ') }}" expected_error: >- - ERROR! Failed to resolve the requested dependencies map. + Failed to resolve the requested dependencies map. Got the candidate namespace3.name:1.0.0 (direct request) which didn't satisfy all of the following requirements: * namespace3.name:1.2.0 @@ -241,7 +241,7 @@ vars: error: "{{ result.stderr | regex_replace('\\n', ' ') }}" expected_error: >- - ERROR! Failed to resolve the requested dependencies map. + Failed to resolve the requested dependencies map. Got the candidate namespace3.name:1.0.0 (dependency of tmp_parent.name:1.0.0) which didn't satisfy all of the following requirements: * namespace3.name:1.2.0 @@ -535,7 +535,7 @@ - assert: that: - required_together is failed - - '"ERROR! Signatures were provided to verify namespace1.name1 but no keyring was configured." in required_together.stderr' + - required_together.stderr is contains("Signatures were provided to verify namespace1.name1 but no keyring was configured.") - name: install collections with ansible-galaxy install -r with invalid signatures - {{ test_id }} # Note that --keyring is a valid option for 'ansible-galaxy install -r ...', not just 'ansible-galaxy collection ...' @@ -796,7 +796,7 @@ - name: assert cache version list is ignored on a collection version change - {{ test_id }} assert: that: - - '"Installing ''cache.cache:1.0.{{ cache_version_build }}'' to" in install_cached_update.stdout' + - '"Installing ''cache.cache:1.0." ~ cache_version_build ~ "'' to" in install_cached_update.stdout' - (install_cached_update_actual.content | b64decode | from_json).collection_info.version == '1.0.' ~ cache_version_build - name: install collection with symlink - {{ test_id }} diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/install_offline.yml b/test/integration/targets/ansible-galaxy-collection/tasks/install_offline.yml index f3b9777c81d..9c889635432 100644 --- a/test/integration/targets/ansible-galaxy-collection/tasks/install_offline.yml +++ b/test/integration/targets/ansible-galaxy-collection/tasks/install_offline.yml @@ -95,9 +95,9 @@ - galaxy_err in missing_dep.stderr - missing_err in missing_dep_offline.stderr vars: - galaxy_err: "ERROR! Unknown error when attempting to call Galaxy at '{{ offline_server }}'" + galaxy_err: "Unknown error when attempting to call Galaxy at '{{ offline_server }}'" missing_err: |- - ERROR! Failed to resolve the requested dependencies map. Could not satisfy the following requirements: + Failed to resolve the requested dependencies map. Could not satisfy the following requirements: * ns.coll2:>=1.0.0 (dependency of ns.coll1:1.0.0) - name: install the dependency from the tarfile diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/list.yml b/test/integration/targets/ansible-galaxy-collection/tasks/list.yml index 1c93d54bf09..4e2569f7215 100644 --- a/test/integration/targets/ansible-galaxy-collection/tasks/list.yml +++ b/test/integration/targets/ansible-galaxy-collection/tasks/list.yml @@ -60,13 +60,13 @@ - assert: that: - - "'dev.collection1 *' in list_result.stdout" + - 'list_result.stdout is regex "dev.collection1\s+\*"' # Note the version displayed is the 'placeholder' string rather than "*" since it is not falsey - - "'dev.collection2 placeholder' in list_result.stdout" - - "'dev.collection3 *' in list_result.stdout" - - "'dev.collection4 *' in list_result.stdout" - - "'dev.collection5 *' in list_result.stdout" - - "'dev.collection6 *' in list_result.stdout" + - 'list_result.stdout is regex "dev.collection2\s+placeholder"' + - 'list_result.stdout is regex "dev.collection3\s+\*"' + - 'list_result.stdout is regex "dev.collection4\s+\*"' + - 'list_result.stdout is regex "dev.collection5\s+\*"' + - 'list_result.stdout is regex "dev.collection6\s+\*"' - name: list collections in human format command: ansible-galaxy collection list --format human @@ -76,12 +76,13 @@ - assert: that: - - "'dev.collection1 *' in list_result_human.stdout" + - 'list_result_human.stdout is regex "dev.collection1\s+\*"' # Note the version displayed is the 'placeholder' string rather than "*" since it is not falsey - - "'dev.collection2 placeholder' in list_result_human.stdout" - - "'dev.collection3 *' in list_result_human.stdout" - - "'dev.collection5 *' in list_result.stdout" - - "'dev.collection6 *' in list_result.stdout" + - 'list_result_human.stdout is regex "dev.collection2\s+placeholder"' + - 'list_result_human.stdout is regex "dev.collection3\s+\*"' + - 'list_result_human.stdout is regex "dev.collection4\s+\*"' + - 'list_result_human.stdout is regex "dev.collection5\s+\*"' + - 'list_result_human.stdout is regex "dev.collection6\s+\*"' - name: list collections in yaml format command: ansible-galaxy collection list --format yaml diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/unsupported_resolvelib.yml b/test/integration/targets/ansible-galaxy-collection/tasks/unsupported_resolvelib.yml index a208b2952e3..8162ae343ce 100644 --- a/test/integration/targets/ansible-galaxy-collection/tasks/unsupported_resolvelib.yml +++ b/test/integration/targets/ansible-galaxy-collection/tasks/unsupported_resolvelib.yml @@ -27,7 +27,7 @@ - assert: that: - resolvelib_version_error is failed - - resolvelib_version_error.stderr | regex_search(error) + - resolvelib_version_error.stderr | regex_search(error) is truthy vars: error: "({{ import_error }}|{{ compat_error }})" import_error: "Failed to import resolvelib" diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/verify.yml b/test/integration/targets/ansible-galaxy-collection/tasks/verify.yml index 9dda1b71b53..da2b58ba57b 100644 --- a/test/integration/targets/ansible-galaxy-collection/tasks/verify.yml +++ b/test/integration/targets/ansible-galaxy-collection/tasks/verify.yml @@ -44,7 +44,7 @@ that: - verify is success - >- - "Found API version '{{ test_api_fallback_versions }}' with Galaxy server {{ test_api_fallback }}" in verify.stdout + "Found API version '" + test_api_fallback_versions + "' with Galaxy server " + test_api_fallback in verify.stdout - name: verify the installed collection against the server command: ansible-galaxy collection verify ansible_test.verify:1.0.0 -s {{ test_name }} {{ galaxy_verbosity }} diff --git a/test/integration/targets/ansible-inventory/tasks/main.yml b/test/integration/targets/ansible-inventory/tasks/main.yml index c3459c122ca..f5da14fc8d8 100644 --- a/test/integration/targets/ansible-inventory/tasks/main.yml +++ b/test/integration/targets/ansible-inventory/tasks/main.yml @@ -6,7 +6,7 @@ - assert: that: - result is failed - - '"ERROR! No action selected, at least one of --host, --graph or --list needs to be specified." in result.stderr' + - result.stderr is contains "No action selected, at least one of --host, --graph or --list needs to be specified." - name: "test option: --list --export" command: ansible-inventory --list --export @@ -62,7 +62,7 @@ - assert: that: - result is failed - - '"ERROR! Pattern must be valid group name when using --graph" in result.stderr' + - result.stderr is contains "Pattern must be valid group name when using --graph" - name: "test option: --host localhost" command: ansible-inventory --host localhost @@ -80,7 +80,8 @@ - assert: that: - result is failed - - '"ERROR! Could not match supplied host pattern, ignoring: invalid" in result.stderr' + - | + result.stderr is contains "Could not match supplied host pattern, ignoring: invalid" - name: "test json output with unicode characters" command: ansible-inventory --list -i {{ role_path }}/files/unicode.yml diff --git a/test/integration/targets/ansible-playbook-callbacks/all-callbacks.yml b/test/integration/targets/ansible-playbook-callbacks/all-callbacks.yml index 85a53c744c6..a8b201b484a 100644 --- a/test/integration/targets/ansible-playbook-callbacks/all-callbacks.yml +++ b/test/integration/targets/ansible-playbook-callbacks/all-callbacks.yml @@ -45,9 +45,9 @@ - name: loop debug: ignore_errors: true - changed_when: '{{ item.changed }}' - failed_when: '{{ item.failed }}' - when: '{{ item.when }}' + changed_when: item.changed + failed_when: item.failed + when: item.when loop: # ok - changed: false diff --git a/test/integration/targets/ansible-pull/cleanup.yml b/test/integration/targets/ansible-pull/cleanup.yml index 32a6602f9e1..68686964e96 100644 --- a/test/integration/targets/ansible-pull/cleanup.yml +++ b/test/integration/targets/ansible-pull/cleanup.yml @@ -1,6 +1,6 @@ - hosts: localhost vars: - git_install: '{{ lookup("file", lookup("env", "OUTPUT_DIR") + "/git_install.json") }}' + git_install: '{{ lookup("file", lookup("env", "OUTPUT_DIR") + "/git_install.json") | from_json }}' tasks: - name: remove unwanted packages package: diff --git a/test/integration/targets/ansible-vault/roles/test_vault_embedded/tasks/main.yml b/test/integration/targets/ansible-vault/roles/test_vault_embedded/tasks/main.yml index eba938966dc..98ef751b86b 100644 --- a/test/integration/targets/ansible-vault/roles/test_vault_embedded/tasks/main.yml +++ b/test/integration/targets/ansible-vault/roles/test_vault_embedded/tasks/main.yml @@ -2,7 +2,7 @@ - name: Assert that a embedded vault of a string with no newline works assert: that: - - '"{{ vault_encrypted_one_line_var }}" == "Setec Astronomy"' + - 'vault_encrypted_one_line_var == "Setec Astronomy"' - name: Assert that a multi line embedded vault works, including new line assert: diff --git a/test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/tasks/main.yml b/test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/tasks/main.yml index e09004a1d9e..107e65cb112 100644 --- a/test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/tasks/main.yml +++ b/test/integration/targets/ansible-vault/roles/test_vault_file_encrypted_embedded/tasks/main.yml @@ -2,7 +2,7 @@ - name: Assert that a vault encrypted file with embedded vault of a string with no newline works assert: that: - - '"{{ vault_file_encrypted_with_encrypted_one_line_var }}" == "Setec Astronomy"' + - 'vault_file_encrypted_with_encrypted_one_line_var == "Setec Astronomy"' - name: Assert that a vault encrypted file with multi line embedded vault works, including new line assert: diff --git a/test/integration/targets/ansible-vault/single_vault_as_string.yml b/test/integration/targets/ansible-vault/single_vault_as_string.yml index 2d523a0b85e..941bb83e19b 100644 --- a/test/integration/targets/ansible-vault/single_vault_as_string.yml +++ b/test/integration/targets/ansible-vault/single_vault_as_string.yml @@ -12,7 +12,7 @@ msg: "{{ vaulted_value }}" - debug: - msg: "{{ vaulted_value|type_debug }}" + msg: "{{ vaulted_value|pprint }}" - assert: that: diff --git a/test/integration/targets/ansible_log/logit.yml b/test/integration/targets/ansible_log/logit.yml index a702aed14fd..32cf46bc455 100644 --- a/test/integration/targets/ansible_log/logit.yml +++ b/test/integration/targets/ansible_log/logit.yml @@ -6,7 +6,7 @@ - name: force warning ping: - when: "{{pepe}} == 1" + when: "{{pepe == 1}}" vars: lola: 1 pepe: lola diff --git a/test/integration/targets/ansible_log/runme.sh b/test/integration/targets/ansible_log/runme.sh index 496be3dbf9c..1498cef7925 100755 --- a/test/integration/targets/ansible_log/runme.sh +++ b/test/integration/targets/ansible_log/runme.sh @@ -13,6 +13,7 @@ ansible-playbook logit.yml ANSIBLE_LOG_PATH=${ALOG} ansible-playbook logit.yml # ensure log file is created [ -f "${ALOG}" ] + # Ensure tasks and log levels appear grep -q '\[normal task\]' "${ALOG}" grep -q 'INFO| TASK \[force warning\]' "${ALOG}" diff --git a/test/integration/targets/any_errors_fatal/test_fatal.yml b/test/integration/targets/any_errors_fatal/test_fatal.yml index a12d741e9e3..48681c7419c 100644 --- a/test/integration/targets/any_errors_fatal/test_fatal.yml +++ b/test/integration/targets/any_errors_fatal/test_fatal.yml @@ -5,7 +5,7 @@ when: inventory_hostname == 'testhost2' - name: EXPECTED FAILURE ejinja eval of a var that should not exist - debug: msg="{{ test }}" + ping: data="{{ test }}" - name: testhost should never reach here as testhost2 failure above should end play debug: diff --git a/test/integration/targets/apt/tasks/downgrade.yml b/test/integration/targets/apt/tasks/downgrade.yml index 896b644d468..e80b099380b 100644 --- a/test/integration/targets/apt/tasks/downgrade.yml +++ b/test/integration/targets/apt/tasks/downgrade.yml @@ -51,7 +51,7 @@ assert: that: - "'1.0.0' in apt_downgrade_foo_version.stdout" - - "{{ apt_downgrade_foo_version.changed }}" + - "apt_downgrade_foo_version.changed" - name: downgrade foo with flag again apt: diff --git a/test/integration/targets/apt/tasks/upgrade.yml b/test/integration/targets/apt/tasks/upgrade.yml index cf747c8108a..4fdfd065d8c 100644 --- a/test/integration/targets/apt/tasks/upgrade.yml +++ b/test/integration/targets/apt/tasks/upgrade.yml @@ -39,7 +39,7 @@ assert: that: - "'1.0.0' not in foo_version.stdout" - - "{{ foo_version.changed }}" + - "foo_version.changed" - name: "(upgrade type: {{upgrade_type}}) upgrade packages to latest version (Idempotant)" apt: diff --git a/test/integration/targets/apt_repository/tasks/apt.yml b/test/integration/targets/apt_repository/tasks/apt.yml index fbaa2c78145..65cbe452c82 100644 --- a/test/integration/targets/apt_repository/tasks/apt.yml +++ b/test/integration/targets/apt_repository/tasks/apt.yml @@ -44,7 +44,7 @@ that: - 'result.changed' - 'result.state == "present"' - - 'result.repo == "{{test_ppa_name}}"' + - 'result.repo == test_ppa_name' - name: 'examine apt cache mtime' stat: path='/var/cache/apt/pkgcache.bin' @@ -78,7 +78,7 @@ that: - 'result.changed' - 'result.state == "present"' - - 'result.repo == "{{test_ppa_name}}"' + - 'result.repo == test_ppa_name' - name: 'examine apt cache mtime' stat: path='/var/cache/apt/pkgcache.bin' @@ -112,7 +112,7 @@ that: - 'result.changed' - 'result.state == "present"' - - 'result.repo == "{{test_ppa_name}}"' + - 'result.repo == test_ppa_name' - name: 'examine apt cache mtime' stat: path='/var/cache/apt/pkgcache.bin' @@ -157,7 +157,7 @@ that: - 'result.changed' - 'result.state == "present"' - - 'result.repo == "{{test_ppa_spec}}"' + - 'result.repo == test_ppa_spec' - '"sources_added" in result' - 'result.sources_added | length == 1' - '"git" in result.sources_added[0]' @@ -182,7 +182,7 @@ that: - 'result.changed' - 'result.state == "absent"' - - 'result.repo == "{{test_ppa_spec}}"' + - 'result.repo == test_ppa_spec' - '"sources_added" in result' - 'result.sources_added | length == 0' - '"sources_removed" in result' @@ -216,7 +216,7 @@ that: - 'result.changed' - 'result.state == "present"' - - 'result.repo == "{{test_ppa_spec}}"' + - 'result.repo == test_ppa_spec' - name: 'examine source file' stat: path='/etc/apt/sources.list.d/{{test_ppa_filename}}.list' diff --git a/test/integration/targets/assert/aliases b/test/integration/targets/assert/aliases index a1b27a83557..2cf35d6504f 100644 --- a/test/integration/targets/assert/aliases +++ b/test/integration/targets/assert/aliases @@ -1,2 +1,3 @@ shippable/posix/group5 context/controller # this is a controller-only action, the module is just for documentation +gather_facts/no diff --git a/test/integration/targets/async/library/async_test.py b/test/integration/targets/async/library/async_test.py index 3905679dbd1..517380c9639 100644 --- a/test/integration/targets/async/library/async_test.py +++ b/test/integration/targets/async/library/async_test.py @@ -1,20 +1,11 @@ from __future__ import annotations -import json import sys from ansible.module_utils.basic import AnsibleModule def main(): - if "--interactive" in sys.argv: - import ansible.module_utils.basic - ansible.module_utils.basic._ANSIBLE_ARGS = json.dumps(dict( - ANSIBLE_MODULE_ARGS=dict( - fail_mode="graceful" - ) - )) - module = AnsibleModule( argument_spec=dict( fail_mode=dict(type='list', default=['success']) diff --git a/test/integration/targets/async/tasks/main.yml b/test/integration/targets/async/tasks/main.yml index 65182070553..1ae24856da5 100644 --- a/test/integration/targets/async/tasks/main.yml +++ b/test/integration/targets/async/tasks/main.yml @@ -108,7 +108,7 @@ - name: assert task was successfully checked assert: that: - - fnf_result.finished + - fnf_result.finished == 1 - fnf_result is finished - name: test graceful module failure diff --git a/test/integration/targets/async_fail/library/async_test.py b/test/integration/targets/async_fail/library/async_test.py index e94a6a52e0b..50f50cade83 100644 --- a/test/integration/targets/async_fail/library/async_test.py +++ b/test/integration/targets/async_fail/library/async_test.py @@ -1,21 +1,11 @@ from __future__ import annotations -import json -import sys import time from ansible.module_utils.basic import AnsibleModule def main(): - if "--interactive" in sys.argv: - import ansible.module_utils.basic - ansible.module_utils.basic._ANSIBLE_ARGS = json.dumps(dict( - ANSIBLE_MODULE_ARGS=dict( - fail_mode="graceful" - ) - )) - module = AnsibleModule( argument_spec=dict( fail_mode=dict(type='list', default=['success']) diff --git a/test/integration/targets/blockinfile/tasks/create_dir.yml b/test/integration/targets/blockinfile/tasks/create_dir.yml index a16ada5e49a..f63f9d3d4ba 100644 --- a/test/integration/targets/blockinfile/tasks/create_dir.yml +++ b/test/integration/targets/blockinfile/tasks/create_dir.yml @@ -25,5 +25,5 @@ stat: path: "{{ remote_tmp_dir_test }}/unreadable/createme/file.txt" register: path_created - failed_when: path_created.exists is false + failed_when: path_created.stat.exists is false when: "ansible_user_id == 'root'" diff --git a/test/integration/targets/blocks/runme.sh b/test/integration/targets/blocks/runme.sh index 820107bbe1f..2bd7966a6c0 100755 --- a/test/integration/targets/blocks/runme.sh +++ b/test/integration/targets/blocks/runme.sh @@ -10,7 +10,7 @@ rm -f block_test.out # run the test and check to make sure the right number of completions was logged ansible-playbook -vv main.yml -i ../../inventory | tee block_test.out env python -c \ - 'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \ + 'import sys, re; sys.stdout.write(re.sub(r"\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \ block_test_wo_colors.out [ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ] # cleanup the output log again, to make sure the test is clean @@ -18,7 +18,7 @@ rm -f block_test.out block_test_wo_colors.out # run test with free strategy and again count the completions ansible-playbook -vv main.yml -i ../../inventory -e test_strategy=free | tee block_test.out env python -c \ - 'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \ + 'import sys, re; sys.stdout.write(re.sub(r"\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \ block_test_wo_colors.out [ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ] # cleanup the output log again, to make sure the test is clean @@ -26,7 +26,7 @@ rm -f block_test.out block_test_wo_colors.out # run test with host_pinned strategy and again count the completions ansible-playbook -vv main.yml -i ../../inventory -e test_strategy=host_pinned | tee block_test.out env python -c \ - 'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \ + 'import sys, re; sys.stdout.write(re.sub(r"\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \ block_test_wo_colors.out [ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ] @@ -34,7 +34,7 @@ env python -c \ rm -f block_test.out block_test_wo_colors.out ansible-playbook -vv block_fail.yml -i ../../inventory | tee block_test.out env python -c \ - 'import sys, re; sys.stdout.write(re.sub("\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \ + 'import sys, re; sys.stdout.write(re.sub(r"\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", "", sys.stdin.read()))' \ block_test_wo_colors.out [ "$(grep -c 'TEST COMPLETE' block_test.out)" = "$(grep -E '^[0-9]+ plays in' block_test_wo_colors.out | cut -f1 -d' ')" ] diff --git a/test/integration/targets/collections/test_task_resolved_plugin/callback_plugins/display_resolved_action.py b/test/integration/targets/collections/test_task_resolved_plugin/callback_plugins/display_resolved_action.py index 5100ae29f3a..55d5b6eb179 100644 --- a/test/integration/targets/collections/test_task_resolved_plugin/callback_plugins/display_resolved_action.py +++ b/test/integration/targets/collections/test_task_resolved_plugin/callback_plugins/display_resolved_action.py @@ -27,8 +27,8 @@ class CallbackModule(CallbackBase): super(CallbackModule, self).__init__(*args, **kwargs) self.requested_to_resolved = {} - def v2_playbook_on_task_start(self, task, is_conditional): - self.requested_to_resolved[task.action] = task.resolved_action + def v2_runner_on_ok(self, result): + self.requested_to_resolved[result._task.action] = result._task.resolved_action def v2_playbook_on_stats(self, stats): for requested, resolved in self.requested_to_resolved.items(): diff --git a/test/integration/targets/command_shell/tasks/main.yml b/test/integration/targets/command_shell/tasks/main.yml index c40b6f73ca4..f5bb4199248 100644 --- a/test/integration/targets/command_shell/tasks/main.yml +++ b/test/integration/targets/command_shell/tasks/main.yml @@ -320,7 +320,7 @@ assert: that: - shell_result0 is changed - - shell_result0.cmd == '{{ remote_tmp_dir_test }}/test.sh' + - shell_result0.cmd == remote_tmp_dir_test + '/test.sh' - shell_result0.rc == 0 - shell_result0.stderr == '' - shell_result0.stdout == 'win' @@ -582,3 +582,8 @@ shell: '{{ role_path }}/scripts/yoink.sh &' delegate_to: localhost timeout: 5 + +- name: Run command that does not exist + command: commandthatdoesnotexist --would-be-awkward + register: res + failed_when: res.stdout != '' or res.stderr != '' diff --git a/test/integration/targets/config/lookup_plugins/casting.py b/test/integration/targets/config/lookup_plugins/casting.py index 4e7338d6dd3..55232018769 100644 --- a/test/integration/targets/config/lookup_plugins/casting.py +++ b/test/integration/targets/config/lookup_plugins/casting.py @@ -52,7 +52,7 @@ class LookupModule(LookupBase): for cast in (list, int, bool, str): option = 'test_%s' % str(cast).replace("", '') value = self.get_option(option) - if value is None or type(value) is cast: + if value is None or isinstance(value, cast): continue raise Exception('%s is not a %s: got %s/%s' % (option, cast, type(value), value)) diff --git a/test/integration/targets/config/lookup_plugins/casting_individual.py b/test/integration/targets/config/lookup_plugins/casting_individual.py index af1f60acdfc..b877bd8e326 100644 --- a/test/integration/targets/config/lookup_plugins/casting_individual.py +++ b/test/integration/targets/config/lookup_plugins/casting_individual.py @@ -52,7 +52,7 @@ class LookupModule(LookupBase): if option in kwargs: self.set_option(option, kwargs[option]) value = self.get_option(option) - if type(value) is not cast: + if not isinstance(value, cast): raise Exception('%s is not a %s: got %s/%s' % (option, cast, type(value), value)) return terms diff --git a/test/integration/targets/copy/tasks/acls.yml b/test/integration/targets/copy/tasks/acls.yml index d7d099e662f..04aa13c85f3 100644 --- a/test/integration/targets/copy/tasks/acls.yml +++ b/test/integration/targets/copy/tasks/acls.yml @@ -20,7 +20,7 @@ - name: Check that there are no ACLs leftovers assert: that: - - "'user:{{ remote_unprivileged_user }}:r-x\t#effective:r--' not in acls.stdout_lines" + - "'user:' + remote_unprivileged_user + ':r-x\t#effective:r--' not in acls.stdout_lines" - name: Check that permissions match with what was set in the mode param assert: diff --git a/test/integration/targets/copy/tasks/tests.yml b/test/integration/targets/copy/tasks/tests.yml index 35c4cdf9414..2b6b5c6ff60 100644 --- a/test/integration/targets/copy/tasks/tests.yml +++ b/test/integration/targets/copy/tasks/tests.yml @@ -941,7 +941,6 @@ - "stat_dir_in_copy_link.stat.exists" - "not stat_dir_in_copy_link.stat.islnk" - "stat_dir_in_copy_link.stat.isdir" - - - "stat_dir_outside_copy_link.stat.exists" - "not stat_dir_outside_copy_link.stat.islnk" - "stat_dir_outside_copy_link.stat.isdir" @@ -1064,7 +1063,7 @@ - name: Test that remote_dir is appropriate for this test (absolute path) assert: that: - - '{{ remote_dir_expanded[0] == "/" }}' + - 'remote_dir_expanded[0] == "/"' - block: - name: Create a directory to copy @@ -1262,7 +1261,7 @@ assert: that: - "copy_result6.changed" - - "copy_result6.dest == '{{remote_dir_expanded}}/multiline.txt'" + - "copy_result6.dest == remote_dir_expanded + '/multiline.txt'" - "copy_result6.checksum == '9cd0697c6a9ff6689f0afb9136fa62e0b3fee903'" # test overwriting a file as an unprivileged user (pull request #8624) @@ -2165,26 +2164,26 @@ assert: that: - testcase5 is changed - - "stat_new_dir_with_chown.stat.uid == {{ ansible_copy_test_user.uid }}" - - "stat_new_dir_with_chown.stat.gid == {{ ansible_copy_test_group.gid }}" - - "stat_new_dir_with_chown.stat.pw_name == '{{ ansible_copy_test_user_name }}'" - - "stat_new_dir_with_chown.stat.gr_name == '{{ ansible_copy_test_user_name }}'" - - "stat_new_dir_with_chown_file1.stat.uid == {{ ansible_copy_test_user.uid }}" - - "stat_new_dir_with_chown_file1.stat.gid == {{ ansible_copy_test_group.gid }}" - - "stat_new_dir_with_chown_file1.stat.pw_name == '{{ ansible_copy_test_user_name }}'" - - "stat_new_dir_with_chown_file1.stat.gr_name == '{{ ansible_copy_test_user_name }}'" - - "stat_new_dir_with_chown_subdir.stat.uid == {{ ansible_copy_test_user.uid }}" - - "stat_new_dir_with_chown_subdir.stat.gid == {{ ansible_copy_test_group.gid }}" - - "stat_new_dir_with_chown_subdir.stat.pw_name == '{{ ansible_copy_test_user_name }}'" - - "stat_new_dir_with_chown_subdir.stat.gr_name == '{{ ansible_copy_test_user_name }}'" - - "stat_new_dir_with_chown_subdir_file12.stat.uid == {{ ansible_copy_test_user.uid }}" - - "stat_new_dir_with_chown_subdir_file12.stat.gid == {{ ansible_copy_test_group.gid }}" - - "stat_new_dir_with_chown_subdir_file12.stat.pw_name == '{{ ansible_copy_test_user_name }}'" - - "stat_new_dir_with_chown_subdir_file12.stat.gr_name == '{{ ansible_copy_test_user_name }}'" - - "stat_new_dir_with_chown_link_file12.stat.uid == {{ ansible_copy_test_user.uid }}" - - "stat_new_dir_with_chown_link_file12.stat.gid == {{ ansible_copy_test_group.gid }}" - - "stat_new_dir_with_chown_link_file12.stat.pw_name == '{{ ansible_copy_test_user_name }}'" - - "stat_new_dir_with_chown_link_file12.stat.gr_name == '{{ ansible_copy_test_user_name }}'" + - stat_new_dir_with_chown.stat.uid == ansible_copy_test_user.uid + - stat_new_dir_with_chown.stat.gid == ansible_copy_test_group.gid + - stat_new_dir_with_chown.stat.pw_name == ansible_copy_test_user_name + - stat_new_dir_with_chown.stat.gr_name == ansible_copy_test_user_name + - stat_new_dir_with_chown_file1.stat.uid == ansible_copy_test_user.uid + - stat_new_dir_with_chown_file1.stat.gid == ansible_copy_test_group.gid + - stat_new_dir_with_chown_file1.stat.pw_name == ansible_copy_test_user_name + - stat_new_dir_with_chown_file1.stat.gr_name == ansible_copy_test_user_name + - stat_new_dir_with_chown_subdir.stat.uid == ansible_copy_test_user.uid + - stat_new_dir_with_chown_subdir.stat.gid == ansible_copy_test_group.gid + - stat_new_dir_with_chown_subdir.stat.pw_name == ansible_copy_test_user_name + - stat_new_dir_with_chown_subdir.stat.gr_name == ansible_copy_test_user_name + - stat_new_dir_with_chown_subdir_file12.stat.uid == ansible_copy_test_user.uid + - stat_new_dir_with_chown_subdir_file12.stat.gid == ansible_copy_test_group.gid + - stat_new_dir_with_chown_subdir_file12.stat.pw_name == ansible_copy_test_user_name + - stat_new_dir_with_chown_subdir_file12.stat.gr_name == ansible_copy_test_user_name + - stat_new_dir_with_chown_link_file12.stat.uid == ansible_copy_test_user.uid + - stat_new_dir_with_chown_link_file12.stat.gid == ansible_copy_test_group.gid + - stat_new_dir_with_chown_link_file12.stat.pw_name == ansible_copy_test_user_name + - stat_new_dir_with_chown_link_file12.stat.gr_name == ansible_copy_test_user_name always: - name: execute - remove the user for test @@ -2356,7 +2355,7 @@ assert: that: - fail_copy_encrypted_file is failed - - fail_copy_encrypted_file.msg == 'A vault password or secret must be specified to decrypt {{role_path}}/files-different/vault/vault-file' + - fail_copy_encrypted_file.msg.endswith('A vault password or secret must be specified to decrypt ' + role_path + '/files-different/vault/vault-file') - name: fail to copy a directory with an encrypted file without the password copy: @@ -2369,7 +2368,7 @@ assert: that: - fail_copy_directory_with_enc_file is failed - - fail_copy_directory_with_enc_file.msg == 'A vault password or secret must be specified to decrypt {{role_path}}/files-different/vault/vault-file' + - fail_copy_directory_with_enc_file.msg.endswith('A vault password or secret must be specified to decrypt ' + role_path + '/files-different/vault/vault-file') # # Test for issue 74536: recursively copy all nested directories with remote_src=yes and src='dir/' when dest exists diff --git a/test/integration/targets/debug/runme.sh b/test/integration/targets/debug/runme.sh index 5faeb782a65..0d2908a2f81 100755 --- a/test/integration/targets/debug/runme.sh +++ b/test/integration/targets/debug/runme.sh @@ -2,19 +2,21 @@ set -eux +set -o pipefail + trap 'rm -f out' EXIT -ansible-playbook main.yml -i ../../inventory | tee out +ansible-playbook main.yml -i ../../inventory "${@}" | tee out for i in 1 2 3; do grep "ok: \[localhost\] => (item=$i)" out grep "\"item\": $i" out done -ansible-playbook main_fqcn.yml -i ../../inventory | tee out +ansible-playbook main_fqcn.yml -i ../../inventory "${@}" | tee out for i in 1 2 3; do grep "ok: \[localhost\] => (item=$i)" out grep "\"item\": $i" out done # ensure debug does not set top level vars when looking at ansible_facts -ansible-playbook nosetfacts.yml "$@" +ansible-playbook nosetfacts.yml "${@}" diff --git a/test/integration/targets/delegate_to/test_random_delegate_to_with_loop.yml b/test/integration/targets/delegate_to/test_random_delegate_to_with_loop.yml index cd7b888b6e9..543aa412f6b 100644 --- a/test/integration/targets/delegate_to/test_random_delegate_to_with_loop.yml +++ b/test/integration/targets/delegate_to/test_random_delegate_to_with_loop.yml @@ -5,7 +5,7 @@ name: 'host{{ item }}' groups: - test - loop: '{{ range(10) }}' + loop: '{{ range(10) | list }}' # This task may fail, if it does, it means the same thing as if the assert below fails - set_fact: @@ -13,7 +13,7 @@ delegate_to: '{{ groups.test|random }}' delegate_facts: true # Purposefully smaller loop than group count - loop: '{{ range(5) }}' + loop: '{{ range(5) | list }}' - hosts: test gather_facts: false diff --git a/test/integration/targets/delegate_to/test_random_delegate_to_without_loop.yml b/test/integration/targets/delegate_to/test_random_delegate_to_without_loop.yml index 95278628919..e4f5babea91 100644 --- a/test/integration/targets/delegate_to/test_random_delegate_to_without_loop.yml +++ b/test/integration/targets/delegate_to/test_random_delegate_to_without_loop.yml @@ -5,7 +5,7 @@ name: 'host{{ item }}' groups: - test - loop: '{{ range(10) }}' + loop: '{{ range(10) | list }}' - set_fact: dv: '{{ ansible_delegated_vars[ansible_host]["ansible_host"] }}' diff --git a/test/integration/targets/dnf/tasks/skip_broken_and_nobest.yml b/test/integration/targets/dnf/tasks/skip_broken_and_nobest.yml index c50457c9c17..0404e63aebe 100644 --- a/test/integration/targets/dnf/tasks/skip_broken_and_nobest.yml +++ b/test/integration/targets/dnf/tasks/skip_broken_and_nobest.yml @@ -90,8 +90,9 @@ that: - skip_broken_res.rc == 0 - skip_broken_res.results|length == 2 - - res.results|select("contains", "Installed: broken-a-1.2.4")|length > 0 - - res.results|select("contains", "Installed: broken-d-1.2.5")|length > 0 + # FIXME: The following assertions have always been broken. Fix the code and/or test as needed. + # - 'skip_broken_res.results|select("contains", "Installed: broken-a-1.2.4")|length > 0' + # - 'skip_broken_res.results|select("contains", "Installed: broken-d-1.2.5")|length > 0' - name: Remove all test packages dnf: @@ -126,10 +127,12 @@ check_mode: true register: res - - assert: + - vars: + pkg_state: '{{ "Downgrade:" if dnf5|default(false) else "Installed:" }}' + assert: that: - res is changed - - res.results|select("contains", "Installed: broken-a-1.2.3")|length > 0 + - res.results|select("contains", pkg_state ~ " broken-a-1.2.3")|length > 0 # Still case 2, but with broken package to test skip_broken # skip_broken: false @@ -177,10 +180,12 @@ check_mode: true register: res - - assert: + - vars: + pkg_state: '{{ "Downgrade:" if dnf5|default(false) else "Installed:" }}' + assert: that: - res is changed - - res.results|select("contains", "Installed: broken-a-1.2.3")|length > 0 + - res.results|select("contains", pkg_state ~ " broken-a-1.2.3")|length > 0 # Case 3 still, with broken package and skip_broken tests like above. - name: Install an older known broken version of broken-a, allow_downgrade=true, skip_broken=false diff --git a/test/integration/targets/dnf/tasks/test_sos_removal.yml b/test/integration/targets/dnf/tasks/test_sos_removal.yml index 5e161dbb2e7..cd43adfca29 100644 --- a/test/integration/targets/dnf/tasks/test_sos_removal.yml +++ b/test/integration/targets/dnf/tasks/test_sos_removal.yml @@ -15,5 +15,6 @@ that: - sos_rm is successful - sos_rm is changed - - sos_rm.results|select("contains", "Removed: sos-{{ sos_version }}-{{ sos_release }}")|length > 0 + - | + sos_rm.results|select("contains", "Removed: sos-" ~ sos_version ~ "-" ~ sos_release) | length > 0 - sos_rm.results|length > 0 diff --git a/test/integration/targets/environment/test_environment.yml b/test/integration/targets/environment/test_environment.yml index f295cf3cabc..685efc31118 100644 --- a/test/integration/targets/environment/test_environment.yml +++ b/test/integration/targets/environment/test_environment.yml @@ -96,7 +96,7 @@ - name: assert foo==outer assert: that: - - "{{ test_foo.results[0].stdout == 'outer' }}" + - test_foo.results[0].stdout == 'outer' - name: set environment on a task environment: @@ -120,7 +120,7 @@ - name: assert foo==outer assert: that: - - "{{ test_foo.results[0].stdout == 'outer' }}" + - test_foo.results[0].stdout == 'outer' - name: set environment on a block environment: @@ -170,4 +170,4 @@ - name: assert foo==outer assert: that: - - "{{ test_foo.results[0].stdout == 'outer' }}" + - test_foo.results[0].stdout == 'outer' diff --git a/test/integration/targets/expect/aliases b/test/integration/targets/expect/aliases index 7211b8d09ac..4991eb2383b 100644 --- a/test/integration/targets/expect/aliases +++ b/test/integration/targets/expect/aliases @@ -1,3 +1,4 @@ shippable/posix/group2 destructive needs/target/setup_pexpect +gather_facts/no diff --git a/test/integration/targets/expect/tasks/main.yml b/test/integration/targets/expect/tasks/main.yml index f7431e19d14..77141c7dc41 100644 --- a/test/integration/targets/expect/tasks/main.yml +++ b/test/integration/targets/expect/tasks/main.yml @@ -117,7 +117,7 @@ - name: assert chdir works assert: that: - - "'{{chdir_result.stdout | trim}}' == '{{remote_tmp_dir_real_path.stdout | trim}}'" + - chdir_result.stdout | trim == remote_tmp_dir_real_path.stdout | trim - name: test timeout option expect: diff --git a/test/integration/targets/file/tasks/main.yml b/test/integration/targets/file/tasks/main.yml index 158fc3ec598..1446fd1f941 100644 --- a/test/integration/targets/file/tasks/main.yml +++ b/test/integration/targets/file/tasks/main.yml @@ -154,10 +154,10 @@ attributes_supported: yes when: - attribute_A_set is success - - attribute_A_set.stdout_lines + - attribute_A_set.stdout_lines is truthy - "'A' in attribute_A_set.stdout_lines[0].split()[0]" - attribute_A_unset is success - - attribute_A_unset.stdout_lines + - attribute_A_unset.stdout_lines is truthy - "'A' not in attribute_A_unset.stdout_lines[0].split()[0]" - name: explicitly set file attribute "A" @@ -930,7 +930,7 @@ that: - "file_error3 is failed" - "file_error3.msg == 'src does not exist'" - - "file_error3.dest == '{{ remote_tmp_dir_test }}/hard.txt' | expanduser" + - "file_error3.dest == remote_tmp_dir_test + '/hard.txt' | expanduser" - "file_error3.src == 'non-existing-file-that-does-not-exist.txt'" - block: diff --git a/test/integration/targets/file/tasks/state_link.yml b/test/integration/targets/file/tasks/state_link.yml index 1927f5e0ac3..40e1145cc88 100644 --- a/test/integration/targets/file/tasks/state_link.yml +++ b/test/integration/targets/file/tasks/state_link.yml @@ -200,7 +200,7 @@ - "missing_dst_no_follow_enable_force_use_mode2 is changed" - "missing_dst_no_follow_enable_force_use_mode3 is not changed" - "soft3_result['stat'].islnk" - - "soft3_result['stat'].lnk_target == '{{ user.home }}/nonexistent'" + - "soft3_result['stat'].lnk_target == user.home + '/nonexistent'" # # Test creating a link to a directory https://github.com/ansible/ansible/issues/1369 diff --git a/test/integration/targets/filter_core/aliases b/test/integration/targets/filter_core/aliases index 9f907740da5..4e6a0088ee8 100644 --- a/test/integration/targets/filter_core/aliases +++ b/test/integration/targets/filter_core/aliases @@ -1,2 +1,3 @@ shippable/posix/group4 setup/always/setup_passlib_controller # required for setup_test_user +destructive diff --git a/test/integration/targets/filter_core/tasks/main.yml b/test/integration/targets/filter_core/tasks/main.yml index 947fc6c2d26..445e66b56bf 100644 --- a/test/integration/targets/filter_core/tasks/main.yml +++ b/test/integration/targets/filter_core/tasks/main.yml @@ -106,8 +106,8 @@ - name: Test hash filter assert: that: - - '"{{ "hash" | hash("sha1") }}" == "2346ad27d7568ba9896f1b7da6b5991251debdf2"' - - '"{{ "café" | hash("sha1") }}" == "f424452a9673918c6f09b0cdd35b20be8e6ae7d7"' + - '"hash" | hash("sha1") == "2346ad27d7568ba9896f1b7da6b5991251debdf2"' + - '"café" | hash("sha1") == "f424452a9673918c6f09b0cdd35b20be8e6ae7d7"' - name: Test unsupported hash type debug: @@ -237,7 +237,8 @@ # but even though it's redundant with those unit tests, we do at least the most complicated example of the documentation here - "(default | combine(patch, recursive=True, list_merge='append_rp')) == result" - combine_fail is failed - - "combine_fail.msg == \"'recursive' and 'list_merge' are the only valid keyword arguments\"" + - | + "'recursive' and 'list_merge' are the only valid keyword arguments" is in combine_fail.msg - set_fact: combine: "{{[x, [y]] | combine(z)}}" @@ -247,7 +248,7 @@ - name: Ensure combining objects which aren't dictionaries throws an error assert: that: - - "result.msg.startswith(\"failed to combine variables, expected dicts but got\")" + - "'failed to combine variables, expected dicts but got' is in result.msg" - name: Ensure combining two dictionaries containing undefined variables provides a helpful error block: @@ -262,7 +263,8 @@ - assert: that: - - "result.msg.startswith('The task includes an option with an undefined variable')" + - | + result.msg is contains "'undef_variable' is undefined" - set_fact: combined: "{{ foo | combine({'key2': {'nested': [undef_variable]}})}}" @@ -271,7 +273,8 @@ - assert: that: - - "result.msg.startswith('The task includes an option with an undefined variable')" + - | + result.msg is contains "'undef_variable' is undefined" - name: regex_search set_fact: @@ -388,9 +391,9 @@ that: - '"]]^"|regex_escape(re_type="posix_basic") == "\\]\\]\\^"' - regex_escape_fail_1 is failed - - 'regex_escape_fail_1.msg == "Regex type (posix_extended) not yet implemented"' + - '"Regex type (posix_extended) not yet implemented" is in regex_escape_fail_1.msg' - regex_escape_fail_2 is failed - - 'regex_escape_fail_2.msg == "Invalid regex type (haha)"' + - '"Invalid regex type (haha)" is in regex_escape_fail_2.msg' - name: Verify from_yaml and from_yaml_all assert: @@ -517,11 +520,19 @@ - name: Verify mandatory assert: that: - - '{{mandatory_demo|mandatory}} == 123' + - mandatory_demo | mandatory == 123 - mandatory_1 is failed - "mandatory_1.msg == \"Mandatory variable 'hey' not defined.\"" - mandatory_2 is failed - - "mandatory_2.msg == 'You did not give me a variable. I am a sad wolf.'" + - mandatory_2.msg is contains "You did not give me a variable. I am a sad wolf." + +- name: Verify undef throws if resolved (default message) + set_fact: + foo: '{{ fail_foo }}' + vars: + fail_foo: '{{ undef() }}' + ignore_errors: yes + register: fail_default - name: Verify undef throws if resolved set_fact: @@ -552,7 +563,10 @@ - name: Verify undef assert: that: + - fail_default is failed + - fail_default.msg is contains('Mandatory variable has not been overridden') - fail_1 is failed + - fail_1.msg is contains('Expected failure') - not (fail_2 is failed) - not (fail_3 is failed) @@ -603,9 +617,9 @@ assert: that: - subelements_1 is failed - - 'subelements_1.msg == "obj must be a list of dicts or a nested dict"' + - '"obj must be a list of dicts or a nested dict" is in subelements_1.msg' - subelements_2 is failed - - '"subelements must be a list or a string" in subelements_2.msg' + - '"subelements must be a list or a string" is in subelements_2.msg' - 'subelements_demo|subelements("does not compute", skip_missing=True) == []' - subelements_3 is failed - '"could not find" in subelements_3.msg' @@ -706,7 +720,7 @@ that: - '"foo"|type_debug == "str"' -- name: Assert that a jinja2 filter that produces a map is auto unrolled +- name: Assert that a jinja2 filter that produces an iterable is auto unrolled assert: that: - thing|map(attribute="bar")|first == 123 diff --git a/test/integration/targets/filter_mathstuff/tasks/main.yml b/test/integration/targets/filter_mathstuff/tasks/main.yml index 33fcae823de..f6bab4f1d93 100644 --- a/test/integration/targets/filter_mathstuff/tasks/main.yml +++ b/test/integration/targets/filter_mathstuff/tasks/main.yml @@ -209,14 +209,14 @@ tags: human_to_bytes assert: that: - - "{{'0'|human_to_bytes}} == 0" - - "{{'0.1'|human_to_bytes}} == 0" - - "{{'0.9'|human_to_bytes}} == 1" - - "{{'1'|human_to_bytes}} == 1" - - "{{'10.00 KB'|human_to_bytes}} == 10240" - - "{{ '11 MB'|human_to_bytes}} == 11534336" - - "{{ '1.1 GB'|human_to_bytes}} == 1181116006" - - "{{'10.00 Kb'|human_to_bytes(isbits=True)}} == 10240" + - "'0'|human_to_bytes == 0" + - "'0.1'|human_to_bytes == 0" + - "'0.9'|human_to_bytes == 1" + - "'1'|human_to_bytes == 1" + - "'10.00 KB'|human_to_bytes == 10240" + - " '11 MB'|human_to_bytes == 11534336" + - " '1.1 GB'|human_to_bytes == 1181116006" + - "'10.00 Kb'|human_to_bytes(isbits=True) == 10240" - name: Verify human_to_bytes (bad string) set_fact: @@ -228,7 +228,7 @@ - name: Verify human_to_bytes (bad string) tags: human_to_bytes assert: - that: "{{_human_bytes_test.failed}}" + that: "_human_bytes_test.failed" - name: Verify that union can be chained tags: union @@ -236,7 +236,7 @@ unions: '{{ [1,2,3]|union([4,5])|union([6,7]) }}' assert: that: - - "unions|type_debug == 'list'" + - unions|type_debug == 'list' - "unions|length == 7" - name: Test union with unhashable item @@ -245,7 +245,7 @@ unions: '{{ [1,2,3]|union([{}]) }}' assert: that: - - "unions|type_debug == 'list'" + - unions|type_debug == 'list' - "unions|length == 4" - name: Verify rekey_on_member with invalid "duplicates" kwarg @@ -311,10 +311,4 @@ - assert: that: "test_var == 'test'" - assert: - that: "rekeyed == {'value': {'test': 'value'}}" - -# TODO: For some reason, the coverage tool isn't accounting for the last test -# so add another "last test" to fake it... -- assert: - that: - - true + that: "rekeyed == {'value': {'test': 'value'} }" diff --git a/test/integration/targets/filter_urls/tasks/main.yml b/test/integration/targets/filter_urls/tasks/main.yml index c062326c54e..9ae64785bbe 100644 --- a/test/integration/targets/filter_urls/tasks/main.yml +++ b/test/integration/targets/filter_urls/tasks/main.yml @@ -18,7 +18,3 @@ - "{'foo': 'bar'}|urlencode == 'foo=bar'" - "{'foo': 'bar', 'baz': 'buz'}|urlencode == 'foo=bar&baz=buz'" - "()|urlencode == ''" - -# Needed (temporarily) due to coverage reports not including the last task. -- assert: - that: true diff --git a/test/integration/targets/find/tasks/main.yml b/test/integration/targets/find/tasks/main.yml index ec028f9c48f..a2edc1123f1 100644 --- a/test/integration/targets/find/tasks/main.yml +++ b/test/integration/targets/find/tasks/main.yml @@ -336,7 +336,7 @@ - name: assert we skipped the ogg file assert: that: - - '"{{ remote_tmp_dir_test }}/e/f/g/h/8.ogg" not in find_test3_list' + - remote_tmp_dir_test + "/e/f/g/h/8.ogg" not in find_test3_list - name: patterns with regex find: @@ -386,7 +386,7 @@ assert: that: - result.matched == 1 - - '"{{ remote_tmp_dir_test }}/astest/old.txt" in astest_list' + - remote_tmp_dir_test + "/astest/old.txt" in astest_list - name: find files newer than 1 week find: @@ -401,7 +401,7 @@ assert: that: - result.matched == 1 - - '"{{ remote_tmp_dir_test }}/astest/new.txt" in astest_list' + - remote_tmp_dir_test + "/astest/new.txt" in astest_list - name: add some content to the new file shell: "echo hello world > {{ remote_tmp_dir_test }}/astest/new.txt" @@ -421,7 +421,7 @@ assert: that: - result.matched == 1 - - '"{{ remote_tmp_dir_test }}/astest/new.txt" in astest_list' + - remote_tmp_dir_test + "/astest/new.txt" in astest_list - '"checksum" in result.files[0]' - name: find ANY item with LESS than 5 bytes, also get checksums @@ -440,8 +440,8 @@ assert: that: - result.matched == 2 - - '"{{ remote_tmp_dir_test }}/astest/old.txt" in astest_list' - - '"{{ remote_tmp_dir_test }}/astest/.hidden.txt" in astest_list' + - remote_tmp_dir_test + "/astest/old.txt" in astest_list + - remote_tmp_dir_test + "/astest/.hidden.txt" in astest_list - '"checksum" in result.files[0]' # Test permission error is correctly handled by find module diff --git a/test/integration/targets/find/tasks/mode.yml b/test/integration/targets/find/tasks/mode.yml index 541bdfcba25..ba5a485c5ac 100644 --- a/test/integration/targets/find/tasks/mode.yml +++ b/test/integration/targets/find/tasks/mode.yml @@ -61,7 +61,7 @@ - assert: that: - exact_mode_0644.files == exact_mode_0644_symbolic.files - - exact_mode_0644.files[0].path == '{{ remote_tmp_dir_test }}/mode_0644' + - exact_mode_0644.files[0].path == remote_tmp_dir_test + '/mode_0644' - user_readable_octal.files == user_readable_symbolic.files - user_readable_octal.files|map(attribute='path')|map('basename')|sort == ['mode_0400', 'mode_0444', 'mode_0644', 'mode_0666', 'mode_0700'] - other_readable_octal.files == other_readable_symbolic.files diff --git a/test/integration/targets/gathering_facts/test_gathering_facts.yml b/test/integration/targets/gathering_facts/test_gathering_facts.yml index 47027e87175..faa187b73e1 100644 --- a/test/integration/targets/gathering_facts/test_gathering_facts.yml +++ b/test/integration/targets/gathering_facts/test_gathering_facts.yml @@ -433,7 +433,7 @@ - name: Test reading facts from default fact_path assert: that: - - '"{{ ansible_local.testfact.fact_dir }}" == "default"' + - 'ansible_local.testfact.fact_dir == "default"' - hosts: facthost9 tags: [ 'fact_local'] @@ -444,7 +444,7 @@ - name: Test reading facts from custom fact_path assert: that: - - '"{{ ansible_local.testfact.fact_dir }}" == "custom"' + - 'ansible_local.testfact.fact_dir == "custom"' - hosts: facthost20 tags: [ 'fact_facter_ohai' ] diff --git a/test/integration/targets/git/tasks/archive.yml b/test/integration/targets/git/tasks/archive.yml index f749de6979a..7fd53002826 100644 --- a/test/integration/targets/git/tasks/archive.yml +++ b/test/integration/targets/git/tasks/archive.yml @@ -118,5 +118,5 @@ - name: ARCHIVE | Assert that prefix directory is found assert: - that: '{{ item.matched == 1 }}' + that: item.matched == 1 with_items: "{{ archive_check.results }}" diff --git a/test/integration/targets/git/tasks/depth.yml b/test/integration/targets/git/tasks/depth.yml index 3573dfbd581..9f1332fcd5a 100644 --- a/test/integration/targets/git/tasks/depth.yml +++ b/test/integration/targets/git/tasks/depth.yml @@ -172,7 +172,7 @@ - name: DEPTH | check update arrived assert: that: - - "{{ a_file.content | b64decode | trim }} == 3" + - a_file.content | b64decode | int == 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 258aecc246e..57e3071007f 100644 --- a/test/integration/targets/git/tasks/localmods.yml +++ b/test/integration/targets/git/tasks/localmods.yml @@ -58,7 +58,7 @@ - name: LOCALMODS | check update arrived assert: that: - - "{{ a_file.content | b64decode | trim }} == 2" + - a_file.content | b64decode | int == 2 - git_fetch_force is changed - name: LOCALMODS | clear checkout_dir @@ -127,7 +127,7 @@ - name: LOCALMODS | check update arrived assert: that: - - "{{ a_file.content | b64decode | trim }} == 2" + - a_file.content | b64decode | int == 2 - git_fetch_force is changed - name: LOCALMODS | clear checkout_dir diff --git a/test/integration/targets/git/tasks/main.yml b/test/integration/targets/git/tasks/main.yml index c990251f335..228aaf01484 100644 --- a/test/integration/targets/git/tasks/main.yml +++ b/test/integration/targets/git/tasks/main.yml @@ -39,7 +39,7 @@ - include_tasks: gpg-verification.yml when: - not gpg_version.stderr - - gpg_version.stdout + - gpg_version.stdout is truthy - not (ansible_os_family == 'RedHat' and ansible_distribution_major_version is version('7', '<')) - import_tasks: localmods.yml - import_tasks: reset-origin.yml diff --git a/test/integration/targets/git/tasks/submodules.yml b/test/integration/targets/git/tasks/submodules.yml index 44d50df1f37..95247dbfac5 100644 --- a/test/integration/targets/git/tasks/submodules.yml +++ b/test/integration/targets/git/tasks/submodules.yml @@ -32,7 +32,7 @@ - name: SUBMODULES | Ensure submodule1 is at the appropriate commit assert: - that: '{{ submodule1.stdout_lines | length }} == 2' + that: submodule1.stdout_lines | length == 2 - name: SUBMODULES | clear checkout_dir file: @@ -53,7 +53,7 @@ - name: SUBMODULES | Ensure submodule1 is at the appropriate commit assert: - that: '{{ submodule1.stdout_lines | length }} == 4' + that: submodule1.stdout_lines | length == 4 - name: SUBMODULES | Copy the checkout so we can run several different tests on it command: 'cp -pr {{ checkout_dir }} {{ checkout_dir }}.bak' @@ -84,8 +84,8 @@ - name: SUBMODULES | Ensure both submodules are at the appropriate commit assert: that: - - '{{ submodule1.stdout_lines|length }} == 4' - - '{{ submodule2.stdout_lines|length }} == 2' + - submodule1.stdout_lines|length == 4 + - submodule2.stdout_lines|length == 2 - name: SUBMODULES | Remove checkout dir @@ -112,7 +112,7 @@ - name: SUBMODULES | Ensure submodule1 is at the appropriate commit assert: - that: '{{ submodule1.stdout_lines | length }} == 5' + that: submodule1.stdout_lines | length == 5 - name: SUBMODULES | Test that update with recursive found new submodules @@ -121,7 +121,7 @@ - name: SUBMODULES | Enusre submodule2 is at the appropriate commit assert: - that: '{{ submodule2.stdout_lines | length }} == 4' + that: submodule2.stdout_lines | length == 4 - name: SUBMODULES | clear checkout_dir file: @@ -147,4 +147,4 @@ - name: SUBMODULES | Ensure submodule1 is at the appropriate commit assert: - that: '{{ submodule1.stdout_lines | length }} == 4' + that: submodule1.stdout_lines | length == 4 diff --git a/test/integration/targets/group_by/test_group_by.yml b/test/integration/targets/group_by/test_group_by.yml index 07368dfe90e..8b1fcaf8bc6 100644 --- a/test/integration/targets/group_by/test_group_by.yml +++ b/test/integration/targets/group_by/test_group_by.yml @@ -135,20 +135,20 @@ gather_facts: false tasks: - name: check that alpaca matched all four groups - assert: { that: ["genus_vicugna", "genus_vic", "genus_vi", "genus_VICUGNA"] } + assert: { that: ["genus_vicugna is defined", "genus_vic is defined", "genus_vi is defined", "genus_VICUGNA is defined"] } - name: llama validation of groups hosts: llama gather_facts: false tasks: - name: check that llama matched all four groups - assert: { that: ["genus_lama", "genus_lam", "genus_la", "genus_LAMA"] } + assert: { that: ["genus_lama is defined", "genus_lam is defined", "genus_la is defined", "genus_LAMA is defined"] } - hosts: camel gather_facts: false tasks: - name: check that camel matched all four groups - assert: { that: ["genus_camelus", "genus_cam", "genus_ca", "genus_CAMELUS"] } + assert: { that: ["genus_camelus is defined", "genus_cam is defined", "genus_ca is defined", "genus_CAMELUS is defined"] } - hosts: vicugna gather_facts: false diff --git a/test/integration/targets/handlers/runme.sh b/test/integration/targets/handlers/runme.sh index 2250df28860..8a14be8f2bf 100755 --- a/test/integration/targets/handlers/runme.sh +++ b/test/integration/targets/handlers/runme.sh @@ -76,7 +76,7 @@ ansible-playbook test_multiple_handlers_with_recursive_notification.yml -i inven set +e result="$(ansible-playbook test_handlers_inexistent_notify.yml -i inventory.handlers "$@" 2>&1)" set -e -grep -q "ERROR! The requested handler 'notify_inexistent_handler' was not found in either the main handlers list nor in the listening handlers list" <<< "$result" +grep -q "The requested handler 'notify_inexistent_handler' was not found in either the main handlers list nor in the listening handlers list" <<< "$result" # Notify inexistent handlers without errors when ANSIBLE_ERROR_ON_MISSING_HANDLER=false ANSIBLE_ERROR_ON_MISSING_HANDLER=false ansible-playbook test_handlers_inexistent_notify.yml -i inventory.handlers -v "$@" @@ -116,19 +116,19 @@ ansible-playbook 58841.yml "$@" --tags evaluation_time -e test_var=myvar | tee o # Test the handler is not found when the variable is undefined ansible-playbook 58841.yml "$@" --tags evaluation_time 2>&1 | tee out.txt ; cat out.txt -grep out.txt -e "ERROR! The requested handler 'handler name with myvar' was not found" +grep out.txt -e "The requested handler 'handler name with myvar' was not found" grep out.txt -e "\[WARNING\]: Handler 'handler name with {{ test_var }}' is unusable" [ "$(grep out.txt -ce 'handler ran')" = "0" ] [ "$(grep out.txt -ce 'handler with var ran')" = "0" ] # Test include_role and import_role cannot be used as handlers ansible-playbook test_role_as_handler.yml "$@" 2>&1 | tee out.txt -grep out.txt -e "ERROR! Using 'include_role' as a handler is not supported." +grep out.txt -e "Using 'include_role' as a handler is not supported." # Test notifying a handler from within include_tasks does not work anymore ansible-playbook test_notify_included.yml "$@" 2>&1 | tee out.txt [ "$(grep out.txt -ce 'I was included')" = "1" ] -grep out.txt -e "ERROR! The requested handler 'handler_from_include' was not found in either the main handlers list nor in the listening handlers list" +grep out.txt -e "The requested handler 'handler_from_include' was not found in either the main handlers list nor in the listening handlers list" ansible-playbook test_handlers_meta.yml -i inventory.handlers -vv "$@" | tee out.txt [ "$(grep out.txt -ce 'RUNNING HANDLER \[noop_handler\]')" = "1" ] @@ -154,7 +154,7 @@ ansible-playbook include_handlers_fail_force.yml --force-handlers -i inventory.h [ "$(grep out.txt -ce 'included handler ran')" = "1" ] ansible-playbook test_flush_handlers_as_handler.yml -i inventory.handlers "$@" 2>&1 | tee out.txt -grep out.txt -e "ERROR! flush_handlers cannot be used as a handler" +grep out.txt -e "flush_handlers cannot be used as a handler" ansible-playbook test_skip_flush.yml -i inventory.handlers "$@" 2>&1 | tee out.txt [ "$(grep out.txt -ce 'handler ran')" = "0" ] @@ -178,13 +178,13 @@ grep out.txt -e "after flush" ansible-playbook 79776.yml -i inventory.handlers "$@" ansible-playbook test_block_as_handler.yml "$@" 2>&1 | tee out.txt -grep out.txt -e "ERROR! Using a block as a handler is not supported." +grep out.txt -e "Using a block as a handler is not supported." ansible-playbook test_block_as_handler-include.yml "$@" 2>&1 | tee out.txt -grep out.txt -e "ERROR! Using a block as a handler is not supported." +grep out.txt -e "Using a block as a handler is not supported." ansible-playbook test_block_as_handler-import.yml "$@" 2>&1 | tee out.txt -grep out.txt -e "ERROR! Using a block as a handler is not supported." +grep out.txt -e "Using a block as a handler is not supported." ansible-playbook test_include_role_handler_once.yml -i inventory.handlers "$@" 2>&1 | tee out.txt [ "$(grep out.txt -ce 'handler ran')" = "1" ] 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 bc63549808c..b9ad471b34d 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 @@ -16,11 +16,6 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . -- name: debug hash behaviour result - debug: - var: "{{ lookup('env', 'ANSIBLE_HASH_BEHAVIOUR') }}" - verbosity: 2 - - name: assert hash behaviour is merge or replace assert: that: diff --git a/test/integration/targets/hash/test_hash.yml b/test/integration/targets/hash/test_hash.yml index 37b56e655f4..2641fd7d17c 100644 --- a/test/integration/targets/hash/test_hash.yml +++ b/test/integration/targets/hash/test_hash.yml @@ -1,4 +1,5 @@ - hosts: testhost + gather_facts: no vars_files: - vars/test_hash_vars.yml vars: diff --git a/test/integration/targets/include_import/aliases b/test/integration/targets/include_import/aliases index 498fedd558e..2f98b8868f7 100644 --- a/test/integration/targets/include_import/aliases +++ b/test/integration/targets/include_import/aliases @@ -1,2 +1,3 @@ shippable/posix/group4 context/controller +gather_facts/no diff --git a/test/integration/targets/include_import/runme.sh b/test/integration/targets/include_import/runme.sh index 556844c3891..6b79c2e2175 100755 --- a/test/integration/targets/include_import/runme.sh +++ b/test/integration/targets/include_import/runme.sh @@ -3,6 +3,7 @@ set -eux export ANSIBLE_ROLES_PATH=./roles +export ANSIBLE_GATHERING=explicit function gen_task_files() { for i in $(printf "%03d " {1..39}); do @@ -80,7 +81,7 @@ ANSIBLE_STRATEGY='free' ansible-playbook undefined_var/playbook.yml -i inventor # include_ + apply (explicit inheritance) ANSIBLE_STRATEGY='linear' ansible-playbook apply/include_apply.yml -i inventory "$@" --tags foo set +e -OUT=$(ANSIBLE_STRATEGY='linear' ansible-playbook apply/import_apply.yml -i inventory "$@" --tags foo 2>&1 | grep 'ERROR! Invalid options for import_tasks: apply') +OUT=$(ANSIBLE_STRATEGY='linear' ansible-playbook apply/import_apply.yml -i inventory "$@" --tags foo 2>&1 | grep 'Invalid options for import_tasks: apply') set -e if [[ -z "$OUT" ]]; then echo "apply on import_tasks did not cause error" @@ -105,7 +106,7 @@ ANSIBLE_HOST_PATTERN_MISMATCH=warning ansible-playbook run_once/playbook.yml "$@ # https://github.com/ansible/ansible/issues/48936 ansible-playbook -v handler_addressing/playbook.yml 2>&1 | tee test_handler_addressing.out -test "$(grep -E -c 'include handler task|ERROR! The requested handler '"'"'do_import'"'"' was not found' test_handler_addressing.out)" = 2 +test "$(grep -E -c 'include handler task|The requested handler '"'"'do_import'"'"' was not found' test_handler_addressing.out)" = 2 # https://github.com/ansible/ansible/issues/49969 ansible-playbook -v parent_templating/playbook.yml 2>&1 | tee test_parent_templating.out diff --git a/test/integration/targets/include_import_tasks_nested/aliases b/test/integration/targets/include_import_tasks_nested/aliases index 1d28bdb2aa3..ea8d1627352 100644 --- a/test/integration/targets/include_import_tasks_nested/aliases +++ b/test/integration/targets/include_import_tasks_nested/aliases @@ -1,2 +1,3 @@ shippable/posix/group5 context/controller +gather_facts/no diff --git a/test/integration/targets/include_vars/aliases b/test/integration/targets/include_vars/aliases index 765b70da796..951eddf8b25 100644 --- a/test/integration/targets/include_vars/aliases +++ b/test/integration/targets/include_vars/aliases @@ -1 +1,2 @@ shippable/posix/group2 +gather_facts/no diff --git a/test/integration/targets/include_vars/tasks/main.yml b/test/integration/targets/include_vars/tasks/main.yml index 245916fa8b8..d96a2ddb50f 100644 --- a/test/integration/targets/include_vars/tasks/main.yml +++ b/test/integration/targets/include_vars/tasks/main.yml @@ -15,7 +15,7 @@ that: - "testing == 789" - "base_dir == 'environments/development'" - - "{{ included_one_file.ansible_included_var_files | length }} == 1" + - "included_one_file.ansible_included_var_files | length == 1" - "'vars/environments/development/all.yml' in included_one_file.ansible_included_var_files[0]" - name: include the vars/environments/development/all.yml and save results in all @@ -51,7 +51,7 @@ assert: that: - webapp_version is defined - - "'file_without_extension' in '{{ include_without_file_extension.ansible_included_var_files | join(' ') }}'" + - "'file_without_extension' in include_without_file_extension.ansible_included_var_files | join(' ')" - name: include every directory in vars include_vars: @@ -67,7 +67,7 @@ - "testing == 456" - "base_dir == 'services'" - "webapp_containers == 10" - - "{{ include_every_dir.ansible_included_var_files | length }} == 7" + - "include_every_dir.ansible_included_var_files | length == 7" - "'vars/all/all.yml' in include_every_dir.ansible_included_var_files[0]" - "'vars/environments/development/all.yml' in include_every_dir.ansible_included_var_files[1]" - "'vars/environments/development/services/webapp.yml' in include_every_dir.ansible_included_var_files[2]" @@ -88,9 +88,9 @@ that: - "testing == 789" - "base_dir == 'environments/development'" - - "{{ include_without_webapp.ansible_included_var_files | length }} == 4" - - "'webapp.yml' not in '{{ include_without_webapp.ansible_included_var_files | join(' ') }}'" - - "'file_without_extension' not in '{{ include_without_webapp.ansible_included_var_files | join(' ') }}'" + - "include_without_webapp.ansible_included_var_files | length == 4" + - "'webapp.yml' not in (include_without_webapp.ansible_included_var_files | join(' '))" + - "'file_without_extension' not in (include_without_webapp.ansible_included_var_files | join(' '))" - name: include only files matching webapp.yml include_vars: @@ -104,9 +104,9 @@ - "testing == 101112" - "base_dir == 'development/services'" - "webapp_containers == 20" - - "{{ include_match_webapp.ansible_included_var_files | length }} == 1" + - "include_match_webapp.ansible_included_var_files | length == 1" - "'vars/environments/development/services/webapp.yml' in include_match_webapp.ansible_included_var_files[0]" - - "'all.yml' not in '{{ include_match_webapp.ansible_included_var_files | join(' ') }}'" + - "'all.yml' not in (include_match_webapp.ansible_included_var_files | join(' '))" - name: include only files matching webapp.yml and store results in webapp include_vars: @@ -173,10 +173,10 @@ - name: Verify the hash variable assert: that: - - "{{ config | length }} == 3" + - "config | length == 3" - "config.key0 == 0" - "config.key1 == 0" - - "{{ config.key2 | length }} == 1" + - "config.key2 | length == 1" - "config.key2.a == 21" - name: Include the second file to merge the hash variable @@ -187,10 +187,10 @@ - name: Verify that the hash is merged assert: that: - - "{{ config | length }} == 4" + - "config | length == 4" - "config.key0 == 0" - "config.key1 == 1" - - "{{ config.key2 | length }} == 2" + - "config.key2 | length == 2" - "config.key2.a == 21" - "config.key2.b == 22" - "config.key3 == 3" @@ -202,9 +202,9 @@ - name: Verify that the properties from the first file is cleared assert: that: - - "{{ config | length }} == 3" + - "config | length == 3" - "config.key1 == 1" - - "{{ config.key2 | length }} == 1" + - "config.key2 | length == 1" - "config.key2.b == 22" - "config.key3 == 3" @@ -216,10 +216,10 @@ - name: Verify that the hash is merged after vars files are accumulated assert: that: - - "{{ config | length }} == 3" + - "config | length == 3" - "config.key0 is undefined" - "config.key1 == 1" - - "{{ config.key2 | length }} == 1" + - "config.key2 | length == 1" - "config.key2.b == 22" - "config.key3 == 3" diff --git a/test/integration/targets/includes/aliases b/test/integration/targets/includes/aliases index 1d28bdb2aa3..ea8d1627352 100644 --- a/test/integration/targets/includes/aliases +++ b/test/integration/targets/includes/aliases @@ -1,2 +1,3 @@ shippable/posix/group5 context/controller +gather_facts/no diff --git a/test/integration/targets/includes/runme.sh b/test/integration/targets/includes/runme.sh index 8622cf66534..97effac9cd8 100755 --- a/test/integration/targets/includes/runme.sh +++ b/test/integration/targets/includes/runme.sh @@ -2,6 +2,8 @@ set -eux +export ANSIBLE_GATHERING=explicit + ansible-playbook test_includes.yml -i ../../inventory "$@" ansible-playbook inherit_notify.yml "$@" @@ -10,7 +12,7 @@ echo "EXPECTED ERROR: Ensure we fail if using 'include' to include a playbook." set +e result="$(ansible-playbook -i ../../inventory include_on_playbook_should_fail.yml -v "$@" 2>&1)" set -e -grep -q "ERROR! 'include_tasks' is not a valid attribute for a Play" <<< "$result" +grep -q "'include_tasks' is not a valid attribute for a Play" <<< "$result" ansible-playbook includes_loop_rescue.yml --extra-vars strategy=linear "$@" ansible-playbook includes_loop_rescue.yml --extra-vars strategy=free "$@" diff --git a/test/integration/targets/inventory/inventory_plugins/constructed_with_hostvars.py b/test/integration/targets/inventory/inventory_plugins/constructed_with_hostvars.py index b8f53334136..bd77d4048c8 100644 --- a/test/integration/targets/inventory/inventory_plugins/constructed_with_hostvars.py +++ b/test/integration/targets/inventory/inventory_plugins/constructed_with_hostvars.py @@ -13,7 +13,6 @@ DOCUMENTATION = """ """ from ansible.errors import AnsibleParserError -from ansible.module_utils.common.text.converters import to_native from ansible.plugins.inventory import BaseInventoryPlugin, Constructable @@ -39,5 +38,5 @@ class InventoryModule(BaseInventoryPlugin, Constructable): # constructed groups based variable values self._add_host_to_keyed_groups(self.get_option('keyed_groups'), hostvars, host, strict=strict, fetch_hostvars=True) - except Exception as e: - raise AnsibleParserError("failed to parse %s: %s " % (to_native(path), to_native(e)), orig_exc=e) + except Exception as ex: + raise AnsibleParserError(f"Failed to parse {path}.") from ex diff --git a/test/integration/targets/inventory/runme.sh b/test/integration/targets/inventory/runme.sh index 8dcac402995..c33fd11f477 100755 --- a/test/integration/targets/inventory/runme.sh +++ b/test/integration/targets/inventory/runme.sh @@ -42,7 +42,7 @@ ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS=always ansible-playbook -i ../../inventory ANSIBLE_TRANSFORM_INVALID_GROUP_CHARS=never ansible-playbook -i ../../inventory "$@" strategy.yml # test extra vars -ansible-inventory -i testhost, -i ./extra_vars_constructed.yml --list -e 'from_extras=hey ' "$@"|grep '"example": "hellohey"' +ansible-inventory -i testhost, -i ./extra_vars_constructed.yml --list -e 'from_extras=hey ' "$@"|grep ': "hellohey"' # test host vars from previous inventory sources ansible-inventory -i ./inv_with_host_vars.yml -i ./host_vars_constructed.yml --graph "$@" | tee out.txt @@ -107,6 +107,7 @@ fi # ensure we don't traceback on inventory due to variables with int as key ansible-inventory -i inv_with_int.yml --list "$@" + # test in subshell relative paths work mid play for extra vars in inventory refresh { cd 1/2 diff --git a/test/integration/targets/inventory_constructed/constructed.yml b/test/integration/targets/inventory_constructed/constructed.yml index be02858f1b4..c1ccdfcad04 100644 --- a/test/integration/targets/inventory_constructed/constructed.yml +++ b/test/integration/targets/inventory_constructed/constructed.yml @@ -1,4 +1,5 @@ plugin: ansible.builtin.constructed +strict: True keyed_groups: - key: hostvar0 - key: hostvar1 diff --git a/test/integration/targets/inventory_constructed/runme.sh b/test/integration/targets/inventory_constructed/runme.sh index 91bbd66bdef..91af1874ebe 100755 --- a/test/integration/targets/inventory_constructed/runme.sh +++ b/test/integration/targets/inventory_constructed/runme.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -eux +set -eux -o pipefail ansible-inventory -i static_inventory.yml -i constructed.yml --graph | tee out.txt diff --git a/test/integration/targets/inventory_script/aliases b/test/integration/targets/inventory_script/aliases index b59832142f2..3feb031bf5c 100644 --- a/test/integration/targets/inventory_script/aliases +++ b/test/integration/targets/inventory_script/aliases @@ -1 +1,2 @@ shippable/posix/group3 +gather_facts/no diff --git a/test/integration/targets/inventory_yaml/runme.sh b/test/integration/targets/inventory_yaml/runme.sh index a8818dd99bb..a642703f52d 100755 --- a/test/integration/targets/inventory_yaml/runme.sh +++ b/test/integration/targets/inventory_yaml/runme.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash +set -eux -o pipefail + # handle empty/commented out group keys correctly https://github.com/ansible/ansible/issues/47254 -ANSIBLE_VERBOSITY=0 diff -w <(ansible-inventory -i ./test.yml --list) success.json +ANSIBLE_VERBOSITY=0 diff --unified -w <(ansible-inventory -i ./test.yml --list) success.json ansible-inventory -i ./test_int_hostname.yml --list 2>&1 | grep 'Host pattern 1234 must be a string' diff --git a/test/integration/targets/inventory_yaml/success.json b/test/integration/targets/inventory_yaml/success.json index a8b15f96c34..6cb31fc69d1 100644 --- a/test/integration/targets/inventory_yaml/success.json +++ b/test/integration/targets/inventory_yaml/success.json @@ -29,30 +29,30 @@ "popular": false } } - }, + }, "all": { "children": [ - "cousins", - "kids", - "the-maid", - "ungrouped" + "ungrouped", + "kids", + "cousins", + "the-maid" ] - }, + }, "cousins": { "children": [ "redheads" ] - }, + }, "kids": { "hosts": [ - "bobby", - "cindy", - "greg", - "jan", - "marcia", - "peter" + "marcia", + "jan", + "cindy", + "greg", + "peter", + "bobby" ] - }, + }, "the-maid": { "hosts": [ "alice" diff --git a/test/integration/targets/jinja2_native_types/test_casting.yml b/test/integration/targets/jinja2_native_types/test_casting.yml index 5e9c76d628c..dfa86603a97 100644 --- a/test/integration/targets/jinja2_native_types/test_casting.yml +++ b/test/integration/targets/jinja2_native_types/test_casting.yml @@ -14,18 +14,18 @@ - assert: that: - int_to_str == "'2'" - - 'int_to_str|type_debug in ["str", "unicode"]' + - int_to_str | type_debug == "str" - 'int_to_str2 == "2"' - - 'int_to_str2|type_debug in ["NativeJinjaText"]' - 'str_to_int == 2' - - 'str_to_int|type_debug == "int"' - - 'dict_to_str|type_debug in ["str", "unicode"]' - - 'list_to_str|type_debug in ["str", "unicode"]' + - str_to_int|type_debug == "int" + - dict_to_str|type_debug == "str" + - list_to_str|type_debug == "str" - 'int_to_bool is sameas true' - 'int_to_bool|type_debug == "bool"' - 'str_true_to_bool is sameas true' - 'str_true_to_bool|type_debug == "bool"' - 'str_false_to_bool is sameas false' - 'str_false_to_bool|type_debug == "bool"' - - 'list_to_json_str|type_debug in ["NativeJinjaText"]' - - 'list_to_yaml_str|type_debug in ["NativeJinjaText"]' + - | + list_to_json_str == '["one", "two"]' + - 'list_to_yaml_str == "[one, two]\n"' diff --git a/test/integration/targets/jinja2_native_types/test_concatentation.yml b/test/integration/targets/jinja2_native_types/test_concatentation.yml index 24a90381e12..1c2817ed8e9 100644 --- a/test/integration/targets/jinja2_native_types/test_concatentation.yml +++ b/test/integration/targets/jinja2_native_types/test_concatentation.yml @@ -5,7 +5,7 @@ - assert: that: - 'integer_sum == 3' - - 'integer_sum|type_debug == "int"' + - integer_sum|type_debug == "int" - name: add casted string and int set_fact: @@ -14,7 +14,6 @@ - assert: that: - 'integer_sum2 == 3' - - 'integer_sum2|type_debug == "int"' - name: concatenate int and string set_fact: @@ -23,7 +22,6 @@ - assert: that: - string_sum == "'12'" - - 'string_sum|type_debug in ["str", "unicode"]' - name: add two lists set_fact: @@ -32,7 +30,6 @@ - assert: that: - 'list_sum == ["one", "two", "three", "four"]' - - 'list_sum|type_debug == "list"' - name: add two lists, multi expression set_fact: @@ -40,7 +37,8 @@ - assert: that: - - 'list_sum_multi|type_debug in ["str", "unicode"]' + - | + list_sum_multi == "['one', 'two'] + ['three', 'four']" - name: add two dicts set_fact: @@ -58,7 +56,6 @@ - assert: that: - 'list_for_strings == "onetwo"' - - 'list_for_strings|type_debug in ["str", "unicode"]' - name: loop through list with int set_fact: @@ -67,7 +64,6 @@ - assert: that: - 'list_for_int == 1' - - 'list_for_int|type_debug == "int"' - name: loop through list with ints set_fact: @@ -75,8 +71,7 @@ - assert: that: - - 'list_for_ints == 42' - - 'list_for_ints|type_debug == "int"' + - 'list_for_ints | int == 42' - name: loop through list to create a new list set_fact: diff --git a/test/integration/targets/jinja2_native_types/test_none.yml b/test/integration/targets/jinja2_native_types/test_none.yml index 1d26154c711..076311d5013 100644 --- a/test/integration/targets/jinja2_native_types/test_none.yml +++ b/test/integration/targets/jinja2_native_types/test_none.yml @@ -5,7 +5,7 @@ - assert: that: - - 'none_var is sameas none' - - 'none_var|type_debug == "NoneType"' - - 'none_var_direct is sameas none' - - 'none_var_direct|type_debug == "NoneType"' + - none_var is sameas none + - none_var|type_debug == "NoneType" + - none_var_direct is sameas none + - none_var_direct|type_debug == "NoneType" diff --git a/test/integration/targets/lookup-option-name/aliases b/test/integration/targets/lookup-option-name/aliases index 498fedd558e..2f98b8868f7 100644 --- a/test/integration/targets/lookup-option-name/aliases +++ b/test/integration/targets/lookup-option-name/aliases @@ -1,2 +1,3 @@ shippable/posix/group4 context/controller +gather_facts/no diff --git a/test/integration/targets/lookup_csvfile/tasks/main.yml b/test/integration/targets/lookup_csvfile/tasks/main.yml index 0279f55981b..2ce12311eb9 100644 --- a/test/integration/targets/lookup_csvfile/tasks/main.yml +++ b/test/integration/targets/lookup_csvfile/tasks/main.yml @@ -53,6 +53,9 @@ - lookup('csvfile', 'Jane', file='people.csv', delimiter=',', col=0, keycol=1) == "Smith" - lookup('csvfile', 'German von Lastname file=people.csv delimiter=, col=1') == "Demo" +- debug: + msg: output {{ lookup('csvfile', 'fruit', file='tabs.csv', delimiter='TAB', col=1) }} + - name: Check tab-separated file assert: that: diff --git a/test/integration/targets/lookup_env/runme.sh b/test/integration/targets/lookup_env/runme.sh index 698d6bfa8cd..6d23f4b0489 100755 --- a/test/integration/targets/lookup_env/runme.sh +++ b/test/integration/targets/lookup_env/runme.sh @@ -1,6 +1,6 @@ #!/bin/sh -set -ex +set -eux unset USR # this should succeed and return 'nobody' as var is undefined diff --git a/test/integration/targets/lookup_first_found/tasks/main.yml b/test/integration/targets/lookup_first_found/tasks/main.yml index 9a4d134e383..f818ea740d5 100644 --- a/test/integration/targets/lookup_first_found/tasks/main.yml +++ b/test/integration/targets/lookup_first_found/tasks/main.yml @@ -109,8 +109,8 @@ - name: Load variables specific for OS family assert: that: - - "{{item|quote}} is file" - - "{{item|basename == 'itworks.yml'}}" + - item is file + - item|basename == 'itworks.yml' with_first_found: - files: - "{{ansible_id}}-{{ansible_lsb.major_release}}.yml" # invalid var, should be skipped @@ -124,8 +124,8 @@ - name: Load variables specific for OS family, but now as list of dicts, same options as above assert: that: - - "{{item|quote}} is file" - - "{{item|basename == 'itworks.yml'}}" + - item is file + - item|basename == 'itworks.yml' with_first_found: - files: - "{{ansible_id}}-{{ansible_lsb.major_release}}.yml" diff --git a/test/integration/targets/lookup_indexed_items/aliases b/test/integration/targets/lookup_indexed_items/aliases index 3005e4b26d0..4d41cf4af0d 100644 --- a/test/integration/targets/lookup_indexed_items/aliases +++ b/test/integration/targets/lookup_indexed_items/aliases @@ -1 +1,2 @@ shippable/posix/group4 +gather_facts/no diff --git a/test/integration/targets/lookup_ini/test_lookup_properties.yml b/test/integration/targets/lookup_ini/test_lookup_properties.yml index a6fc0f7d7c2..ed347600922 100644 --- a/test/integration/targets/lookup_ini/test_lookup_properties.yml +++ b/test/integration/targets/lookup_ini/test_lookup_properties.yml @@ -10,7 +10,7 @@ field_with_space: "{{lookup('ini', 'field.with.space type=properties file=lookup.properties')}}" - assert: - that: "{{item}} is defined" + that: "item is defined" with_items: [ 'test1', 'test2', 'test_dot', 'field_with_space' ] - name: "read ini value" diff --git a/test/integration/targets/lookup_sequence/tasks/main.yml b/test/integration/targets/lookup_sequence/tasks/main.yml index 5090ae92bbd..18b55ffdfd1 100644 --- a/test/integration/targets/lookup_sequence/tasks/main.yml +++ b/test/integration/targets/lookup_sequence/tasks/main.yml @@ -76,10 +76,8 @@ - assert: that: - ansible_failed_task.name == "EXPECTED FAILURE - test invalid arg" - - ansible_failed_result.msg in [expected1, expected2] - vars: - expected1: "unrecognized arguments to with_sequence: ['junk']" - expected2: "unrecognized arguments to with_sequence: [u'junk']" + - '"unrecognized arguments to with_sequence: " in ansible_failed_result.msg' + - '"junk" in ansible_failed_result.msg' - block: - name: EXPECTED FAILURE - test bad kv value @@ -144,7 +142,7 @@ - assert: that: - ansible_failed_task.name == "EXPECTED FAILURE - test no count or end" - - ansible_failed_result.msg == "must specify count or end in with_sequence" + - ansible_failed_result.msg is contains "must specify count or end in with_sequence" - block: - name: EXPECTED FAILURE - test both count and end @@ -157,7 +155,7 @@ - assert: that: - ansible_failed_task.name == "EXPECTED FAILURE - test both count and end" - - ansible_failed_result.msg == "can't specify both count and end in with_sequence" + - ansible_failed_result.msg is contains "can't specify both count and end in with_sequence" - block: - name: EXPECTED FAILURE - test count backwards message @@ -170,7 +168,7 @@ - assert: that: - ansible_failed_task.name == "EXPECTED FAILURE - test count backwards message" - - ansible_failed_result.msg == "to count backwards make stride negative" + - ansible_failed_result.msg is contains "to count backwards make stride negative" - block: - name: EXPECTED FAILURE - test count forward message @@ -183,7 +181,7 @@ - assert: that: - ansible_failed_task.name == "EXPECTED FAILURE - test count forward message" - - ansible_failed_result.msg == "to count forward don't make stride negative" + - ansible_failed_result.msg is contains "to count forward don't make stride negative" - block: - name: EXPECTED FAILURE - test bad format string message @@ -196,7 +194,7 @@ - assert: that: - ansible_failed_task.name == "EXPECTED FAILURE - test bad format string message" - - ansible_failed_result.msg == expected + - ansible_failed_result.msg is contains expected vars: expected: "bad formatting string: d" diff --git a/test/integration/targets/lookup_subelements/tasks/main.yml b/test/integration/targets/lookup_subelements/tasks/main.yml index 9d93cf20963..7885347bb23 100644 --- a/test/integration/targets/lookup_subelements/tasks/main.yml +++ b/test/integration/targets/lookup_subelements/tasks/main.yml @@ -133,7 +133,7 @@ - assert: that: - - "'{{ item.0.name }}' != 'carol'" + - "item.0.name != 'carol'" with_subelements: - "{{ users }}" - mysql.privs @@ -220,5 +220,5 @@ - assert: that: - - "'{{ user_alice }}' == 'localhost'" - - "'{{ user_bob }}' == 'db1'" + - "user_alice == 'localhost'" + - "user_bob == 'db1'" diff --git a/test/integration/targets/lookup_together/tasks/main.yml b/test/integration/targets/lookup_together/tasks/main.yml index 115c9e5213a..03da4546c43 100644 --- a/test/integration/targets/lookup_together/tasks/main.yml +++ b/test/integration/targets/lookup_together/tasks/main.yml @@ -26,4 +26,4 @@ - assert: that: - ansible_failed_task.name == "EXPECTED FAILURE - test empty list" - - ansible_failed_result.msg == "with_together requires at least one element in each list" + - ansible_failed_result.msg is contains "with_together requires at least one element in each list" diff --git a/test/integration/targets/lookup_url/tasks/main.yml b/test/integration/targets/lookup_url/tasks/main.yml index d69ae5b5b5a..c69868f4a84 100644 --- a/test/integration/targets/lookup_url/tasks/main.yml +++ b/test/integration/targets/lookup_url/tasks/main.yml @@ -1,6 +1,6 @@ - name: Test that retrieving a url works set_fact: - web_data: "{{ lookup('url', 'https://' ~ httpbin_host ~ '/get?one') }}" + web_data: "{{ lookup('url', 'https://' ~ httpbin_host ~ '/get?one') | from_json }}" - name: Assert that the url was retrieved assert: @@ -39,7 +39,7 @@ block: - name: Test user agent set_fact: - web_data: "{{ lookup('url', 'https://' ~ httpbin_host ~ '/user-agent') }}" + web_data: "{{ lookup('url', 'https://' ~ httpbin_host ~ '/user-agent') | from_json }}" - name: Assert that user agent is set assert: @@ -51,7 +51,7 @@ block: - name: Test force basic auth set_fact: - web_data: "{{ lookup('url', 'https://' ~ httpbin_host ~ '/headers', username='abc') }}" + web_data: "{{ lookup('url', 'https://' ~ httpbin_host ~ '/headers', username='abc') | from_json }}" - name: Assert that Authorization header is set assert: diff --git a/test/integration/targets/lookup_url/tasks/use_netrc.yml b/test/integration/targets/lookup_url/tasks/use_netrc.yml index 0dc6d60273d..517c46e3c95 100644 --- a/test/integration/targets/lookup_url/tasks/use_netrc.yml +++ b/test/integration/targets/lookup_url/tasks/use_netrc.yml @@ -10,7 +10,7 @@ - name: test Url lookup with netrc forced Basic auth set_fact: - web_data: "{{ lookup('ansible.builtin.url', 'https://' ~ httpbin_host ~ '/basic-auth/foo/bar', headers={'Authorization':'Bearer foobar'}) }}" + web_data: "{{ lookup('ansible.builtin.url', 'https://' ~ httpbin_host ~ '/basic-auth/foo/bar', headers={'Authorization':'Bearer foobar'}) | from_json }}" - name: assert test Url lookup with netrc forced Basic auth assert: @@ -19,7 +19,7 @@ - name: test Url lookup with use_netrc=False set_fact: - web_data: "{{ lookup('ansible.builtin.url', 'https://' ~ httpbin_host ~ '/bearer', headers={'Authorization':'Bearer foobar'}, use_netrc='False') }}" + web_data: "{{ lookup('ansible.builtin.url', 'https://' ~ httpbin_host ~ '/bearer', headers={'Authorization':'Bearer foobar'}, use_netrc='False') | from_json }}" - name: assert test Url lookup with netrc=False used Bearer authentication assert: diff --git a/test/integration/targets/lookup_varnames/tasks/main.yml b/test/integration/targets/lookup_varnames/tasks/main.yml index fec3efd536f..9aa76a1d86f 100644 --- a/test/integration/targets/lookup_varnames/tasks/main.yml +++ b/test/integration/targets/lookup_varnames/tasks/main.yml @@ -9,13 +9,13 @@ - name: Try various regexes and make sure they work assert: that: - - lookup('varnames', '^qz_.+', wantlist=True) == ['qz_1', 'qz_2'] - - lookup('varnames', '^qz_.+', '^qa.*', wantlist=True) == ['qz_1', 'qz_2', 'qa_1'] - - "'ansible_python_interpreter' in lookup('varnames', '^ansible_.*', wantlist=True)" + - lookup('varnames', '^qz_.+', wantlist=True) | sort == ['qz_1', 'qz_2'] + - lookup('varnames', '^qz_.+', '^qa.*', wantlist=True) | sort == ['qa_1', 'qz_1', 'qz_2'] + - lookup('varnames', '^ansible_.*', wantlist=True) is contains "ansible_python_interpreter" - lookup('varnames', '^doesnotexist.*', wantlist=True) == [] - lookup('varnames', '^doesnotexist.*', '.*python_inter.*', wantlist=True) == ['ansible_python_interpreter'] - - lookup('varnames', '^q.*_\d', wantlist=True) == ['qz_1', 'qz_2', 'qa_1'] - - lookup('varnames', '^q.*_\d') == 'qz_1,qz_2,qa_1' + - lookup('varnames', '^q.*_\d', wantlist=True) | sort == ['qa_1', 'qz_1', 'qz_2'] + - lookup('varnames', '^q.*_\d') is search('(?=.*qa_1)(?=.*qz_1)(?=.*qz_2)') - name: Make sure it fails successfully set_fact: diff --git a/test/integration/targets/loop_control/inner.yml b/test/integration/targets/loop_control/inner.yml index 1c286fa4607..976f196102d 100644 --- a/test/integration/targets/loop_control/inner.yml +++ b/test/integration/targets/loop_control/inner.yml @@ -3,7 +3,7 @@ that: - ansible_loop.index == ansible_loop.index0 + 1 - ansible_loop.revindex == ansible_loop.revindex0 + 1 - - ansible_loop.first == {{ ansible_loop.index == 1 }} - - ansible_loop.last == {{ ansible_loop.index == ansible_loop.length }} + - ansible_loop.first == (ansible_loop.index == 1) + - ansible_loop.last == (ansible_loop.index == ansible_loop.length) - ansible_loop.length == 3 - ansible_loop.allitems|join(',') == 'first,second,third' diff --git a/test/integration/targets/loops/aliases b/test/integration/targets/loops/aliases index 498fedd558e..2f98b8868f7 100644 --- a/test/integration/targets/loops/aliases +++ b/test/integration/targets/loops/aliases @@ -1,2 +1,3 @@ shippable/posix/group4 context/controller +gather_facts/no diff --git a/test/integration/targets/module_defaults/tasks/main.yml b/test/integration/targets/module_defaults/tasks/main.yml index 04832785ec4..d55ed8d1ad7 100644 --- a/test/integration/targets/module_defaults/tasks/main.yml +++ b/test/integration/targets/module_defaults/tasks/main.yml @@ -3,7 +3,7 @@ test_file: /tmp/ansible-test.module_defaults.foo module_defaults: debug: - msg: test default + msg: test {{ "default" }} file: path: '{{ test_file }}' block: 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 f4bd264957f..7d5119cccb0 100644 --- a/test/integration/targets/module_precedence/modules_test_multiple_roles.yml +++ b/test/integration/targets/module_precedence/modules_test_multiple_roles.yml @@ -14,4 +14,4 @@ - assert: that: - '"location" in result' - - 'result["location"] == "{{ expected_location}}"' + - result["location"] == expected_location 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 5403ae238c2..d8936fdbac2 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 @@ -13,4 +13,4 @@ - assert: that: - '"location" in result' - - 'result["location"] == "{{ expected_location}}"' + - result["location"] == expected_location diff --git a/test/integration/targets/module_precedence/multiple_roles/bar/tasks/main.yml b/test/integration/targets/module_precedence/multiple_roles/bar/tasks/main.yml index 52c34020130..b978f115179 100644 --- a/test/integration/targets/module_precedence/multiple_roles/bar/tasks/main.yml +++ b/test/integration/targets/module_precedence/multiple_roles/bar/tasks/main.yml @@ -7,4 +7,4 @@ assert: that: - '"location" in result' - - 'result["location"] == "{{ expected_location }}"' + - result["location"] == expected_location diff --git a/test/integration/targets/module_precedence/multiple_roles/foo/tasks/main.yml b/test/integration/targets/module_precedence/multiple_roles/foo/tasks/main.yml index 52c34020130..b978f115179 100644 --- a/test/integration/targets/module_precedence/multiple_roles/foo/tasks/main.yml +++ b/test/integration/targets/module_precedence/multiple_roles/foo/tasks/main.yml @@ -7,4 +7,4 @@ assert: that: - '"location" in result' - - 'result["location"] == "{{ expected_location }}"' + - result["location"] == expected_location diff --git a/test/integration/targets/module_utils_facts.system.selinux/tasks/main.yml b/test/integration/targets/module_utils_facts.system.selinux/tasks/main.yml index 7687223115f..983ccf6a9f3 100644 --- a/test/integration/targets/module_utils_facts.system.selinux/tasks/main.yml +++ b/test/integration/targets/module_utils_facts.system.selinux/tasks/main.yml @@ -23,7 +23,7 @@ - set_fact: selinux_policytype: "{{ r.stdout_lines[0] | trim }}" - when: r is success and r.stdout_lines + when: r is success and r.stdout_lines is truthy - assert: that: diff --git a/test/integration/targets/ping/aliases b/test/integration/targets/ping/aliases index 765b70da796..951eddf8b25 100644 --- a/test/integration/targets/ping/aliases +++ b/test/integration/targets/ping/aliases @@ -1 +1,2 @@ shippable/posix/group2 +gather_facts/no diff --git a/test/integration/targets/playbook/runme.sh b/test/integration/targets/playbook/runme.sh index cc8d4957332..bf4f1769b54 100755 --- a/test/integration/targets/playbook/runme.sh +++ b/test/integration/targets/playbook/runme.sh @@ -21,42 +21,42 @@ echo "EXPECTED ERROR: Ensure we fail properly if a play has both user and remote set +e result="$(ansible-playbook -i ../../inventory remote_user_and_user.yml -v "$@" 2>&1)" set -e -grep -q "ERROR! both 'user' and 'remote_user' are set for this play." <<< "$result" +grep -q "both 'user' and 'remote_user' are set for this play." <<< "$result" # test that playbook errors if len(plays) == 0 echo "EXPECTED ERROR: Ensure we fail properly if a playbook is an empty list." set +e result="$(ansible-playbook -i ../../inventory empty.yml -v "$@" 2>&1)" set -e -grep -q "ERROR! A playbook must contain at least one play" <<< "$result" +grep -q "A playbook must contain at least one play" <<< "$result" # test that play errors if len(hosts) == 0 echo "EXPECTED ERROR: Ensure we fail properly if a play has 0 hosts." set +e result="$(ansible-playbook -i ../../inventory empty_hosts.yml -v "$@" 2>&1)" set -e -grep -q "ERROR! Hosts list cannot be empty. Please check your playbook" <<< "$result" +grep -q "Hosts list cannot be empty. Please check your playbook" <<< "$result" # test that play errors if tasks is malformed echo "EXPECTED ERROR: Ensure we fail properly if tasks is malformed." set +e result="$(ansible-playbook -i ../../inventory malformed_tasks.yml -v "$@" 2>&1)" set -e -grep -q "ERROR! A malformed block was encountered while loading tasks: 123 should be a list or None" <<< "$result" +grep -q "A malformed block was encountered while loading tasks: 123 should be a list or None" <<< "$result" # test that play errors if pre_tasks is malformed echo "EXPECTED ERROR: Ensure we fail properly if pre_tasks is malformed." set +e result="$(ansible-playbook -i ../../inventory malformed_pre_tasks.yml -v "$@" 2>&1)" set -e -grep -q "ERROR! A malformed block was encountered while loading pre_tasks" <<< "$result" +grep -q "A malformed block was encountered while loading pre_tasks" <<< "$result" # test that play errors if post_tasks is malformed echo "EXPECTED ERROR: Ensure we fail properly if post_tasks is malformed." set +e result="$(ansible-playbook -i ../../inventory malformed_post_tasks.yml -v "$@" 2>&1)" set -e -grep -q "ERROR! A malformed block was encountered while loading post_tasks" <<< "$result" +grep -q "A malformed block was encountered while loading post_tasks" <<< "$result" # test roles: null -- it gets converted to [] internally ansible-playbook -i ../../inventory roles_null.yml -v "$@" @@ -66,21 +66,21 @@ echo "EXPECTED ERROR: Ensure we fail properly if roles is malformed." set +e result="$(ansible-playbook -i ../../inventory malformed_roles.yml -v "$@" 2>&1)" set -e -grep -q "ERROR! A malformed role declaration was encountered." <<< "$result" +grep -q "A malformed role declaration was encountered." <<< "$result" # test roles: ["foo,bar"] -- errors about old style echo "EXPECTED ERROR: Ensure we fail properly if old style role is given." set +e result="$(ansible-playbook -i ../../inventory old_style_role.yml -v "$@" 2>&1)" set -e -grep -q "ERROR! Invalid old style role requirement: foo,bar" <<< "$result" +grep -q "Invalid old style role requirement: foo,bar" <<< "$result" # test vars prompt that has no name echo "EXPECTED ERROR: Ensure we fail properly if vars_prompt has no name." set +e result="$(ansible-playbook -i ../../inventory malformed_vars_prompt.yml -v "$@" 2>&1)" set -e -grep -q "ERROR! Invalid vars_prompt data structure, missing 'name' key" <<< "$result" +grep -q "Invalid vars_prompt data structure, missing 'name' key" <<< "$result" # test vars_prompt: null ansible-playbook -i ../../inventory vars_prompt_null.yml -v "$@" diff --git a/test/integration/targets/plugin_config_for_inventory/aliases b/test/integration/targets/plugin_config_for_inventory/aliases index 1d28bdb2aa3..ea8d1627352 100644 --- a/test/integration/targets/plugin_config_for_inventory/aliases +++ b/test/integration/targets/plugin_config_for_inventory/aliases @@ -1,2 +1,3 @@ shippable/posix/group5 context/controller +gather_facts/no diff --git a/test/integration/targets/plugin_namespace/tasks/main.yml b/test/integration/targets/plugin_namespace/tasks/main.yml index 19bdd3a0eb8..c671dc02d36 100644 --- a/test/integration/targets/plugin_namespace/tasks/main.yml +++ b/test/integration/targets/plugin_namespace/tasks/main.yml @@ -6,6 +6,6 @@ - assert: that: # filter names are prefixed with a unique hash value to prevent shadowing of other plugins - - filter_name | regex_search('^ansible\.plugins\.filter\.[0-9]+_test_filter$') + - filter_name | regex_search('^ansible\.plugins\.filter\.[0-9]+_test_filter$') is truthy - lookup_name == 'ansible.plugins.lookup.lookup_name' - test_name_ok diff --git a/test/integration/targets/register/runme.sh b/test/integration/targets/register/runme.sh index 8957096852b..54198738ccd 100755 --- a/test/integration/targets/register/runme.sh +++ b/test/integration/targets/register/runme.sh @@ -9,4 +9,4 @@ ansible-playbook can_register.yml -i ../../inventory -v "$@" set +e result="$(ansible-playbook invalid.yml -i ../../inventory -v "$@" 2>&1)" set -e -grep -q "Invalid variable name in " <<< "${result}" +grep -q "Invalid variable name" <<< "${result}" diff --git a/test/integration/targets/result_pickle_error/action_plugins/result_pickle_error.py b/test/integration/targets/result_pickle_error/action_plugins/result_pickle_error.py index 50871b42b06..a65b36cffd1 100644 --- a/test/integration/targets/result_pickle_error/action_plugins/result_pickle_error.py +++ b/test/integration/targets/result_pickle_error/action_plugins/result_pickle_error.py @@ -4,11 +4,13 @@ from __future__ import annotations +import typing as t + from ansible.plugins.action import ActionBase class CannotBePickled: - def __getstate__(self): + def __getstate__(self) -> t.NoReturn: raise Exception('pickle intentionally not supported') diff --git a/test/integration/targets/result_pickle_error/runme.yml b/test/integration/targets/result_pickle_error/runme.yml index 605084985f4..bddb372f67a 100644 --- a/test/integration/targets/result_pickle_error/runme.yml +++ b/test/integration/targets/result_pickle_error/runme.yml @@ -4,4 +4,4 @@ - include_role: name: result_pickle_error # Just for caution loop 3 times to ensure no issues - loop: '{{ range(3) }}' + loop: '{{ range(3) | list }}' diff --git a/test/integration/targets/roles_arg_spec/test.yml b/test/integration/targets/roles_arg_spec/test.yml index 26beb210554..4c3ff5cced4 100644 --- a/test/integration/targets/roles_arg_spec/test.yml +++ b/test/integration/targets/roles_arg_spec/test.yml @@ -392,7 +392,8 @@ # We expect the role to actually run, but will fail because an undefined variable was referenced # and validation wasn't performed up front (thus not returning 'argument_errors'). - "'argument_errors' not in ansible_failed_result" - - "'The task includes an option with an undefined variable.' in ansible_failed_result.msg" + - | + ansible_failed_result.msg is contains "'c_int' is undefined" - name: "New play to reset vars: Test collection-based role" hosts: localhost diff --git a/test/integration/targets/script/tasks/main.yml b/test/integration/targets/script/tasks/main.yml index 59dc6eb2407..9eed2ce9947 100644 --- a/test/integration/targets/script/tasks/main.yml +++ b/test/integration/targets/script/tasks/main.yml @@ -209,7 +209,7 @@ assert: that: - _check_mode_test2 is skipped - - '_check_mode_test2.msg == "{{ remote_tmp_dir_test | expanduser }}/afile2.txt exists, matching creates option"' + - '_check_mode_test2.msg == (remote_tmp_dir_test | expanduser) + "/afile2.txt exists, matching creates option"' - name: Remove afile2.txt file: @@ -231,7 +231,7 @@ assert: that: - _check_mode_test3 is skipped - - '_check_mode_test3.msg == "{{ remote_tmp_dir_test | expanduser }}/afile2.txt does not exist, matching removes option"' + - '_check_mode_test3.msg == (remote_tmp_dir_test | expanduser) + "/afile2.txt does not exist, matching removes option"' # executable diff --git a/test/integration/targets/setup_cron/tasks/main.yml b/test/integration/targets/setup_cron/tasks/main.yml index 90f3085df15..599013097a1 100644 --- a/test/integration/targets/setup_cron/tasks/main.yml +++ b/test/integration/targets/setup_cron/tasks/main.yml @@ -18,11 +18,11 @@ - name: install cron package package: name: '{{ cron_pkg }}' - when: cron_pkg | default(false, true) + when: cron_pkg | default(false, true) is truthy register: cron_package_installed until: cron_package_installed is success -- when: faketime_pkg | default(false, true) +- when: faketime_pkg | default(false, true) is truthy block: - name: install faketime packages package: diff --git a/test/integration/targets/slurp/tasks/main.yml b/test/integration/targets/slurp/tasks/main.yml index 939859415ac..283b06a73e5 100644 --- a/test/integration/targets/slurp/tasks/main.yml +++ b/test/integration/targets/slurp/tasks/main.yml @@ -29,11 +29,11 @@ - name: check slurp existing result assert: that: - - 'slurp_existing.content' - - 'slurp_existing.encoding == "base64"' - - 'slurp_existing is not changed' - - 'slurp_existing is not failed' - - '"{{ slurp_existing.content | b64decode }}" == "We are at the café"' + - slurp_existing.content is truthy + - slurp_existing.encoding == "base64" + - slurp_existing is not changed + - slurp_existing is not failed + - slurp_existing.content | b64decode == "We are at the café" - name: Create a binary file to test with copy: @@ -49,10 +49,10 @@ - name: check slurp result of binary assert: that: - - "slurp_binary.content" - - "slurp_binary.encoding == 'base64'" - - "slurp_binary is not changed" - - "slurp_binary is not failed" + - slurp_binary.content is truthy + - slurp_binary.encoding == 'base64' + - slurp_binary is not changed + - slurp_binary is not failed - name: test slurp with missing argument action: slurp @@ -62,8 +62,8 @@ - name: check slurp with missing argument result assert: that: - - "slurp_no_args is failed" - - "slurp_no_args.msg" - - "slurp_no_args is not changed" + - slurp_no_args is failed + - slurp_no_args.msg is truthy + - slurp_no_args is not changed - import_tasks: test_unreadable.yml diff --git a/test/integration/targets/special_vars/aliases b/test/integration/targets/special_vars/aliases index 0010517586c..560955db2be 100644 --- a/test/integration/targets/special_vars/aliases +++ b/test/integration/targets/special_vars/aliases @@ -1,3 +1,4 @@ shippable/posix/group4 needs/target/include_parent_role_vars context/controller +gather_facts/no diff --git a/test/integration/targets/subversion/roles/subversion/tasks/setup.yml b/test/integration/targets/subversion/roles/subversion/tasks/setup.yml index 52729d5b994..8bdd7ef4e4d 100644 --- a/test/integration/targets/subversion/roles/subversion/tasks/setup.yml +++ b/test/integration/targets/subversion/roles/subversion/tasks/setup.yml @@ -22,7 +22,7 @@ name: '{{ upgrade_packages }}' state: latest when: - - upgrade_packages | default([]) + - upgrade_packages | default([]) is truthy - name: create SVN home folder file: diff --git a/test/integration/targets/systemd/tasks/main.yml b/test/integration/targets/systemd/tasks/main.yml index 9444c13d2af..fcf98ec29a9 100644 --- a/test/integration/targets/systemd/tasks/main.yml +++ b/test/integration/targets/systemd/tasks/main.yml @@ -66,7 +66,7 @@ - assert: that: - result is failed - - 'result is search("Could not find the requested service {{ fake_service }}")' + - result is search("Could not find the requested service " + fake_service) - name: the module must fail in check_mode as well when a service is not found systemd: @@ -79,7 +79,7 @@ - assert: that: - result is failed - - 'result is search("Could not find the requested service {{ fake_service }}")' + - result is search("Could not find the requested service " + fake_service) - name: check that the module works even when systemd is offline (eg in chroot) systemd: diff --git a/test/integration/targets/systemd/tasks/test_systemd_version.yml b/test/integration/targets/systemd/tasks/test_systemd_version.yml index 2b2fae167c8..2039d6fbd19 100644 --- a/test/integration/targets/systemd/tasks/test_systemd_version.yml +++ b/test/integration/targets/systemd/tasks/test_systemd_version.yml @@ -6,6 +6,6 @@ - name: Assert the systemd version fact ansible.builtin.assert: that: - - ansible_systemd.version | int + - ansible_systemd.version | int > 0 - ansible_systemd.version is match('^[1-9][0-9][0-9]$') - - ansible_systemd.features | regex_search('(\\+|-)(PAM|AUDIT)') + - ansible_systemd.features | regex_search('(\\+|-)(PAM|AUDIT)') is not none diff --git a/test/integration/targets/tags/ansible_run_tags.yml b/test/integration/targets/tags/ansible_run_tags.yml index 0e965ad2533..7b889ff569d 100644 --- a/test/integration/targets/tags/ansible_run_tags.yml +++ b/test/integration/targets/tags/ansible_run_tags.yml @@ -15,7 +15,7 @@ - assert: that: - - ansible_run_tags == ['all'] + - ansible_run_tags|sort == ['all'] when: expect == 'all' tags: - always @@ -29,7 +29,7 @@ - assert: that: - - ansible_run_tags == ['untagged'] + - ansible_run_tags|sort == ['untagged'] when: expect == 'untagged' tags: - always @@ -43,7 +43,7 @@ - assert: that: - - ansible_run_tags == ['tagged'] + - ansible_run_tags|sort == ['tagged'] when: expect == 'tagged' tags: - always diff --git a/test/integration/targets/template/tasks/main.yml b/test/integration/targets/template/tasks/main.yml index 36f85b8b791..55eb55c9dda 100644 --- a/test/integration/targets/template/tasks/main.yml +++ b/test/integration/targets/template/tasks/main.yml @@ -19,14 +19,6 @@ - set_fact: output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}" -- name: show python interpreter - debug: - msg: "{{ ansible_python['executable'] }}" - -- name: show jinja2 version - debug: - msg: "{{ lookup('pipe', ansible_python.executable ~ ' -c \"import jinja2; print(jinja2.__version__)\"') }}" - - name: get default group shell: id -gn register: group @@ -357,7 +349,7 @@ - assert: that: - "\"foo t'e~m\\plated\" in unusual_results.stdout_lines" - - "{{unusual_results.stdout_lines| length}} == 1" + - "unusual_results.stdout_lines| length == 1" - name: check that the unusual filename can be checked for changes template: @@ -715,8 +707,7 @@ - name: check that proper error message is emitted when in operator is used assert: that: - - '"The task includes an option with an undefined variable" in error.msg' - - "\"'y' is undefined\n\n\" in error.msg" + - error.msg is contains "'y' is undefined" - template: src: template_import_macro_globals.j2 @@ -732,8 +723,9 @@ # aliases file requires root for template tests so this should be safe - import_tasks: backup_test.yml -- name: test STRING_TYPE_FILTERS +- name: ensure that Jinja preserves types previously eaten by repr/eval literal collisions copy: + # setting indent_value is how we're sure the output JSON string was preserved as a string instead of a repr of the dict content: "{{ a_dict | to_nice_json(indent=(indent_value|int))}}\n" dest: "{{ output_dir }}/string_type_filters.templated" vars: @@ -758,11 +750,9 @@ src: empty_template.j2 dest: "{{ output_dir }}/empty_template.templated" -- assert: - that: - - test - vars: - test: "{{ lookup('file', output_dir ~ '/empty_template.templated')|length == 0 }}" +- name: assert empty template contents + assert: + that: lookup('file', output_dir + '/empty_template.templated')|length == 0 - name: test jinja2 override without colon throws proper error block: diff --git a/test/integration/targets/template/undefined_in_import.yml b/test/integration/targets/template/undefined_in_import.yml index 62f60d6687c..b3eed507a65 100644 --- a/test/integration/targets/template/undefined_in_import.yml +++ b/test/integration/targets/template/undefined_in_import.yml @@ -1,11 +1,11 @@ - hosts: localhost gather_facts: false tasks: - - debug: - msg: "{{ lookup('template', 'undefined_in_import.j2') }}" + - raw: echo {{ lookup('template', 'undefined_in_import.j2') }} ignore_errors: true register: res - assert: that: - - "\"'undefined_variable' is undefined\" in res.msg" + - res.failed + - res.msg is contains("'undefined_variable' is undefined") diff --git a/test/integration/targets/templating/aliases b/test/integration/targets/templating/aliases index 8278ec8bcc7..0712f145f72 100644 --- a/test/integration/targets/templating/aliases +++ b/test/integration/targets/templating/aliases @@ -1,2 +1,3 @@ shippable/posix/group3 context/controller +gather_facts/no diff --git a/test/integration/targets/unarchive/tasks/test_missing_binaries.yml b/test/integration/targets/unarchive/tasks/test_missing_binaries.yml index 8d9256e78ce..f1caa4265cc 100644 --- a/test/integration/targets/unarchive/tasks/test_missing_binaries.yml +++ b/test/integration/targets/unarchive/tasks/test_missing_binaries.yml @@ -66,7 +66,7 @@ - zip_success.changed # Verify that file list is generated - "'files' in zip_success" - - "{{zip_success['files']| length}} == 3" + - zip_success['files'] | length == 3 - "'foo-unarchive.txt' in zip_success['files']" - "'foo-unarchive-777.txt' in zip_success['files']" - "'FOO-UNAR.TXT' in zip_success['files']" diff --git a/test/integration/targets/unarchive/tasks/test_mode.yml b/test/integration/targets/unarchive/tasks/test_mode.yml index 9e8b14c8b28..e4cd601f934 100644 --- a/test/integration/targets/unarchive/tasks/test_mode.yml +++ b/test/integration/targets/unarchive/tasks/test_mode.yml @@ -131,7 +131,7 @@ - "unarchive08_stat.stat.mode == '0601'" # Verify that file list is generated - "'files' in unarchive08" - - "{{unarchive08['files']| length}} == 3" + - unarchive08['files']| length == 3 - "'foo-unarchive.txt' in unarchive08['files']" - "'foo-unarchive-777.txt' in unarchive08['files']" - "'FOO-UNAR.TXT' in unarchive08['files']" @@ -163,7 +163,7 @@ - "unarchive08_stat.stat.mode == '0601'" # Verify that file list is generated - "'files' in unarchive08" - - "{{unarchive08['files']| length}} == 3" + - unarchive08['files']| length == 3 - "'foo-unarchive.txt' in unarchive08['files']" - "'foo-unarchive-777.txt' in unarchive08['files']" - "'FOO-UNAR.TXT' in unarchive08['files']" diff --git a/test/integration/targets/unarchive/tasks/test_unprivileged_user.yml b/test/integration/targets/unarchive/tasks/test_unprivileged_user.yml index 8ee1db49e40..2a5cb8f803c 100644 --- a/test/integration/targets/unarchive/tasks/test_unprivileged_user.yml +++ b/test/integration/targets/unarchive/tasks/test_unprivileged_user.yml @@ -40,7 +40,7 @@ - unarchive10 is changed # Verify that file list is generated - "'files' in unarchive10" - - "{{unarchive10['files']| length}} == 1" + - unarchive10['files']| length == 1 - "'foo-unarchive.txt' in unarchive10['files']" - archive_path.stat.exists diff --git a/test/integration/targets/unarchive/tasks/test_zip.yml b/test/integration/targets/unarchive/tasks/test_zip.yml index cf03946fcdf..52de9cd2847 100644 --- a/test/integration/targets/unarchive/tasks/test_zip.yml +++ b/test/integration/targets/unarchive/tasks/test_zip.yml @@ -17,7 +17,7 @@ - "unarchive03.changed == true" # Verify that file list is generated - "'files' in unarchive03" - - "{{unarchive03['files']| length}} == 3" + - unarchive03['files'] | length == 3 - "'foo-unarchive.txt' in unarchive03['files']" - "'foo-unarchive-777.txt' in unarchive03['files']" - "'FOO-UNAR.TXT' in unarchive03['files']" diff --git a/test/integration/targets/uri/tasks/main.yml b/test/integration/targets/uri/tasks/main.yml index f51bcede4a1..9c8f110e684 100644 --- a/test/integration/targets/uri/tasks/main.yml +++ b/test/integration/targets/uri/tasks/main.yml @@ -227,7 +227,7 @@ - name: Assert location header assert: that: - - 'result.location|default("") == "https://{{ httpbin_host }}/relative-redirect/1"' + - 'result.location|default("") == "https://" + httpbin_host + "/relative-redirect/1"' - name: Check SSL with redirect uri: @@ -237,7 +237,7 @@ - name: Assert SSL with redirect assert: that: - - 'result.url|default("") == "https://{{ httpbin_host }}/get"' + - 'result.url|default("") == "https://" + httpbin_host + "/get"' - name: redirect to bad SSL site uri: @@ -475,7 +475,7 @@ body: integer_value: 1 register: multipart_invalid - failed_when: 'multipart_invalid.msg != "failed to parse body as form-multipart: value must be a string, or mapping, cannot be type int"' + failed_when: '"failed to parse body as form-multipart: value must be a string, or mapping, cannot be type" not in multipart_invalid.msg' - name: Validate invalid method uri: diff --git a/test/integration/targets/uri/tasks/redirect-all.yml b/test/integration/targets/uri/tasks/redirect-all.yml index d5b47a1c410..2dc6b70296c 100644 --- a/test/integration/targets/uri/tasks/redirect-all.yml +++ b/test/integration/targets/uri/tasks/redirect-all.yml @@ -12,7 +12,7 @@ - http_301_head.json is not defined - http_301_head.redirected == true - http_301_head.status == 200 - - http_301_head.url == 'https://{{ httpbin_host }}/anything' + - http_301_head.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 301 using GET uri: @@ -27,10 +27,10 @@ - http_301_get is successful - http_301_get.json.data == '' - http_301_get.json.method == 'GET' - - http_301_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_301_get.json.url == 'https://' + httpbin_host + '/anything' - http_301_get.redirected == true - http_301_get.status == 200 - - http_301_get.url == 'https://{{ httpbin_host }}/anything' + - http_301_get.url == 'https://' + httpbin_host + '/anything' # NOTE: The HTTP POST turns into an HTTP GET - name: Test HTTP 301 using POST @@ -48,10 +48,10 @@ - http_301_post is successful - http_301_post.json.data == '' - http_301_post.json.method == 'GET' - - http_301_post.json.url == 'https://{{ httpbin_host }}/anything' + - http_301_post.json.url == 'https://' + httpbin_host + '/anything' - http_301_post.redirected == true - http_301_post.status == 200 - - http_301_post.url == 'https://{{ httpbin_host }}/anything' + - http_301_post.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 302 using HEAD uri: @@ -67,7 +67,7 @@ - http_302_head.json is not defined - http_302_head.redirected == true - http_302_head.status == 200 - - http_302_head.url == 'https://{{ httpbin_host }}/anything' + - http_302_head.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 302 using GET uri: @@ -82,10 +82,10 @@ - http_302_get is successful - http_302_get.json.data == '' - http_302_get.json.method == 'GET' - - http_302_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_302_get.json.url == 'https://' + httpbin_host + '/anything' - http_302_get.redirected == true - http_302_get.status == 200 - - http_302_get.url == 'https://{{ httpbin_host }}/anything' + - http_302_get.url == 'https://' + httpbin_host + '/anything' # NOTE: The HTTP POST turns into an HTTP GET - name: Test HTTP 302 using POST @@ -103,10 +103,10 @@ - http_302_post is successful - http_302_post.json.data == '' - http_302_post.json.method == 'GET' - - http_302_post.json.url == 'https://{{ httpbin_host }}/anything' + - http_302_post.json.url == 'https://' + httpbin_host + '/anything' - http_302_post.redirected == true - http_302_post.status == 200 - - http_302_post.url == 'https://{{ httpbin_host }}/anything' + - http_302_post.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 303 using HEAD uri: @@ -122,7 +122,7 @@ - http_303_head.json is not defined - http_303_head.redirected == true - http_303_head.status == 200 - - http_303_head.url == 'https://{{ httpbin_host }}/anything' + - http_303_head.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 303 using GET uri: @@ -137,10 +137,10 @@ - http_303_get is successful - http_303_get.json.data == '' - http_303_get.json.method == 'GET' - - http_303_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_303_get.json.url == 'https://' + httpbin_host + '/anything' - http_303_get.redirected == true - http_303_get.status == 200 - - http_303_get.url == 'https://{{ httpbin_host }}/anything' + - http_303_get.url == 'https://' + httpbin_host + '/anything' # NOTE: The HTTP POST turns into an HTTP GET - name: Test HTTP 303 using POST @@ -158,10 +158,10 @@ - http_303_post is successful - http_303_post.json.data == '' - http_303_post.json.method == 'GET' - - http_303_post.json.url == 'https://{{ httpbin_host }}/anything' + - http_303_post.json.url == 'https://' + httpbin_host + '/anything' - http_303_post.redirected == true - http_303_post.status == 200 - - http_303_post.url == 'https://{{ httpbin_host }}/anything' + - http_303_post.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 307 using HEAD uri: @@ -177,7 +177,7 @@ - http_307_head.json is not defined - http_307_head.redirected == true - http_307_head.status == 200 - - http_307_head.url == 'https://{{ httpbin_host }}/anything' + - http_307_head.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 307 using GET uri: @@ -192,10 +192,10 @@ - http_307_get is successful - http_307_get.json.data == '' - http_307_get.json.method == 'GET' - - http_307_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_307_get.json.url == 'https://' + httpbin_host + '/anything' - http_307_get.redirected == true - http_307_get.status == 200 - - http_307_get.url == 'https://{{ httpbin_host }}/anything' + - http_307_get.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 307 using POST uri: @@ -212,10 +212,10 @@ - http_307_post is successful - http_307_post.json.json.foo == 'bar' - http_307_post.json.method == 'POST' - - http_307_post.json.url == 'https://{{ httpbin_host }}/anything' + - http_307_post.json.url == 'https://' + httpbin_host + '/anything' - http_307_post.redirected == true - http_307_post.status == 200 - - http_307_post.url == 'https://{{ httpbin_host }}/anything' + - http_307_post.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 308 using HEAD uri: @@ -231,7 +231,7 @@ - http_308_head.json is undefined - http_308_head.redirected == true - http_308_head.status == 200 - - http_308_head.url == 'https://{{ httpbin_host }}/anything' + - http_308_head.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 308 using GET uri: @@ -246,10 +246,10 @@ - http_308_get is successful - http_308_get.json.data == '' - http_308_get.json.method == 'GET' - - http_308_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_308_get.json.url == 'https://' + httpbin_host + '/anything' - http_308_get.redirected == true - http_308_get.status == 200 - - http_308_get.url == 'https://{{ httpbin_host }}/anything' + - http_308_get.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 308 using POST uri: @@ -266,7 +266,7 @@ - http_308_post is successful - http_308_post.json.json.foo == 'bar' - http_308_post.json.method == 'POST' - - http_308_post.json.url == 'https://{{ httpbin_host }}/anything' + - http_308_post.json.url == 'https://' + httpbin_host + '/anything' - http_308_post.redirected == true - http_308_post.status == 200 - - http_308_post.url == 'https://{{ httpbin_host }}/anything' + - http_308_post.url == 'https://' + httpbin_host + '/anything' diff --git a/test/integration/targets/uri/tasks/redirect-none.yml b/test/integration/targets/uri/tasks/redirect-none.yml index 060950d2320..c9a5cd240e8 100644 --- a/test/integration/targets/uri/tasks/redirect-none.yml +++ b/test/integration/targets/uri/tasks/redirect-none.yml @@ -11,11 +11,11 @@ that: - http_301_head is failure - http_301_head.json is not defined - - http_301_head.location == 'https://{{ httpbin_host }}/anything' + - http_301_head.location == 'https://' + httpbin_host + '/anything' - "http_301_head.msg == 'Status code was 301 and not [200]: HTTP Error 301: MOVED PERMANENTLY'" - http_301_head.redirected == false - http_301_head.status == 301 - - http_301_head.url == 'https://{{ httpbin_host }}/redirect-to?status_code=301&url=https://{{ httpbin_host }}/anything' + - http_301_head.url == 'https://' + httpbin_host + '/redirect-to?status_code=301&url=https://' + httpbin_host + '/anything' - name: Test HTTP 301 using GET uri: @@ -30,11 +30,11 @@ that: - http_301_get is failure - http_301_get.json is not defined - - http_301_get.location == 'https://{{ httpbin_host }}/anything' + - http_301_get.location == 'https://' + httpbin_host + '/anything' - "http_301_get.msg == 'Status code was 301 and not [200]: HTTP Error 301: MOVED PERMANENTLY'" - http_301_get.redirected == false - http_301_get.status == 301 - - http_301_get.url == 'https://{{ httpbin_host }}/redirect-to?status_code=301&url=https://{{ httpbin_host }}/anything' + - http_301_get.url == 'https://' + httpbin_host + '/redirect-to?status_code=301&url=https://' + httpbin_host + '/anything' - name: Test HTTP 301 using POST uri: @@ -51,11 +51,11 @@ that: - http_301_post is failure - http_301_post.json is not defined - - http_301_post.location == 'https://{{ httpbin_host }}/anything' + - http_301_post.location == 'https://' + httpbin_host + '/anything' - "http_301_post.msg == 'Status code was 301 and not [200]: HTTP Error 301: MOVED PERMANENTLY'" - http_301_post.redirected == false - http_301_post.status == 301 - - http_301_post.url == 'https://{{ httpbin_host }}/redirect-to?status_code=301&url=https://{{ httpbin_host }}/anything' + - http_301_post.url == 'https://' + httpbin_host + '/redirect-to?status_code=301&url=https://' + httpbin_host + '/anything' - name: Test HTTP 302 using HEAD uri: @@ -70,11 +70,11 @@ that: - http_302_head is failure - http_302_head.json is not defined - - http_302_head.location == 'https://{{ httpbin_host }}/anything' + - http_302_head.location == 'https://' + httpbin_host + '/anything' - "http_302_head.msg == 'Status code was 302 and not [200]: HTTP Error 302: FOUND'" - http_302_head.redirected == false - http_302_head.status == 302 - - http_302_head.url == 'https://{{ httpbin_host }}/redirect-to?status_code=302&url=https://{{ httpbin_host }}/anything' + - http_302_head.url == 'https://' + httpbin_host + '/redirect-to?status_code=302&url=https://' + httpbin_host + '/anything' - name: Test HTTP 302 using GET uri: @@ -89,11 +89,11 @@ that: - http_302_get is failure - http_302_get.json is not defined - - http_302_get.location == 'https://{{ httpbin_host }}/anything' + - http_302_get.location == 'https://' + httpbin_host + '/anything' - "http_302_get.msg == 'Status code was 302 and not [200]: HTTP Error 302: FOUND'" - http_302_get.redirected == false - http_302_get.status == 302 - - http_302_get.url == 'https://{{ httpbin_host }}/redirect-to?status_code=302&url=https://{{ httpbin_host }}/anything' + - http_302_get.url == 'https://' + httpbin_host + '/redirect-to?status_code=302&url=https://' + httpbin_host + '/anything' - name: Test HTTP 302 using POST uri: @@ -110,11 +110,11 @@ that: - http_302_post is failure - http_302_post.json is not defined - - http_302_post.location == 'https://{{ httpbin_host }}/anything' + - http_302_post.location == 'https://' + httpbin_host + '/anything' - "http_302_post.msg == 'Status code was 302 and not [200]: HTTP Error 302: FOUND'" - http_302_post.redirected == false - http_302_post.status == 302 - - http_302_post.url == 'https://{{ httpbin_host }}/redirect-to?status_code=302&url=https://{{ httpbin_host }}/anything' + - http_302_post.url == 'https://' + httpbin_host + '/redirect-to?status_code=302&url=https://' + httpbin_host + '/anything' - name: Test HTTP 303 using HEAD uri: @@ -129,11 +129,11 @@ that: - http_303_head is failure - http_303_head.json is not defined - - http_303_head.location == 'https://{{ httpbin_host }}/anything' + - http_303_head.location == 'https://' + httpbin_host + '/anything' - "http_303_head.msg == 'Status code was 303 and not [200]: HTTP Error 303: SEE OTHER'" - http_303_head.redirected == false - http_303_head.status == 303 - - http_303_head.url == 'https://{{ httpbin_host }}/redirect-to?status_code=303&url=https://{{ httpbin_host }}/anything' + - http_303_head.url == 'https://' + httpbin_host + '/redirect-to?status_code=303&url=https://' + httpbin_host + '/anything' - name: Test HTTP 303 using GET uri: @@ -148,11 +148,11 @@ that: - http_303_get is failure - http_303_get.json is not defined - - http_303_get.location == 'https://{{ httpbin_host }}/anything' + - http_303_get.location == 'https://' + httpbin_host + '/anything' - "http_303_get.msg == 'Status code was 303 and not [200]: HTTP Error 303: SEE OTHER'" - http_303_get.redirected == false - http_303_get.status == 303 - - http_303_get.url == 'https://{{ httpbin_host }}/redirect-to?status_code=303&url=https://{{ httpbin_host }}/anything' + - http_303_get.url == 'https://' + httpbin_host + '/redirect-to?status_code=303&url=https://' + httpbin_host + '/anything' - name: Test HTTP 303 using POST uri: @@ -169,11 +169,11 @@ that: - http_303_post is failure - http_303_post.json is not defined - - http_303_post.location == 'https://{{ httpbin_host }}/anything' + - http_303_post.location == 'https://' + httpbin_host + '/anything' - "http_303_post.msg == 'Status code was 303 and not [200]: HTTP Error 303: SEE OTHER'" - http_303_post.redirected == false - http_303_post.status == 303 - - http_303_post.url == 'https://{{ httpbin_host }}/redirect-to?status_code=303&url=https://{{ httpbin_host }}/anything' + - http_303_post.url == 'https://' + httpbin_host + '/redirect-to?status_code=303&url=https://' + httpbin_host + '/anything' - name: Test HTTP 307 using HEAD uri: @@ -188,11 +188,11 @@ that: - http_307_head is failure - http_307_head.json is not defined - - http_307_head.location == 'https://{{ httpbin_host }}/anything' + - http_307_head.location == 'https://' + httpbin_host + '/anything' - "http_307_head.msg == 'Status code was 307 and not [200]: HTTP Error 307: TEMPORARY REDIRECT'" - http_307_head.redirected == false - http_307_head.status == 307 - - http_307_head.url == 'https://{{ httpbin_host }}/redirect-to?status_code=307&url=https://{{ httpbin_host }}/anything' + - http_307_head.url == 'https://' + httpbin_host + '/redirect-to?status_code=307&url=https://' + httpbin_host + '/anything' - name: Test HTTP 307 using GET uri: @@ -207,11 +207,11 @@ that: - http_307_get is failure - http_307_get.json is not defined - - http_307_get.location == 'https://{{ httpbin_host }}/anything' + - http_307_get.location == 'https://' + httpbin_host + '/anything' - "http_307_get.msg == 'Status code was 307 and not [200]: HTTP Error 307: TEMPORARY REDIRECT'" - http_307_get.redirected == false - http_307_get.status == 307 - - http_307_get.url == 'https://{{ httpbin_host }}/redirect-to?status_code=307&url=https://{{ httpbin_host }}/anything' + - http_307_get.url == 'https://' + httpbin_host + '/redirect-to?status_code=307&url=https://' + httpbin_host + '/anything' - name: Test HTTP 307 using POST uri: @@ -228,11 +228,11 @@ that: - http_307_post is failure - http_307_post.json is not defined - - http_307_post.location == 'https://{{ httpbin_host }}/anything' + - http_307_post.location == 'https://' + httpbin_host + '/anything' - "http_307_post.msg == 'Status code was 307 and not [200]: HTTP Error 307: TEMPORARY REDIRECT'" - http_307_post.redirected == false - http_307_post.status == 307 - - http_307_post.url == 'https://{{ httpbin_host }}/redirect-to?status_code=307&url=https://{{ httpbin_host }}/anything' + - http_307_post.url == 'https://' + httpbin_host + '/redirect-to?status_code=307&url=https://' + httpbin_host + '/anything' # NOTE: This is a bug, fixed in https://github.com/ansible/ansible/pull/36809 - name: Test HTTP 308 using HEAD @@ -248,11 +248,11 @@ that: - http_308_head is failure - http_308_head.json is not defined - - http_308_head.location == 'https://{{ httpbin_host }}/anything' + - http_308_head.location == 'https://' + httpbin_host + '/anything' - "'Status code was 308 and not [200]: HTTP Error 308: ' in http_308_head.msg" - http_308_head.redirected == false - http_308_head.status == 308 - - http_308_head.url == 'https://{{ httpbin_host }}/redirect-to?status_code=308&url=https://{{ httpbin_host }}/anything' + - http_308_head.url == 'https://' + httpbin_host + '/redirect-to?status_code=308&url=https://' + httpbin_host + '/anything' # NOTE: This is a bug, fixed in https://github.com/ansible/ansible/pull/36809 - name: Test HTTP 308 using GET @@ -268,11 +268,11 @@ that: - http_308_get is failure - http_308_get.json is not defined - - http_308_get.location == 'https://{{ httpbin_host }}/anything' + - http_308_get.location == 'https://' + httpbin_host + '/anything' - "'Status code was 308 and not [200]: HTTP Error 308: ' in http_308_get.msg" - http_308_get.redirected == false - http_308_get.status == 308 - - http_308_get.url == 'https://{{ httpbin_host }}/redirect-to?status_code=308&url=https://{{ httpbin_host }}/anything' + - http_308_get.url == 'https://' + httpbin_host + '/redirect-to?status_code=308&url=https://' + httpbin_host + '/anything' - name: Test HTTP 308 using POST uri: @@ -289,8 +289,8 @@ that: - http_308_post is failure - http_308_post.json is not defined - - http_308_post.location == 'https://{{ httpbin_host }}/anything' + - http_308_post.location == 'https://' + httpbin_host + '/anything' - "'Status code was 308 and not [200]: HTTP Error 308: ' in http_308_post.msg" - http_308_post.redirected == false - http_308_post.status == 308 - - http_308_post.url == 'https://{{ httpbin_host }}/redirect-to?status_code=308&url=https://{{ httpbin_host }}/anything' + - http_308_post.url == 'https://' + httpbin_host + '/redirect-to?status_code=308&url=https://' + httpbin_host + '/anything' diff --git a/test/integration/targets/uri/tasks/redirect-safe.yml b/test/integration/targets/uri/tasks/redirect-safe.yml index bcc416964eb..ae16e27ff64 100644 --- a/test/integration/targets/uri/tasks/redirect-safe.yml +++ b/test/integration/targets/uri/tasks/redirect-safe.yml @@ -12,7 +12,7 @@ - http_301_head.json is not defined - http_301_head.redirected == true - http_301_head.status == 200 - - http_301_head.url == 'https://{{ httpbin_host }}/anything' + - http_301_head.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 301 using GET uri: @@ -27,10 +27,10 @@ - http_301_get is successful - http_301_get.json.data == '' - http_301_get.json.method == 'GET' - - http_301_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_301_get.json.url == 'https://' + httpbin_host + '/anything' - http_301_get.redirected == true - http_301_get.status == 200 - - http_301_get.url == 'https://{{ httpbin_host }}/anything' + - http_301_get.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 301 using POST uri: @@ -47,11 +47,11 @@ that: - http_301_post is failure - http_301_post.json is not defined - - http_301_post.location == 'https://{{ httpbin_host }}/anything' + - http_301_post.location == 'https://' + httpbin_host + '/anything' - "http_301_post.msg == 'Status code was 301 and not [200]: HTTP Error 301: MOVED PERMANENTLY'" - http_301_post.redirected == false - http_301_post.status == 301 - - http_301_post.url == 'https://{{ httpbin_host }}/redirect-to?status_code=301&url=https://{{ httpbin_host }}/anything' + - http_301_post.url == 'https://' + httpbin_host + '/redirect-to?status_code=301&url=https://' + httpbin_host + '/anything' - name: Test HTTP 302 using HEAD uri: @@ -67,7 +67,7 @@ - http_302_head.json is not defined - http_302_head.redirected == true - http_302_head.status == 200 - - http_302_head.url == 'https://{{ httpbin_host }}/anything' + - http_302_head.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 302 using GET uri: @@ -82,10 +82,10 @@ - http_302_get is successful - http_302_get.json.data == '' - http_302_get.json.method == 'GET' - - http_302_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_302_get.json.url == 'https://' + httpbin_host + '/anything' - http_302_get.redirected == true - http_302_get.status == 200 - - http_302_get.url == 'https://{{ httpbin_host }}/anything' + - http_302_get.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 302 using POST uri: @@ -102,11 +102,11 @@ that: - http_302_post is failure - http_302_post.json is not defined - - http_302_post.location == 'https://{{ httpbin_host }}/anything' + - http_302_post.location == 'https://' + httpbin_host + '/anything' - "http_302_post.msg == 'Status code was 302 and not [200]: HTTP Error 302: FOUND'" - http_302_post.redirected == false - http_302_post.status == 302 - - http_302_post.url == 'https://{{ httpbin_host }}/redirect-to?status_code=302&url=https://{{ httpbin_host }}/anything' + - http_302_post.url == 'https://' + httpbin_host + '/redirect-to?status_code=302&url=https://' + httpbin_host + '/anything' - name: Test HTTP 303 using HEAD uri: @@ -122,7 +122,7 @@ - http_303_head.json is not defined - http_303_head.redirected == true - http_303_head.status == 200 - - http_303_head.url == 'https://{{ httpbin_host }}/anything' + - http_303_head.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 303 using GET uri: @@ -137,10 +137,10 @@ - http_303_get is successful - http_303_get.json.data == '' - http_303_get.json.method == 'GET' - - http_303_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_303_get.json.url == 'https://' + httpbin_host + '/anything' - http_303_get.redirected == true - http_303_get.status == 200 - - http_303_get.url == 'https://{{ httpbin_host }}/anything' + - http_303_get.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 303 using POST uri: @@ -157,11 +157,11 @@ that: - http_303_post is failure - http_303_post.json is not defined - - http_303_post.location == 'https://{{ httpbin_host }}/anything' + - http_303_post.location == 'https://' + httpbin_host + '/anything' - "http_303_post.msg == 'Status code was 303 and not [200]: HTTP Error 303: SEE OTHER'" - http_303_post.redirected == false - http_303_post.status == 303 - - http_303_post.url == 'https://{{ httpbin_host }}/redirect-to?status_code=303&url=https://{{ httpbin_host }}/anything' + - http_303_post.url == 'https://' + httpbin_host + '/redirect-to?status_code=303&url=https://' + httpbin_host + '/anything' - name: Test HTTP 307 using HEAD uri: @@ -177,7 +177,7 @@ - http_307_head.json is not defined - http_307_head.redirected == true - http_307_head.status == 200 - - http_307_head.url == 'https://{{ httpbin_host }}/anything' + - http_307_head.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 307 using GET uri: @@ -192,10 +192,10 @@ - http_307_get is successful - http_307_get.json.data == '' - http_307_get.json.method == 'GET' - - http_307_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_307_get.json.url == 'https://' + httpbin_host + '/anything' - http_307_get.redirected == true - http_307_get.status == 200 - - http_307_get.url == 'https://{{ httpbin_host }}/anything' + - http_307_get.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 307 using POST uri: @@ -212,11 +212,11 @@ that: - http_307_post is failure - http_307_post.json is not defined - - http_307_post.location == 'https://{{ httpbin_host }}/anything' + - http_307_post.location == 'https://' + httpbin_host + '/anything' - "http_307_post.msg == 'Status code was 307 and not [200]: HTTP Error 307: TEMPORARY REDIRECT'" - http_307_post.redirected == false - http_307_post.status == 307 - - http_307_post.url == 'https://{{ httpbin_host }}/redirect-to?status_code=307&url=https://{{ httpbin_host }}/anything' + - http_307_post.url == 'https://' + httpbin_host + '/redirect-to?status_code=307&url=https://' + httpbin_host + '/anything' - name: Test HTTP 308 using HEAD uri: @@ -232,7 +232,7 @@ - http_308_head.json is not defined - http_308_head.redirected == true - http_308_head.status == 200 - - http_308_head.url == 'https://{{ httpbin_host }}/anything' + - http_308_head.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 308 using GET uri: @@ -247,10 +247,10 @@ - http_308_get is successful - http_308_get.json.data == '' - http_308_get.json.method == 'GET' - - http_308_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_308_get.json.url == 'https://' + httpbin_host + '/anything' - http_308_get.redirected == true - http_308_get.status == 200 - - http_308_get.url == 'https://{{ httpbin_host }}/anything' + - http_308_get.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 308 using POST uri: @@ -267,8 +267,8 @@ that: - http_308_post is failure - http_308_post.json is not defined - - http_308_post.location == 'https://{{ httpbin_host }}/anything' + - http_308_post.location == 'https://' + httpbin_host + '/anything' - "'Status code was 308 and not [200]: HTTP Error 308: ' in http_308_post.msg" - http_308_post.redirected == false - http_308_post.status == 308 - - http_308_post.url == 'https://{{ httpbin_host }}/redirect-to?status_code=308&url=https://{{ httpbin_host }}/anything' + - http_308_post.url == 'https://' + httpbin_host + '/redirect-to?status_code=308&url=https://' + httpbin_host + '/anything' diff --git a/test/integration/targets/uri/tasks/redirect-urllib2.yml b/test/integration/targets/uri/tasks/redirect-urllib2.yml index 9435db4758b..d3475148446 100644 --- a/test/integration/targets/uri/tasks/redirect-urllib2.yml +++ b/test/integration/targets/uri/tasks/redirect-urllib2.yml @@ -11,7 +11,7 @@ - http_301_head is successful - http_301_head.redirected == true - http_301_head.status == 200 - - http_301_head.url == 'https://{{ httpbin_host }}/anything' + - http_301_head.url == 'https://' + httpbin_host + '/anything' # HTTP 301 responses on HEAD requests behave differently depending on the Python version # see: https://github.com/python/cpython/issues/99730 @@ -27,7 +27,7 @@ that: - http_301_head.json.data == '' - http_301_head.json.method == 'GET' - - http_301_head.json.url == 'https://{{ httpbin_host }}/anything' + - http_301_head.json.url == 'https://' + httpbin_host + '/anything' when: ansible_python_version is version("3.13", "<") - name: Test HTTP 301 using GET @@ -43,10 +43,10 @@ - http_301_get is successful - http_301_get.json.data == '' - http_301_get.json.method == 'GET' - - http_301_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_301_get.json.url == 'https://' + httpbin_host + '/anything' - http_301_get.redirected == true - http_301_get.status == 200 - - http_301_get.url == 'https://{{ httpbin_host }}/anything' + - http_301_get.url == 'https://' + httpbin_host + '/anything' # NOTE: The HTTP POST turns into an HTTP GET - name: Test HTTP 301 using POST @@ -64,10 +64,10 @@ - http_301_post is successful - http_301_post.json.data == '' - http_301_post.json.method == 'GET' - - http_301_post.json.url == 'https://{{ httpbin_host }}/anything' + - http_301_post.json.url == 'https://' + httpbin_host + '/anything' - http_301_post.redirected == true - http_301_post.status == 200 - - http_301_post.url == 'https://{{ httpbin_host }}/anything' + - http_301_post.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 302 using HEAD uri: @@ -82,7 +82,7 @@ - http_302_head is successful - http_302_head.redirected == true - http_302_head.status == 200 - - http_302_head.url == 'https://{{ httpbin_host }}/anything' + - http_302_head.url == 'https://' + httpbin_host + '/anything' # HTTP 302 responses on HEAD requests behave differently depending on the Python version # see: https://github.com/python/cpython/issues/99730 @@ -98,7 +98,7 @@ that: - http_302_head.json.data == '' - http_302_head.json.method == 'GET' - - http_302_head.json.url == 'https://{{ httpbin_host }}/anything' + - http_302_head.json.url == 'https://' + httpbin_host + '/anything' when: ansible_python_version is version("3.13", "<") - name: Test HTTP 302 using GET @@ -114,10 +114,10 @@ - http_302_get is successful - http_302_get.json.data == '' - http_302_get.json.method == 'GET' - - http_302_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_302_get.json.url == 'https://' + httpbin_host + '/anything' - http_302_get.redirected == true - http_302_get.status == 200 - - http_302_get.url == 'https://{{ httpbin_host }}/anything' + - http_302_get.url == 'https://' + httpbin_host + '/anything' # NOTE: The HTTP POST turns into an HTTP GET - name: Test HTTP 302 using POST @@ -135,10 +135,10 @@ - http_302_post is successful - http_302_post.json.data == '' - http_302_post.json.method == 'GET' - - http_302_post.json.url == 'https://{{ httpbin_host }}/anything' + - http_302_post.json.url == 'https://' + httpbin_host + '/anything' - http_302_post.redirected == true - http_302_post.status == 200 - - http_302_post.url == 'https://{{ httpbin_host }}/anything' + - http_302_post.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 303 using HEAD uri: @@ -153,7 +153,7 @@ - http_303_head is successful - http_303_head.redirected == true - http_303_head.status == 200 - - http_303_head.url == 'https://{{ httpbin_host }}/anything' + - http_303_head.url == 'https://' + httpbin_host + '/anything' # HTTP 303 responses on HEAD requests behave differently depending on the Python version # see: https://github.com/python/cpython/issues/99730 @@ -185,10 +185,10 @@ - http_303_get is successful - http_303_get.json.data == '' - http_303_get.json.method == 'GET' - - http_303_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_303_get.json.url == 'https://' + httpbin_host + '/anything' - http_303_get.redirected == true - http_303_get.status == 200 - - http_303_get.url == 'https://{{ httpbin_host }}/anything' + - http_303_get.url == 'https://' + httpbin_host + '/anything' # NOTE: The HTTP POST turns into an HTTP GET - name: Test HTTP 303 using POST @@ -206,10 +206,10 @@ - http_303_post is successful - http_303_post.json.data == '' - http_303_post.json.method == 'GET' - - http_303_post.json.url == 'https://{{ httpbin_host }}/anything' + - http_303_post.json.url == 'https://' + httpbin_host + '/anything' - http_303_post.redirected == true - http_303_post.status == 200 - - http_303_post.url == 'https://{{ httpbin_host }}/anything' + - http_303_post.url == 'https://' + httpbin_host + '/anything' - name: Test HTTP 307 using HEAD uri: @@ -224,7 +224,7 @@ - http_307_head is successful - http_307_head.redirected == true - http_307_head.status == 200 - - http_307_head.url == 'https://{{ httpbin_host }}/anything' + - http_307_head.url == 'https://' + httpbin_host + '/anything' # HTTP 307 responses on HEAD requests behave differently depending on the Python version # see: https://github.com/python/cpython/issues/99730 @@ -256,10 +256,10 @@ - http_307_get is successful - http_307_get.json.data == '' - http_307_get.json.method == 'GET' - - http_307_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_307_get.json.url == 'https://' + httpbin_host + '/anything' - http_307_get.redirected == true - http_307_get.status == 200 - - http_307_get.url == 'https://{{ httpbin_host }}/anything' + - http_307_get.url == 'https://' + httpbin_host + '/anything' # FIXME: This is fixed in https://github.com/ansible/ansible/pull/36809 - name: Test HTTP 307 using POST @@ -277,11 +277,11 @@ that: - http_307_post is failure - http_307_post.json is not defined - - http_307_post.location == 'https://{{ httpbin_host }}/anything' + - http_307_post.location == 'https://' + httpbin_host + '/anything' - "http_307_post.msg == 'Status code was 307 and not [200]: HTTP Error 307: TEMPORARY REDIRECT'" - http_307_post.redirected == false - http_307_post.status == 307 - - http_307_post.url == 'https://{{ httpbin_host }}/redirect-to?status_code=307&url=https://{{ httpbin_host }}/anything' + - http_307_post.url == 'https://' + httpbin_host + '/redirect-to?status_code=307&url=https://' + httpbin_host + '/anything' # FIXME: This is fixed in https://github.com/ansible/ansible/pull/36809 - name: Test HTTP 308 using HEAD @@ -297,11 +297,11 @@ that: - http_308_head is failure - http_308_head.json is not defined - - http_308_head.location == 'https://{{ httpbin_host }}/anything' + - http_308_head.location == 'https://' + httpbin_host + '/anything' - "'Status code was 308 and not [200]: HTTP Error 308: ' in http_308_head.msg" - http_308_head.redirected == false - http_308_head.status == 308 - - http_308_head.url == 'https://{{ httpbin_host }}/redirect-to?status_code=308&url=https://{{ httpbin_host }}/anything' + - http_308_head.url == 'https://' + httpbin_host + '/redirect-to?status_code=308&url=https://' + httpbin_host + '/anything' # Python 3.10 and earlier do not support HTTP 308 responses. # See: https://github.com/python/cpython/issues/84501 when: ansible_python_version is version('3.11', '<') @@ -311,7 +311,7 @@ - http_308_head is successful - http_308_head.redirected == true - http_308_head.status == 200 - - http_308_head.url == 'https://{{ httpbin_host }}/anything' + - http_308_head.url == 'https://' + httpbin_host + '/anything' # Python 3.11 introduced support for HTTP 308 responses. # See: https://github.com/python/cpython/issues/84501 when: ansible_python_version is version('3.11', '>=') @@ -347,11 +347,11 @@ that: - http_308_get is failure - http_308_get.json is not defined - - http_308_get.location == 'https://{{ httpbin_host }}/anything' + - http_308_get.location == 'https://' + httpbin_host + '/anything' - "'Status code was 308 and not [200]: HTTP Error 308: ' in http_308_get.msg" - http_308_get.redirected == false - http_308_get.status == 308 - - http_308_get.url == 'https://{{ httpbin_host }}/redirect-to?status_code=308&url=https://{{ httpbin_host }}/anything' + - http_308_get.url == 'https://' + httpbin_host + '/redirect-to?status_code=308&url=https://' + httpbin_host + '/anything' # Python 3.10 and earlier do not support HTTP 308 responses. # See: https://github.com/python/cpython/issues/84501 when: ansible_python_version is version('3.11', '<') @@ -361,10 +361,10 @@ - http_308_get is successful - http_308_get.json.data == '' - http_308_get.json.method == 'GET' - - http_308_get.json.url == 'https://{{ httpbin_host }}/anything' + - http_308_get.json.url == 'https://' + httpbin_host + '/anything' - http_308_get.redirected == true - http_308_get.status == 200 - - http_308_get.url == 'https://{{ httpbin_host }}/anything' + - http_308_get.url == 'https://' + httpbin_host + '/anything' # Python 3.11 introduced support for HTTP 308 responses. # See: https://github.com/python/cpython/issues/84501 when: ansible_python_version is version('3.11', '>=') @@ -385,8 +385,8 @@ that: - http_308_post is failure - http_308_post.json is not defined - - http_308_post.location == 'https://{{ httpbin_host }}/anything' + - http_308_post.location == 'https://' + httpbin_host + '/anything' - "'Status code was 308 and not [200]: HTTP Error 308: ' in http_308_post.msg" - http_308_post.redirected == false - http_308_post.status == 308 - - http_308_post.url == 'https://{{ httpbin_host }}/redirect-to?status_code=308&url=https://{{ httpbin_host }}/anything' + - http_308_post.url == 'https://' + httpbin_host + '/redirect-to?status_code=308&url=https://' + httpbin_host + '/anything' diff --git a/test/integration/targets/uri/tasks/unexpected-failures.yml b/test/integration/targets/uri/tasks/unexpected-failures.yml index 341b66e709e..a9813f0df67 100644 --- a/test/integration/targets/uri/tasks/unexpected-failures.yml +++ b/test/integration/targets/uri/tasks/unexpected-failures.yml @@ -22,5 +22,4 @@ assert: that: - ret is failed - - "not ret.msg.startswith('MODULE FAILURE')" - - '"Could not replace file" in ret.msg' + - ret.msg is match "Could not replace file" diff --git a/test/integration/targets/var_blending/aliases b/test/integration/targets/var_blending/aliases index 1d28bdb2aa3..ea8d1627352 100644 --- a/test/integration/targets/var_blending/aliases +++ b/test/integration/targets/var_blending/aliases @@ -1,2 +1,3 @@ shippable/posix/group5 context/controller +gather_facts/no diff --git a/test/integration/targets/var_blending/test_var_blending.yml b/test/integration/targets/var_blending/test_var_blending.yml index 88a35b2c2c0..c13a714d44d 100644 --- a/test/integration/targets/var_blending/test_var_blending.yml +++ b/test/integration/targets/var_blending/test_var_blending.yml @@ -3,6 +3,5 @@ - vars_file.yml vars: vars_var: 123 - gather_facts: True roles: - { role: test_var_blending, parameterized_beats_default: 1234, tags: test_var_blending } diff --git a/test/integration/targets/var_precedence/aliases b/test/integration/targets/var_precedence/aliases index 8278ec8bcc7..0712f145f72 100644 --- a/test/integration/targets/var_precedence/aliases +++ b/test/integration/targets/var_precedence/aliases @@ -1,2 +1,3 @@ shippable/posix/group3 context/controller +gather_facts/no diff --git a/test/integration/targets/var_precedence/runme.sh b/test/integration/targets/var_precedence/runme.sh index 0f0811c3e9d..f111d962e79 100755 --- a/test/integration/targets/var_precedence/runme.sh +++ b/test/integration/targets/var_precedence/runme.sh @@ -2,6 +2,8 @@ set -eux +export ANSIBLE_GATHERING=explicit + ansible-playbook test_var_precedence.yml -i inventory -v "$@" \ -e 'extra_var=extra_var' \ -e 'extra_var_override=extra_var_override' diff --git a/test/integration/targets/var_precedence/test_var_precedence.yml b/test/integration/targets/var_precedence/test_var_precedence.yml index bba661db04a..f4e2038b42f 100644 --- a/test/integration/targets/var_precedence/test_var_precedence.yml +++ b/test/integration/targets/var_precedence/test_var_precedence.yml @@ -29,8 +29,7 @@ - debug: var=registered_var - debug: var=from_inventory_once_removed - assert: - that: item - with_items: + that: - 'extra_var == "extra_var"' - 'extra_var_override == "extra_var_override"' - 'extra_var_override_once_removed == "extra_var_override"' diff --git a/test/integration/targets/wait_for/tasks/main.yml b/test/integration/targets/wait_for/tasks/main.yml index eb186b3ab11..92f7c0ff1ce 100644 --- a/test/integration/targets/wait_for/tasks/main.yml +++ b/test/integration/targets/wait_for/tasks/main.yml @@ -40,7 +40,7 @@ assert: that: - waitfor is successful - - waitfor.path == "{{ remote_tmp_dir | expanduser }}/wait_for_file" + - waitfor.path == (remote_tmp_dir | expanduser + "/wait_for_file") - waitfor.elapsed >= 2 - waitfor.elapsed <= 15 @@ -58,7 +58,7 @@ assert: that: - waitfor is successful - - waitfor.path == "{{ remote_tmp_dir | expanduser }}/wait_for_file" + - waitfor.path == (remote_tmp_dir | expanduser + "/wait_for_file") - waitfor.elapsed >= 2 - waitfor.elapsed <= 15 @@ -163,7 +163,7 @@ that: - waitfor is successful - waitfor is not changed - - "waitfor.port == {{ http_port }}" + - waitfor.port == http_port - name: install psutil using pip (non-Linux) pip: @@ -191,7 +191,7 @@ that: - waitfor is successful - waitfor is not changed - - "waitfor.port == {{ http_port }}" + - waitfor.port == http_port - name: test wait_for with delay wait_for: diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt index 86af1c72145..b8bac0a1e42 100644 --- a/test/sanity/ignore.txt +++ b/test/sanity/ignore.txt @@ -71,8 +71,6 @@ test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/un test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/vendored_pty.py pep8!skip # vendored code test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/modules/my_module.py pylint:relative-beyond-top-level test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util2.py pylint:relative-beyond-top-level -test/integration/targets/config/lookup_plugins/casting.py pylint:unidiomatic-typecheck -test/integration/targets/config/lookup_plugins/casting_individual.py pylint:unidiomatic-typecheck test/integration/targets/fork_safe_stdio/vendored_pty.py pep8!skip # vendored code test/integration/targets/gathering_facts/library/bogus_facts shebang test/integration/targets/gathering_facts/library/dummy1 shebang