From 8253fb171dc5feb852111554c29bc1762a659f2d Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 9 Mar 2025 17:01:54 +0100 Subject: [PATCH] [PR #9859/eff25c8a backport][stable-10] Fix/improve tests (#9860) Fix/improve tests (#9859) * Fix tests. * Improve callback tests. (cherry picked from commit eff25c8a6ef7c5012ccf5efaec9d6ca1c678ccb7) Co-authored-by: Felix Fontein --- .../targets/callback/filter_plugins/helper.py | 54 +++++++++++++++++++ .../targets/callback/tasks/main.yml | 35 +----------- .../consul/tasks/consul_binding_rule.yml | 6 +-- .../targets/consul/tasks/consul_token.yml | 4 +- .../targets/deploy_helper/tasks/main.yml | 3 +- .../targets/filter_accumulate/tasks/main.yml | 4 +- .../targets/filter_counter/tasks/main.yml | 4 +- .../targets/filter_from_csv/tasks/main.yml | 2 +- .../filter_groupby_as_dict/tasks/main.yml | 8 +-- .../targets/filter_hashids/tasks/main.yml | 6 +-- .../targets/filter_keep_keys/tasks/tests.yml | 8 +-- .../tasks/lists_mergeby_2-10.yml | 14 ++--- .../tasks/lists_mergeby_default.yml | 22 ++++---- .../targets/filter_random_mac/tasks/main.yml | 6 +-- .../filter_remove_keys/tasks/tests.yml | 8 +-- .../filter_replace_keys/tasks/tests.yml | 8 +-- .../tasks/tasks.yml | 32 +++++------ .../targets/ini_file/tasks/tests/01-value.yml | 6 +-- .../tasks/tests/10-rollback.yml | 4 +- .../targets/java_keystore/tasks/tests.yml | 24 ++++----- .../targets/kernel_blacklist/tasks/main.yml | 6 +-- .../targets/keycloak_realm_key/tasks/main.yml | 6 ++- .../targets/lookup_dependent/tasks/main.yml | 12 +++-- .../targets/pkgng/tasks/freebsd.yml | 6 ++- .../targets/setup_cron/tasks/main.yml | 4 +- .../systemd_creds_encrypt/tasks/main.yaml | 2 +- .../targets/test_ansible_type/tasks/tasks.yml | 42 +++++++-------- .../test_fqdn_valid/tasks/fqdn_valid_1.yml | 8 +-- 28 files changed, 187 insertions(+), 157 deletions(-) create mode 100644 tests/integration/targets/callback/filter_plugins/helper.py diff --git a/tests/integration/targets/callback/filter_plugins/helper.py b/tests/integration/targets/callback/filter_plugins/helper.py new file mode 100644 index 0000000000..867dce6c75 --- /dev/null +++ b/tests/integration/targets/callback/filter_plugins/helper.py @@ -0,0 +1,54 @@ +# Copyright (c) Ansible Project +# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) +# SPDX-License-Identifier: GPL-3.0-or-later + +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +from ansible.module_utils.six import string_types + + +def callback_results_extractor(outputs_results): + results = [] + for result in outputs_results: + differences = [] + expected_output = result['test']['expected_output'] + stdout_lines = result['stdout_lines'] + for i in range(max(len(expected_output), len(stdout_lines))): + line = "line_%s" % (i + 1) + test_line = stdout_lines[i] if i < len(stdout_lines) else None + expected_lines = expected_output[i] if i < len(expected_output) else None + if not isinstance(expected_lines, string_types) and expected_lines is not None: + if test_line not in expected_lines: + differences.append({ + 'line': { + 'expected_one_of': expected_lines, + 'got': test_line, + } + }) + else: + if test_line != expected_lines: + differences.append({ + 'line': { + 'expected': expected_lines, + 'got': test_line, + } + }) + results.append({ + 'name': result['test']['name'], + 'output': { + 'differences': differences, + 'expected': expected_output, + 'got': stdout_lines, + }, + }) + return results + + +class FilterModule: + ''' Jinja2 compat filters ''' + + def filters(self): + return { + 'callback_results_extractor': callback_results_extractor, + } diff --git a/tests/integration/targets/callback/tasks/main.yml b/tests/integration/targets/callback/tasks/main.yml index 827217a532..51cef62173 100644 --- a/tests/integration/targets/callback/tasks/main.yml +++ b/tests/integration/targets/callback/tasks/main.yml @@ -50,44 +50,11 @@ - name: Assert test output equals expected output assert: that: result.output.differences | length == 0 - loop: "{{ results }}" + loop: "{{ outputs.results | callback_results_extractor }}" loop_control: loop_var: result label: "{{ result.name }}" register: assertions - vars: - results: >- - {%- set results = [] -%} - {%- for result in outputs.results -%} - {%- set differences = [] -%} - {%- for i in range([result.test.expected_output | count, result.stdout_lines | count] | max) -%} - {%- set line = "line_%s" | format(i+1) -%} - {%- set test_line = result.stdout_lines[i] | default(none) -%} - {%- set expected_lines = result.test.expected_output[i] | default(none) -%} - {%- if expected_lines is not string and expected_lines is not none -%} - {%- if test_line not in expected_lines -%} - {{- differences.append({ - line: { - 'expected_one_of': expected_lines, - 'got': test_line }}) -}} - {%- endif -%} - {%- else -%} - {%- if expected_lines != test_line -%} - {{- differences.append({ - line: { - 'expected': expected_lines, - 'got': test_line }}) -}} - {%- endif -%} - {%- endif -%} - {%- endfor -%} - {{- results.append({ - 'name': result.test.name, - 'output': { - 'differences': differences, - 'expected': result.test.expected_output, - 'got': result.stdout_lines }}) -}} - {%- endfor -%} - {{- results -}} always: - name: Remove temporary playbooks diff --git a/tests/integration/targets/consul/tasks/consul_binding_rule.yml b/tests/integration/targets/consul/tasks/consul_binding_rule.yml index 218daf982b..57f487d146 100644 --- a/tests/integration/targets/consul/tasks/consul_binding_rule.yml +++ b/tests/integration/targets/consul/tasks/consul_binding_rule.yml @@ -33,7 +33,7 @@ that: - result is changed - result.binding_rule.AuthMethod == 'test' - - result.binding.Description == 'test-binding: my description' + - "result.binding_rule.Description == 'test-binding: my description'" - result.operation == 'create' - name: Update a binding rule @@ -46,7 +46,7 @@ - assert: that: - result is changed - - result.binding.Description == 'test-binding: my description' + - "result.binding_rule.Description == 'test-binding: my description'" - result.operation == 'update' - name: Update a binding rule (noop) @@ -58,7 +58,7 @@ - assert: that: - result is not changed - - result.binding.Description == 'test-binding: my description' + - "result.binding_rule.Description == 'test-binding: my description'" - result.operation is not defined - name: Delete a binding rule diff --git a/tests/integration/targets/consul/tasks/consul_token.yml b/tests/integration/targets/consul/tasks/consul_token.yml index 9b3679ef1b..b328d0939d 100644 --- a/tests/integration/targets/consul/tasks/consul_token.yml +++ b/tests/integration/targets/consul/tasks/consul_token.yml @@ -22,7 +22,7 @@ - assert: that: - simple_create_result is changed - - simple_create_result.token.AccessorID + - simple_create_result.token.AccessorID is truthy - simple_create_result.operation == 'create' - name: Create token @@ -84,5 +84,5 @@ - assert: that: - result is changed - - not result.token + - result.token is falsy - result.operation == 'remove' diff --git a/tests/integration/targets/deploy_helper/tasks/main.yml b/tests/integration/targets/deploy_helper/tasks/main.yml index 9bd5f41506..e0fdee83e9 100644 --- a/tests/integration/targets/deploy_helper/tasks/main.yml +++ b/tests/integration/targets/deploy_helper/tasks/main.yml @@ -123,11 +123,12 @@ register: releases_path - stat: path={{ deploy_helper.shared_path }} register: shared_path + when: deploy_helper.shared_path is truthy - name: Assert State=present with shared_path set to False assert: that: - "releases_path.stat.exists" - - "not shared_path.stat.exists" + - "deploy_helper.shared_path is falsy or not shared_path.stat.exists" # Setup older releases for tests - file: path={{ deploy_helper.releases_path }}/{{ item }} state=directory diff --git a/tests/integration/targets/filter_accumulate/tasks/main.yml b/tests/integration/targets/filter_accumulate/tasks/main.yml index 8fe854228a..7f2ddfb7d7 100644 --- a/tests/integration/targets/filter_accumulate/tasks/main.yml +++ b/tests/integration/targets/filter_accumulate/tasks/main.yml @@ -30,6 +30,6 @@ assert: that: - integer_result is failed - - integer_result.msg is match('Invalid value type.*') + - integer_result.msg is search('Invalid value type') - non_uniform_list_result is failed - - non_uniform_list_result.msg is match('Unexpected templating type error.*can only concatenate str.*') + - non_uniform_list_result.msg is search('can only concatenate str') diff --git a/tests/integration/targets/filter_counter/tasks/main.yml b/tests/integration/targets/filter_counter/tasks/main.yml index 77d6b1b020..2879aaea12 100644 --- a/tests/integration/targets/filter_counter/tasks/main.yml +++ b/tests/integration/targets/filter_counter/tasks/main.yml @@ -26,7 +26,7 @@ assert: that: - res is failed - - res.msg is match('Argument for community.general.counter must be a sequence') + - res.msg is search('Argument for community.general.counter must be a sequence') - name: test fail element not hashable debug: @@ -38,4 +38,4 @@ assert: that: - res is failed - - res.msg is match('community.general.counter needs a sequence with hashable elements') + - res.msg is search('community.general.counter needs a sequence with hashable elements') diff --git a/tests/integration/targets/filter_from_csv/tasks/main.yml b/tests/integration/targets/filter_from_csv/tasks/main.yml index 5c58f85d47..ae9af332d7 100644 --- a/tests/integration/targets/filter_from_csv/tasks/main.yml +++ b/tests/integration/targets/filter_from_csv/tasks/main.yml @@ -51,4 +51,4 @@ assert: that: - _invalid_csv_strict_true is failed - - _invalid_csv_strict_true.msg is match('Unable to process file:.*') + - _invalid_csv_strict_true.msg is search('Unable to process file:.*') diff --git a/tests/integration/targets/filter_groupby_as_dict/tasks/main.yml b/tests/integration/targets/filter_groupby_as_dict/tasks/main.yml index f4047f4ac6..f420d671f2 100644 --- a/tests/integration/targets/filter_groupby_as_dict/tasks/main.yml +++ b/tests/integration/targets/filter_groupby_as_dict/tasks/main.yml @@ -16,7 +16,7 @@ - assert: that: - - result.msg == 'Input is not a sequence' + - result.msg is search('Input is not a sequence') - name: 'Test error: list element not a mapping' set_fact: @@ -26,7 +26,7 @@ - assert: that: - - "result.msg == 'Sequence element #0 is not a mapping'" + - "result.msg is search('Sequence element #0 is not a mapping')" - name: 'Test error: list element does not have attribute' set_fact: @@ -36,7 +36,7 @@ - assert: that: - - "result.msg == 'Attribute not contained in element #1 of sequence'" + - "result.msg is search('Attribute not contained in element #1 of sequence')" - name: 'Test error: attribute collision' set_fact: @@ -46,4 +46,4 @@ - assert: that: - - result.msg == "Multiple sequence entries have attribute value 'a'" or result.msg == "Multiple sequence entries have attribute value u'a'" + - result.msg is search("Multiple sequence entries have attribute value u?'a'") diff --git a/tests/integration/targets/filter_hashids/tasks/main.yml b/tests/integration/targets/filter_hashids/tasks/main.yml index 4a76540f6b..3cd9106aa7 100644 --- a/tests/integration/targets/filter_hashids/tasks/main.yml +++ b/tests/integration/targets/filter_hashids/tasks/main.yml @@ -31,7 +31,7 @@ - name: Register result of invalid salt debug: - var: "invalid_input | community.general.hashids_encode(salt=10)" + var: "single_int | community.general.hashids_encode(salt=10)" register: invalid_salt_message ignore_errors: true @@ -42,7 +42,7 @@ - name: Register result of invalid alphabet debug: - var: "invalid_input | community.general.hashids_encode(alphabet='abc')" + var: "single_int | community.general.hashids_encode(alphabet='abc')" register: invalid_alphabet_message ignore_errors: true @@ -53,7 +53,7 @@ - name: Register result of invalid min_length debug: - var: "invalid_input | community.general.hashids_encode(min_length='foo')" + var: "single_int | community.general.hashids_encode(min_length='foo')" register: invalid_min_length_message ignore_errors: true diff --git a/tests/integration/targets/filter_keep_keys/tasks/tests.yml b/tests/integration/targets/filter_keep_keys/tasks/tests.yml index fa821702f0..bebfc5fcbf 100644 --- a/tests/integration/targets/filter_keep_keys/tasks/tests.yml +++ b/tests/integration/targets/filter_keep_keys/tasks/tests.yml @@ -6,7 +6,7 @@ - name: Debug ansible_version ansible.builtin.debug: var: ansible_version - when: not quite_test | d(true) | bool + when: not (quiet_test | default(true) | bool) tags: ansible_version - name: Tests @@ -19,13 +19,13 @@ fail_msg: | [ERR] result: {{ result | to_yaml }} - quiet: "{{ quiet_test | d(true) | bool }}" + quiet: "{{ quiet_test | default(true) | bool }}" loop: "{{ tests | subelements('group') }}" loop_control: loop_var: i - label: "{{ i.1.mp | d('default') }}: {{ i.1.tt }}" + label: "{{ i.1.mp | default('default') }}: {{ i.1.tt }}" vars: input: "{{ i.0.input }}" target: "{{ i.1.tt }}" - mp: "{{ i.1.mp | d('default') }}" + mp: "{{ i.1.mp | default('default') }}" result: "{{ lookup('template', i.0.template) }}" diff --git a/tests/integration/targets/filter_lists_mergeby/tasks/lists_mergeby_2-10.yml b/tests/integration/targets/filter_lists_mergeby/tasks/lists_mergeby_2-10.yml index 62896e1b01..1e000c9753 100644 --- a/tests/integration/targets/filter_lists_mergeby/tasks/lists_mergeby_2-10.yml +++ b/tests/integration/targets/filter_lists_mergeby/tasks/lists_mergeby_2-10.yml @@ -16,7 +16,7 @@ {{ my_list|to_nice_yaml|indent(2) }} my_list|difference(result101): {{ my_list|difference(result101)|to_nice_yaml|indent(2) }} - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Merge 2 lists by attribute name. list_merge='keep'. assert assert: that: my_list | difference(result101) | length == 0 @@ -35,7 +35,7 @@ {{ my_list|to_nice_yaml|indent(2) }} my_list|difference(result102): {{ my_list|difference(result102)|to_nice_yaml|indent(2) }} - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Merge 2 lists by attribute name. list_merge='append'. assert assert: that: my_list | difference(result102) | length == 0 @@ -54,7 +54,7 @@ {{ my_list|to_nice_yaml|indent(2) }} my_list|difference(result103): {{ my_list|difference(result103)|to_nice_yaml|indent(2) }} - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Merge 2 lists by attribute name. list_merge='prepend'. assert assert: that: my_list | difference(result103) | length == 0 @@ -73,7 +73,7 @@ {{ my_list|to_nice_yaml|indent(2) }} my_list|difference(result104): {{ my_list|difference(result104)|to_nice_yaml|indent(2) }} - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Merge 2 lists by attribute name. list_merge='append_rp'. assert assert: that: my_list | difference(result104) | length == 0 @@ -92,7 +92,7 @@ {{ my_list|to_nice_yaml|indent(2) }} my_list|difference(result105): {{ my_list|difference(result105)|to_nice_yaml|indent(2) }} - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Merge 2 lists by attribute name. list_merge='prepend_rp'. assert assert: that: my_list | difference(result105) | length == 0 @@ -115,7 +115,7 @@ {{ my_list|to_nice_yaml|indent(2) }} my_list|difference(result200): {{ my_list|difference(result200)|to_nice_yaml|indent(2) }} - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Merge by name. recursive=True list_merge='append_rp'. assert assert: that: my_list | difference(result200) | length == 0 @@ -136,7 +136,7 @@ {{ my_list|to_nice_yaml|indent(2) }} my_list|difference(result201): {{ my_list|difference(result201)|to_nice_yaml|indent(2) }} - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Merge by name. recursive=False list_merge='append_rp'. assert assert: that: my_list | difference(result201) | length == 0 diff --git a/tests/integration/targets/filter_lists_mergeby/tasks/lists_mergeby_default.yml b/tests/integration/targets/filter_lists_mergeby/tasks/lists_mergeby_default.yml index 93917c97cc..b0484af2f2 100644 --- a/tests/integration/targets/filter_lists_mergeby/tasks/lists_mergeby_default.yml +++ b/tests/integration/targets/filter_lists_mergeby/tasks/lists_mergeby_default.yml @@ -6,7 +6,7 @@ - name: Debug ansible_version debug: var: ansible_version - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool tags: t0 - name: 1. Test lists merged by attribute name @@ -14,7 +14,7 @@ - name: Test lists merged by attribute name debug debug: msg: "{{ list1 | community.general.lists_mergeby(list2, 'name') }}" - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Test lists merged by attribute name assert assert: that: @@ -27,7 +27,7 @@ - name: Test list1 empty debug debug: msg: "{{ [] | community.general.lists_mergeby(list2, 'name') }}" - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Test list1 empty assert assert: that: @@ -40,7 +40,7 @@ - name: Test all lists empty debug debug: msg: "{{ [] | community.general.lists_mergeby([], 'name') }}" - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Test all lists empty assert assert: that: @@ -58,7 +58,7 @@ - name: First argument must be list debug debug: var: my_list - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: First argument must be list assert assert: that: @@ -76,7 +76,7 @@ - name: Second argument must be list set debug debug: var: my_list - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Second argument must be list set assert assert: that: @@ -94,7 +94,7 @@ - name: First arguments after the lists must be string debug debug: var: my_list - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: First arguments after the lists must be string assert assert: that: @@ -112,7 +112,7 @@ - name: Elements of list must be dictionaries debug debug: var: my_list - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Elements of list must be dictionaries assert assert: that: @@ -128,7 +128,7 @@ - name: Merge 3 lists by attribute name. 1 list in params. debug debug: var: my_list - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Merge 3 lists by attribute name. 1 list in params. assert assert: that: my_list | difference(result1) | length == 0 @@ -142,7 +142,7 @@ - name: Merge 3 lists by attribute name. No list in the params. debug debug: var: my_list - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Merge 3 lists by attribute name. No list in the params. asset assert: that: my_list | difference(result1) | length == 0 @@ -162,7 +162,7 @@ {{ my_list|to_nice_yaml|indent(2) }} my_list|difference(result100): {{ my_list|difference(result100)|to_nice_yaml|indent(2) }} - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Merge 2 lists by attribute name. list_merge='replace'. assert assert: that: my_list | difference(result100) | length == 0 diff --git a/tests/integration/targets/filter_random_mac/tasks/main.yml b/tests/integration/targets/filter_random_mac/tasks/main.yml index 230f9776d5..db47011927 100644 --- a/tests/integration/targets/filter_random_mac/tasks/main.yml +++ b/tests/integration/targets/filter_random_mac/tasks/main.yml @@ -19,7 +19,7 @@ assert: that: - _bad_random_mac_filter is failed - - "_bad_random_mac_filter.msg is match('Invalid value type (.*int.*) for random_mac .*')" + - "_bad_random_mac_filter.msg is search('Invalid value type (.*int.*) for random_mac .*')" - name: Test random_mac filter bad argument value debug: @@ -31,7 +31,7 @@ assert: that: - _bad_random_mac_filter is failed - - "_bad_random_mac_filter.msg is match('Invalid value (.*) for random_mac: .* not hexa byte')" + - "_bad_random_mac_filter.msg is search('Invalid value (.*) for random_mac: .* not hexa byte')" - name: Test random_mac filter prefix too big debug: @@ -43,7 +43,7 @@ assert: that: - _bad_random_mac_filter is failed - - "_bad_random_mac_filter.msg is match('Invalid value (.*) for random_mac: 5 colon.* separated items max')" + - "_bad_random_mac_filter.msg is search('Invalid value (.*) for random_mac: 5 colon.* separated items max')" - name: Verify random_mac filter assert: diff --git a/tests/integration/targets/filter_remove_keys/tasks/tests.yml b/tests/integration/targets/filter_remove_keys/tasks/tests.yml index fa821702f0..bebfc5fcbf 100644 --- a/tests/integration/targets/filter_remove_keys/tasks/tests.yml +++ b/tests/integration/targets/filter_remove_keys/tasks/tests.yml @@ -6,7 +6,7 @@ - name: Debug ansible_version ansible.builtin.debug: var: ansible_version - when: not quite_test | d(true) | bool + when: not (quiet_test | default(true) | bool) tags: ansible_version - name: Tests @@ -19,13 +19,13 @@ fail_msg: | [ERR] result: {{ result | to_yaml }} - quiet: "{{ quiet_test | d(true) | bool }}" + quiet: "{{ quiet_test | default(true) | bool }}" loop: "{{ tests | subelements('group') }}" loop_control: loop_var: i - label: "{{ i.1.mp | d('default') }}: {{ i.1.tt }}" + label: "{{ i.1.mp | default('default') }}: {{ i.1.tt }}" vars: input: "{{ i.0.input }}" target: "{{ i.1.tt }}" - mp: "{{ i.1.mp | d('default') }}" + mp: "{{ i.1.mp | default('default') }}" result: "{{ lookup('template', i.0.template) }}" diff --git a/tests/integration/targets/filter_replace_keys/tasks/tests.yml b/tests/integration/targets/filter_replace_keys/tasks/tests.yml index fa821702f0..bebfc5fcbf 100644 --- a/tests/integration/targets/filter_replace_keys/tasks/tests.yml +++ b/tests/integration/targets/filter_replace_keys/tasks/tests.yml @@ -6,7 +6,7 @@ - name: Debug ansible_version ansible.builtin.debug: var: ansible_version - when: not quite_test | d(true) | bool + when: not (quiet_test | default(true) | bool) tags: ansible_version - name: Tests @@ -19,13 +19,13 @@ fail_msg: | [ERR] result: {{ result | to_yaml }} - quiet: "{{ quiet_test | d(true) | bool }}" + quiet: "{{ quiet_test | default(true) | bool }}" loop: "{{ tests | subelements('group') }}" loop_control: loop_var: i - label: "{{ i.1.mp | d('default') }}: {{ i.1.tt }}" + label: "{{ i.1.mp | default('default') }}: {{ i.1.tt }}" vars: input: "{{ i.0.input }}" target: "{{ i.1.tt }}" - mp: "{{ i.1.mp | d('default') }}" + mp: "{{ i.1.mp | default('default') }}" result: "{{ lookup('template', i.0.template) }}" diff --git a/tests/integration/targets/filter_reveal_ansible_type/tasks/tasks.yml b/tests/integration/targets/filter_reveal_ansible_type/tasks/tasks.yml index 37d3abcb71..528c01addb 100644 --- a/tests/integration/targets/filter_reveal_ansible_type/tasks/tasks.yml +++ b/tests/integration/targets/filter_reveal_ansible_type/tasks/tasks.yml @@ -10,7 +10,7 @@ that: result == dtype success_msg: '"abc" is {{ dtype }}' fail_msg: '"abc" is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: data: "abc" result: '{{ data | community.general.reveal_ansible_type }}' @@ -21,7 +21,7 @@ that: result == dtype success_msg: '"abc" is {{ dtype }}' fail_msg: '"abc" is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: alias: {"AnsibleUnicode": "str"} data: "abc" @@ -33,7 +33,7 @@ that: result == dtype success_msg: '["a", "b", "c"] is {{ dtype }}' fail_msg: '["a", "b", "c"] is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: data: ["a", "b", "c"] result: '{{ data | community.general.reveal_ansible_type }}' @@ -44,7 +44,7 @@ that: result == dtype success_msg: '{"a": "foo", "b": "bar", "c": "baz"} is {{ dtype }}' fail_msg: '{"a": "foo", "b": "bar", "c": "baz"} is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: data: {"a": "foo", "b": "bar", "c": "baz"} result: '{{ data | community.general.reveal_ansible_type }}' @@ -58,7 +58,7 @@ that: result == dtype success_msg: '"abc" is {{ dtype }}' fail_msg: '"abc" is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ "abc" | community.general.reveal_ansible_type }}' dtype: str @@ -68,7 +68,7 @@ that: result == dtype success_msg: '123 is {{ dtype }}' fail_msg: '123 is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ 123 | community.general.reveal_ansible_type }}' dtype: int @@ -78,7 +78,7 @@ that: result == dtype success_msg: '123.45 is {{ dtype }}' fail_msg: '123.45 is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ 123.45 | community.general.reveal_ansible_type }}' dtype: float @@ -88,7 +88,7 @@ that: result == dtype success_msg: 'true is {{ dtype }}' fail_msg: 'true is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ true | community.general.reveal_ansible_type }}' dtype: bool @@ -98,7 +98,7 @@ that: result == dtype success_msg: '["a", "b", "c"] is {{ dtype }}' fail_msg: '["a", "b", "c"] is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ ["a", "b", "c"] | community.general.reveal_ansible_type }}' dtype: list[str] @@ -108,7 +108,7 @@ that: result == dtype success_msg: '[{"a": 1}, {"b": 2}] is {{ dtype }}' fail_msg: '[{"a": 1}, {"b": 2}] is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ [{"a": 1}, {"b": 2}] | community.general.reveal_ansible_type }}' dtype: list[dict] @@ -118,7 +118,7 @@ that: result == dtype success_msg: '{"a": 1} is {{ dtype }}' fail_msg: '{"a": 1} is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ {"a": 1} | community.general.reveal_ansible_type }}' dtype: dict[str, int] @@ -128,7 +128,7 @@ that: result == dtype success_msg: '{"a": 1, "b": 2} is {{ dtype }}' fail_msg: '{"a": 1, "b": 2} is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ {"a": 1, "b": 2} | community.general.reveal_ansible_type }}' dtype: dict[str, int] @@ -141,7 +141,7 @@ that: result == dtype success_msg: 'data is {{ dtype }}' fail_msg: 'data is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: alias: {"AnsibleUnicode": "str"} data: {1: 'a', 'b': 'b'} @@ -153,7 +153,7 @@ that: result == dtype success_msg: 'data is {{ dtype }}' fail_msg: 'data is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: alias: {"AnsibleUnicode": "str"} data: {1: 'a', 2: 'b'} @@ -165,7 +165,7 @@ that: result == dtype success_msg: 'data is {{ dtype }}' fail_msg: 'data is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: alias: {"AnsibleUnicode": "str"} data: {'a': 1, 'b': 1.1, 'c': 'abc', 'd': True, 'e': ['x', 'y', 'z'], 'f': {'x': 1, 'y': 2}} @@ -177,7 +177,7 @@ that: result == dtype success_msg: 'data is {{ dtype }}' fail_msg: 'data is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: alias: {"AnsibleUnicode": "str"} data: [1, 2, 1.1, 'abc', True, ['x', 'y', 'z'], {'x': 1, 'y': 2}] diff --git a/tests/integration/targets/ini_file/tasks/tests/01-value.yml b/tests/integration/targets/ini_file/tasks/tests/01-value.yml index f95f166fe5..b52b299dfd 100644 --- a/tests/integration/targets/ini_file/tasks/tests/01-value.yml +++ b/tests/integration/targets/ini_file/tasks/tests/01-value.yml @@ -253,7 +253,7 @@ path: "{{ output_file }}" section: mysqld option: "{{ item.o }}" - value: "{{ item.v | d(omit) }}" + value: "{{ item.v | default(omit) }}" allow_no_value: true loop: - { o: "skip-name-resolve" } @@ -512,10 +512,10 @@ - name: test-value 20 - Tests with empty strings ini_file: path: "{{ output_file }}" - section: "{{ item.section | d('extensions') }}" + section: "{{ item.section | default('extensions') }}" option: "{{ item.option }}" value: "" - allow_no_value: "{{ item.no_value | d(omit) }}" + allow_no_value: "{{ item.no_value | default(omit) }}" loop: - option: evolve - option: regress diff --git a/tests/integration/targets/iptables_state/tasks/tests/10-rollback.yml b/tests/integration/targets/iptables_state/tasks/tests/10-rollback.yml index 53fdd3ca03..9a79d6390e 100644 --- a/tests/integration/targets/iptables_state/tasks/tests/10-rollback.yml +++ b/tests/integration/targets/iptables_state/tasks/tests/10-rollback.yml @@ -70,7 +70,7 @@ async: "{{ ansible_timeout }}" poll: 0 vars: - ansible_timeout: "{{ max_delay | d(300) }}" + ansible_timeout: "{{ max_delay | default(300) }}" rescue: - name: "explain expected failure" @@ -179,7 +179,7 @@ async: "{{ ansible_timeout }}" poll: 0 vars: - ansible_timeout: "{{ max_delay | d(300) }}" + ansible_timeout: "{{ max_delay | default(300) }}" rescue: - name: "explain expected failure" diff --git a/tests/integration/targets/java_keystore/tasks/tests.yml b/tests/integration/targets/java_keystore/tasks/tests.yml index 899fe27e85..02e380fb7a 100644 --- a/tests/integration/targets/java_keystore/tasks/tests.yml +++ b/tests/integration/targets/java_keystore/tasks/tests.yml @@ -26,7 +26,7 @@ - name: Read certificate keys slurp: - src: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.key' }}" + src: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | default(item.name)) ~ '.key' }}" loop: "{{ java_keystore_certs }}" when: not remote_cert register: certificate_keys @@ -34,15 +34,15 @@ - name: Create a Java keystore for the given ({{ 'remote' if remote_cert else 'local' }}) certificates (check mode) community.general.java_keystore: &java_keystore_params name: example - dest: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.jks' }}" + dest: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | default(item.name)) ~ '.jks' }}" certificate: "{{ omit if remote_cert else (certificates.results[loop_index].content | b64decode) }}" private_key: "{{ omit if remote_cert else (certificate_keys.results[loop_index].content | b64decode) }}" certificate_path: "{{ omit if not remote_cert else remote_tmp_dir ~ '/' ~ item.name ~ '.pem' }}" - private_key_path: "{{ omit if not remote_cert else remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.key' }}" - private_key_passphrase: "{{ item.passphrase | d(omit) }}" + private_key_path: "{{ omit if not remote_cert else remote_tmp_dir ~ '/' ~ (item.keyname | default(item.name)) ~ '.key' }}" + private_key_passphrase: "{{ item.passphrase | default(omit) }}" password: changeit ssl_backend: "{{ ssl_backend }}" - keystore_type: "{{ item.keystore_type | d(omit) }}" + keystore_type: "{{ item.keystore_type | default(omit) }}" loop: "{{ java_keystore_certs }}" loop_control: index_var: loop_index @@ -82,7 +82,7 @@ - name: Read certificate keys (new) slurp: - src: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.key' }}" + src: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | default(item.name)) ~ '.key' }}" loop: "{{ java_keystore_new_certs }}" when: not remote_cert register: certificate_keys_new @@ -90,15 +90,15 @@ - name: Create a Java keystore for the given certificates (certificate changed, check mode) community.general.java_keystore: &java_keystore_params_new_certs name: example - dest: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.jks' }}" + dest: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | default(item.name)) ~ '.jks' }}" certificate: "{{ omit if remote_cert else (certificates_new.results[loop_index].content | b64decode) }}" private_key: "{{ omit if remote_cert else (certificate_keys_new.results[loop_index].content | b64decode) }}" certificate_path: "{{ omit if not remote_cert else remote_tmp_dir ~ '/' ~ item.name ~ '.pem' }}" - private_key_path: "{{ omit if not remote_cert else remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.key' }}" - private_key_passphrase: "{{ item.passphrase | d(omit) }}" + private_key_path: "{{ omit if not remote_cert else remote_tmp_dir ~ '/' ~ (item.keyname | default(item.name)) ~ '.key' }}" + private_key_passphrase: "{{ item.passphrase | default(omit) }}" password: changeit ssl_backend: "{{ ssl_backend }}" - keystore_type: "{{ item.keystore_type | d(omit) }}" + keystore_type: "{{ item.keystore_type | default(omit) }}" loop: "{{ java_keystore_new_certs }}" loop_control: index_var: loop_index @@ -193,7 +193,7 @@ - name: Stat keystore (before failure) ansible.builtin.stat: - path: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.jks' }}" + path: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | default(item.name)) ~ '.jks' }}" loop: "{{ java_keystore_new_certs }}" register: result_stat_before @@ -211,7 +211,7 @@ - name: Stat keystore (after failure) ansible.builtin.stat: - path: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | d(item.name)) ~ '.jks' }}" + path: "{{ remote_tmp_dir ~ '/' ~ (item.keyname | default(item.name)) ~ '.jks' }}" loop: "{{ java_keystore_new_certs }}" register: result_stat_after diff --git a/tests/integration/targets/kernel_blacklist/tasks/main.yml b/tests/integration/targets/kernel_blacklist/tasks/main.yml index 48cd38a937..61d766d48e 100644 --- a/tests/integration/targets/kernel_blacklist/tasks/main.yml +++ b/tests/integration/targets/kernel_blacklist/tasks/main.yml @@ -51,7 +51,7 @@ - orig_stat.stat.size == stat_test_1.stat.size - orig_stat.stat.checksum == stat_test_1.stat.checksum - orig_stat.stat.mtime == stat_test_1.stat.mtime - - stat_test_1.stat.checksum == expected_content | checksum + - stat_test_1.stat.checksum == (expected_content | trim + '\n') | checksum vars: expected_content: | # Copyright (c) Ansible Project @@ -83,7 +83,7 @@ assert: that: - bl_test_2 is changed - - slurp_test_2.content|b64decode == content + - slurp_test_2.content|b64decode == (content | trim + '\n') vars: content: | # Copyright (c) Ansible Project @@ -111,7 +111,7 @@ assert: that: - bl_test_3 is changed - - slurp_test_3.content|b64decode == content + - slurp_test_3.content|b64decode == (content | trim + '\n') vars: content: | # Copyright (c) Ansible Project diff --git a/tests/integration/targets/keycloak_realm_key/tasks/main.yml b/tests/integration/targets/keycloak_realm_key/tasks/main.yml index c02950600f..e447d075e0 100644 --- a/tests/integration/targets/keycloak_realm_key/tasks/main.yml +++ b/tests/integration/targets/keycloak_realm_key/tasks/main.yml @@ -151,7 +151,8 @@ - result.end_state.config.enabled == ["true"] - result.end_state.config.algorithm == ["RS256"] - result.end_state.config.priority == ["140"] - - result.msg == "Realm key testkey would be changed: config.priority ['150'] -> ['140']" + - >- + result.msg == "Realm key testkey would be changed: config.priority ['150'] -> ['140']" - name: Update custom realm key community.general.keycloak_realm_key: @@ -184,7 +185,8 @@ - result.end_state.config.enabled == ["true"] - result.end_state.config.algorithm == ["RS256"] - result.end_state.config.priority == ["140"] - - result.msg == "Realm key testkey changed: config.priority ['150'] -> ['140']" + - >- + result.msg == "Realm key testkey changed: config.priority ['150'] -> ['140']" - name: Update custom realm key (test for idempotency) community.general.keycloak_realm_key: diff --git a/tests/integration/targets/lookup_dependent/tasks/main.yml b/tests/integration/targets/lookup_dependent/tasks/main.yml index b2f2097294..a1328cc19e 100644 --- a/tests/integration/targets/lookup_dependent/tasks/main.yml +++ b/tests/integration/targets/lookup_dependent/tasks/main.yml @@ -136,7 +136,8 @@ assert: that: - eval_error is failed - - eval_error.msg.startswith("Caught \"'foo' is undefined") + - >- + "Caught \"'foo' is undefined" in eval_error.msg - name: "Test 5: same variable name reused" debug: @@ -151,7 +152,8 @@ assert: that: - eval_error is failed - - eval_error.msg.startswith("Caught \"'x' is undefined") + - >- + "Caught \"'x' is undefined" in eval_error.msg - name: "Test 6: multi-value dict" debug: @@ -166,7 +168,8 @@ assert: that: - eval_error is failed - - eval_error.msg == 'Parameter 0 must be a one-element dictionary, got 2 elements' + - >- + 'Parameter 0 must be a one-element dictionary, got 2 elements' in eval_error.msg - name: "Test 7: empty dict" debug: @@ -180,4 +183,5 @@ assert: that: - eval_error is failed - - eval_error.msg == 'Parameter 0 must be a one-element dictionary, got 0 elements' + - >- + 'Parameter 0 must be a one-element dictionary, got 0 elements' in eval_error.msg diff --git a/tests/integration/targets/pkgng/tasks/freebsd.yml b/tests/integration/targets/pkgng/tasks/freebsd.yml index a9c0a1873b..a4a85e004f 100644 --- a/tests/integration/targets/pkgng/tasks/freebsd.yml +++ b/tests/integration/targets/pkgng/tasks/freebsd.yml @@ -469,8 +469,10 @@ - '(pkgng_example8_invalid_annotation_failure.results | selectattr("changed") | list | count) == 0' # Invalid strings should always fail - '(pkgng_example8_invalid_annotation_failure.results | rejectattr("failed") | list | count) == 0' - # Invalid strings should not cause an exception - - '(pkgng_example8_invalid_annotation_failure.results | selectattr("exception", "defined") | list | count) == 0' + # Invalid strings should not cause a module crash + - '(pkgng_example8_invalid_annotation_failure.results | selectattr("module_stdout", "defined") | list | count) == 0' + # Invalid strings should have a proper msg field + - '(pkgng_example8_invalid_annotation_failure.results | selectattr("msg", "match", "failed to annotate zsh, invalid annotate string: .*") | list | count) == 4' # Verify annotations are unaffected - '(pkgng_example8_invalid_annotation_verify.stdout_lines | select("search", "(naked_string|invalid_operation|empty_first_tag|validsecond|notag)") | list | count) == 0' diff --git a/tests/integration/targets/setup_cron/tasks/main.yml b/tests/integration/targets/setup_cron/tasks/main.yml index cca7071a3a..b669f0219f 100644 --- a/tests/integration/targets/setup_cron/tasks/main.yml +++ b/tests/integration/targets/setup_cron/tasks/main.yml @@ -25,10 +25,10 @@ - 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 cron and faketime packages package: diff --git a/tests/integration/targets/systemd_creds_encrypt/tasks/main.yaml b/tests/integration/targets/systemd_creds_encrypt/tasks/main.yaml index 362fe90bcb..8ed45b2dc3 100644 --- a/tests/integration/targets/systemd_creds_encrypt/tasks/main.yaml +++ b/tests/integration/targets/systemd_creds_encrypt/tasks/main.yaml @@ -19,7 +19,7 @@ - name: Assert encrypted secret output is base64 encoded ansible.builtin.assert: that: - - encrypted_secret.value | b64decode + - (encrypted_secret.value | b64decode) is truthy fail_msg: "Encrypted secret is not base64 encoded" success_msg: "Encrypted secret is base64 encoded" diff --git a/tests/integration/targets/test_ansible_type/tasks/tasks.yml b/tests/integration/targets/test_ansible_type/tasks/tasks.yml index 261256c0d4..d962838106 100644 --- a/tests/integration/targets/test_ansible_type/tasks/tasks.yml +++ b/tests/integration/targets/test_ansible_type/tasks/tasks.yml @@ -10,7 +10,7 @@ that: data is community.general.ansible_type(dtype) success_msg: '"abc" is {{ dtype }}' fail_msg: '"abc" is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: data: "abc" result: '{{ data | community.general.reveal_ansible_type }}' @@ -21,7 +21,7 @@ that: data is community.general.ansible_type(dtype, alias) success_msg: '"abc" is {{ dtype }}' fail_msg: '"abc" is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: alias: {"AnsibleUnicode": "str"} data: "abc" @@ -33,7 +33,7 @@ that: data is community.general.ansible_type(dtype) success_msg: '["a", "b", "c"] is {{ dtype }}' fail_msg: '["a", "b", "c"] is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: data: ["a", "b", "c"] result: '{{ data | community.general.reveal_ansible_type }}' @@ -44,7 +44,7 @@ that: data is community.general.ansible_type(dtype) success_msg: '{"a": "foo", "b": "bar", "c": "baz"} is {{ dtype }}' fail_msg: '{"a": "foo", "b": "bar", "c": "baz"} is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: data: {"a": "foo", "b": "bar", "c": "baz"} result: '{{ data | community.general.reveal_ansible_type }}' @@ -58,7 +58,7 @@ that: '"abc" is community.general.ansible_type(dtype)' success_msg: '"abc" is {{ dtype }}' fail_msg: '"abc" is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ "abc" | community.general.reveal_ansible_type }}' dtype: str @@ -68,7 +68,7 @@ that: '123 is community.general.ansible_type(dtype)' success_msg: '123 is {{ dtype }}' fail_msg: '123 is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ 123 | community.general.reveal_ansible_type }}' dtype: int @@ -78,7 +78,7 @@ that: '123.45 is community.general.ansible_type(dtype)' success_msg: '123.45 is {{ dtype }}' fail_msg: '123.45 is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ 123.45 | community.general.reveal_ansible_type }}' dtype: float @@ -88,7 +88,7 @@ that: 'true is community.general.ansible_type(dtype)' success_msg: 'true is {{ dtype }}' fail_msg: 'true is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ true | community.general.reveal_ansible_type }}' dtype: bool @@ -98,7 +98,7 @@ that: '["a", "b", "c"] is community.general.ansible_type(dtype)' success_msg: '["a", "b", "c"] is {{ dtype }}' fail_msg: '["a", "b", "c"] is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ ["a", "b", "c"] | community.general.reveal_ansible_type }}' dtype: list[str] @@ -108,7 +108,7 @@ that: '[{"a": 1}, {"b": 2}] is community.general.ansible_type(dtype)' success_msg: '[{"a": 1}, {"b": 2}] is {{ dtype }}' fail_msg: '[{"a": 1}, {"b": 2}] is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ [{"a": 1}, {"b": 2}] | community.general.reveal_ansible_type }}' dtype: list[dict] @@ -118,7 +118,7 @@ that: '{"a": 1} is community.general.ansible_type(dtype)' success_msg: '{"a": 1} is {{ dtype }}' fail_msg: '{"a": 1} is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ {"a": 1} | community.general.reveal_ansible_type }}' dtype: dict[str, int] @@ -128,7 +128,7 @@ that: '{"a": 1, "b": 2} is community.general.ansible_type(dtype)' success_msg: '{"a": 1, "b": 2} is {{ dtype }}' fail_msg: '{"a": 1, "b": 2} is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: result: '{{ {"a": 1, "b": 2} | community.general.reveal_ansible_type }}' dtype: dict[str, int] @@ -141,7 +141,7 @@ that: data is community.general.ansible_type(dtype, alias) success_msg: '{"1": "a", "b": "b"} is {{ dtype }}' fail_msg: '{"1": "a", "b": "b"} is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: alias: {"AnsibleUnicode": "str"} data: {1: 'a', 'b': 'b'} @@ -153,7 +153,7 @@ that: data is community.general.ansible_type(dtype, alias) success_msg: '{"1": "a", "2": "b"} is {{ dtype }}' fail_msg: '{"1": "a", "2": "b"} is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: alias: {"AnsibleUnicode": "str"} data: {1: 'a', 2: 'b'} @@ -165,7 +165,7 @@ that: data is community.general.ansible_type(dtype, alias) success_msg: '{"a": 1, "b": 1.1, "c": "abc", "d": true, "e": ["x", "y", "z"], "f": {"x": 1, "y": 2}} is {{ dtype }}' fail_msg: '{"a": 1, "b": 1.1, "c": "abc", "d": true, "e": ["x", "y", "z"], "f": {"x": 1, "y": 2}} is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: alias: {"AnsibleUnicode": "str"} data: {'a': 1, 'b': 1.1, 'c': 'abc', 'd': True, 'e': ['x', 'y', 'z'], 'f': {'x': 1, 'y': 2}} @@ -177,7 +177,7 @@ that: data is community.general.ansible_type(dtype, alias) success_msg: '[1, 2, 1.1, "abc", true, ["x", "y", "z"], {"x": 1, "y": 2}] is {{ dtype }}' fail_msg: '[1, 2, 1.1, "abc", true, ["x", "y", "z"], {"x": 1, "y": 2}] is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: alias: {"AnsibleUnicode": "str"} data: [1, 2, 1.1, 'abc', True, ['x', 'y', 'z'], {'x': 1, 'y': 2}] @@ -192,7 +192,7 @@ that: data is community.general.ansible_type(dtype) success_msg: '"abc" is {{ dtype }}' fail_msg: '"abc" is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: data: abc result: '{{ data | community.general.reveal_ansible_type }}' @@ -203,7 +203,7 @@ that: data is community.general.ansible_type(dtype) success_msg: '123 is {{ dtype }}' fail_msg: '123 is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: data: 123 result: '{{ data | community.general.reveal_ansible_type }}' @@ -214,7 +214,7 @@ that: data is community.general.ansible_type(dtype) success_msg: '123.45 is {{ dtype }}' fail_msg: '123.45 is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: data: 123.45 result: '{{ data | community.general.reveal_ansible_type }}' @@ -228,7 +228,7 @@ that: data is community.general.ansible_type(dtype, alias) success_msg: '123 is {{ dtype }}' fail_msg: '123 is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: alias: {"int": "number", "float": "number"} data: 123 @@ -240,7 +240,7 @@ that: data is community.general.ansible_type(dtype, alias) success_msg: '123.45 is {{ dtype }}' fail_msg: '123.45 is {{ result }}' - quiet: '{{ quiet_test | d(true) | bool }}' + quiet: '{{ quiet_test | default(true) | bool }}' vars: alias: {"int": "number", "float": "number"} data: 123.45 diff --git a/tests/integration/targets/test_fqdn_valid/tasks/fqdn_valid_1.yml b/tests/integration/targets/test_fqdn_valid/tasks/fqdn_valid_1.yml index 36cfffad0c..3a839a0e6a 100644 --- a/tests/integration/targets/test_fqdn_valid/tasks/fqdn_valid_1.yml +++ b/tests/integration/targets/test_fqdn_valid/tasks/fqdn_valid_1.yml @@ -6,7 +6,7 @@ - name: Debug ansible_version ansible.builtin.debug: var: ansible_version - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool tags: t0 - name: 1. Test valid hostnames. Default options. @@ -14,7 +14,7 @@ - name: "1. Default min_labels=1, allow_underscores=False" ansible.builtin.debug: msg: "hosts_invalid: {{ hosts_invalid }}" - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Assert ansible.builtin.assert: that: hosts_invalid|difference(result)|length == 0 @@ -29,7 +29,7 @@ - name: "2. allow_underscores=True, default min_labels=1" ansible.builtin.debug: msg: "hosts_invalid: {{ hosts_invalid }}" - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Assert ansible.builtin.assert: that: hosts_invalid|difference(result)|length == 0 @@ -45,7 +45,7 @@ - name: "3. allow_underscores=True, min_labels=2" ansible.builtin.debug: msg: "hosts_invalid: {{ hosts_invalid }}" - when: debug_test|d(false)|bool + when: debug_test|default(false)|bool - name: Assert ansible.builtin.assert: that: hosts_invalid|difference(result)|length == 0