summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 16:16:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-05 16:16:47 +0000
commit7a7fb74454bb3a169acecd30e87067502bfe3260 (patch)
treed684cbea7ffc70bd39a1e52bb65b0ea5ae156bda /test
parentAdding upstream version 2.16.6. (diff)
downloadansible-core-7a7fb74454bb3a169acecd30e87067502bfe3260.tar.xz
ansible-core-7a7fb74454bb3a169acecd30e87067502bfe3260.zip
Adding upstream version 2.17.0.upstream/2.17.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test')
-rw-r--r--test/integration/targets/ansiballz_python/library/check_rlimit_and_maxfd.py3
-rw-r--r--test/integration/targets/ansiballz_python/library/custom_module.py3
-rw-r--r--test/integration/targets/ansiballz_python/library/sys_check.py3
-rw-r--r--test/integration/targets/ansiballz_python/module_utils/custom_util.py3
-rw-r--r--test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/cache/notjsonfile.py4
-rw-r--r--test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/inventory/statichost.py3
-rw-r--r--test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/lookup/noop.py4
-rw-r--r--test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/fakemodule.py5
-rw-r--r--test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/notrealmodule.py3
-rw-r--r--test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/randommodule.py3
-rw-r--r--test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/vars/noop_vars_plugin.py3
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/cache/notjsonfile.py4
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/filter/filter_subdir/in_subdir.py4
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/filter/grouped.py4
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/inventory/statichost.py3
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/lookup/noop.py4
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/database/database_type/subdir_module.py3
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/fakemodule.py3
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/notrealmodule.py3
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/randommodule.py12
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/test/test_test.py3
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/vars/noop_vars_plugin.py3
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/roles/testrole/meta/main.yml4
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/deprecation.py3
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/module.py3
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/plugin.py3
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/version_added.py3
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol3/plugins/modules/test1.py3
-rw-r--r--test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol4/plugins/modules/test2.py3
-rw-r--r--test/integration/targets/ansible-doc/fakecollrole.output21
-rw-r--r--test/integration/targets/ansible-doc/fakemodule.output13
-rw-r--r--test/integration/targets/ansible-doc/fakerole.output50
-rw-r--r--test/integration/targets/ansible-doc/filter_plugins/other.py4
-rw-r--r--test/integration/targets/ansible-doc/fix-urls.py1
-rw-r--r--test/integration/targets/ansible-doc/library/double_doc.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_docs.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_docs_missing_description.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_docs_no_metadata.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_docs_no_status.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_docs_non_iterable_status.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_docs_removed_precedence.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_docs_removed_status.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_docs_returns.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_docs_returns_broken.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_docs_suboptions.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_docs_yaml_anchors.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_no_docs.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_no_docs_no_metadata.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_no_docs_no_status.py3
-rw-r--r--test/integration/targets/ansible-doc/library/test_no_docs_non_iterable_status.py3
-rw-r--r--test/integration/targets/ansible-doc/lookup_plugins/_deprecated_with_adj_docs.py3
-rw-r--r--test/integration/targets/ansible-doc/lookup_plugins/_deprecated_with_docs.py3
-rw-r--r--test/integration/targets/ansible-doc/noop.output1
-rw-r--r--test/integration/targets/ansible-doc/noop_vars_plugin.output1
-rw-r--r--test/integration/targets/ansible-doc/notjsonfile.output1
-rw-r--r--test/integration/targets/ansible-doc/randommodule-text-verbose.output79
-rw-r--r--test/integration/targets/ansible-doc/randommodule-text.output125
-rw-r--r--test/integration/targets/ansible-doc/randommodule.output5
-rw-r--r--test/integration/targets/ansible-doc/roles/test_role1/meta/argument_specs.yml6
-rwxr-xr-xtest/integration/targets/ansible-doc/runme.sh61
-rw-r--r--test/integration/targets/ansible-doc/test.yml51
-rw-r--r--test/integration/targets/ansible-doc/test_docs_returns.output28
-rw-r--r--test/integration/targets/ansible-doc/test_docs_suboptions.output42
-rw-r--r--test/integration/targets/ansible-doc/test_docs_yaml_anchors.output35
-rw-r--r--test/integration/targets/ansible-doc/yolo-text.output18
-rw-r--r--test/integration/targets/ansible-doc/yolo.output1
-rw-r--r--test/integration/targets/ansible-galaxy-collection-cli/files/empty_manifest_galaxy.yml8
-rw-r--r--test/integration/targets/ansible-galaxy-collection-cli/files/expected_empty.txt117
-rw-r--r--test/integration/targets/ansible-galaxy-collection-cli/files/make_collection_dir.py2
-rw-r--r--test/integration/targets/ansible-galaxy-collection-cli/tasks/manifest.yml31
-rw-r--r--test/integration/targets/ansible-galaxy-collection/files/build_bad_tar.py6
-rw-r--r--test/integration/targets/ansible-galaxy-collection/files/test_module.py3
-rw-r--r--test/integration/targets/ansible-galaxy-collection/handlers/main.yml7
-rw-r--r--test/integration/targets/ansible-galaxy-collection/library/reset_pulp.py3
-rw-r--r--test/integration/targets/ansible-galaxy-collection/library/setup_collections.py3
-rw-r--r--test/integration/targets/ansible-galaxy-collection/tasks/download.yml27
-rw-r--r--test/integration/targets/ansible-galaxy-collection/tasks/init.yml21
-rw-r--r--test/integration/targets/ansible-galaxy-collection/tasks/install.yml27
-rw-r--r--test/integration/targets/ansible-galaxy-collection/tasks/setup_gpg.yml21
-rw-r--r--test/integration/targets/ansible-galaxy-collection/tasks/verify.yml11
-rwxr-xr-xtest/integration/targets/ansible-galaxy-role/files/create-role-archive.py1
-rw-r--r--test/integration/targets/ansible-galaxy-role/files/safe-symlinks/defaults/common_vars/subdir/group0/main.yml (renamed from test/units/compat/__init__.py)0
-rw-r--r--test/integration/targets/ansible-galaxy-role/files/safe-symlinks/defaults/main.yml0
-rw-r--r--test/integration/targets/ansible-galaxy-role/files/safe-symlinks/handlers/utils.yml0
-rw-r--r--test/integration/targets/ansible-galaxy-role/files/safe-symlinks/meta/main.yml0
-rw-r--r--test/integration/targets/ansible-galaxy-role/files/safe-symlinks/tasks/utils/suite.yml0
-rw-r--r--test/integration/targets/ansible-galaxy-role/tasks/valid-role-symlinks.yml116
-rw-r--r--test/integration/targets/ansible-galaxy/files/testserver.py3
-rw-r--r--test/integration/targets/ansible-inventory/filter_plugins/toml.py4
-rw-r--r--test/integration/targets/ansible-playbook-callbacks/callback_list_include_role_fail.expected9
-rw-r--r--test/integration/targets/ansible-playbook-callbacks/callbacks_list.expected4
-rw-r--r--test/integration/targets/ansible-playbook-callbacks/include_role-fail.yml5
-rwxr-xr-xtest/integration/targets/ansible-playbook-callbacks/runme.sh9
-rw-r--r--test/integration/targets/ansible-runner/aliases4
-rw-r--r--test/integration/targets/ansible-runner/files/adhoc_example1.py28
-rw-r--r--test/integration/targets/ansible-runner/files/playbook_example1.py41
-rw-r--r--test/integration/targets/ansible-runner/filter_plugins/parse.py17
-rw-r--r--test/integration/targets/ansible-runner/inventory1
-rwxr-xr-xtest/integration/targets/ansible-runner/runme.sh7
-rw-r--r--test/integration/targets/ansible-runner/tasks/adhoc_example1.yml14
-rw-r--r--test/integration/targets/ansible-runner/tasks/main.yml4
-rw-r--r--test/integration/targets/ansible-runner/tasks/playbook_example1.yml21
-rw-r--r--test/integration/targets/ansible-runner/tasks/setup.yml4
-rw-r--r--test/integration/targets/ansible-runner/test.yml3
-rw-r--r--test/integration/targets/ansible-test-config-invalid/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_test.py3
-rw-r--r--test/integration/targets/ansible-test-config/ansible_collections/ns/col/plugins/module_utils/test.py2
-rw-r--r--test/integration/targets/ansible-test-config/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_test.py2
-rwxr-xr-xtest/integration/targets/ansible-test-container/runme.py93
-rw-r--r--test/integration/targets/ansible-test-coverage/ansible_collections/ns/col/plugins/module_utils/test_util.py3
-rw-r--r--test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/doc_fragments/ps_util.py3
-rw-r--r--test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/module_utils/my_util.py3
-rw-r--r--test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/modules/hello.py3
-rw-r--r--test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_my_util.py3
-rw-r--r--test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/modules/test_hello.py3
-rwxr-xr-xtest/integration/targets/ansible-test-integration-targets/test.py1
-rw-r--r--test/integration/targets/ansible-test-integration/ansible_collections/ns/col/plugins/module_utils/my_util.py3
-rw-r--r--test/integration/targets/ansible-test-integration/ansible_collections/ns/col/plugins/modules/hello.py3
-rwxr-xr-xtest/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/run-with-pty.py1
-rwxr-xr-xtest/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/tests/integration/targets/no-tty/assert-no-tty.py1
-rw-r--r--test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/vendored_pty.py1
-rw-r--r--test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/lookup/a/b/lookup2.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/lookup/lookup1.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/modules/a/b/module2.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/modules/module1.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-import/ansible_collections/ns/col/plugins/lookup/vendor1.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-import/ansible_collections/ns/col/plugins/lookup/vendor2.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-no-get-exception/ansible_collections/ns/col/do-not-check-me.py2
-rw-r--r--test/integration/targets/ansible-test-sanity-no-get-exception/ansible_collections/ns/col/plugins/modules/check-me.py2
-rw-r--r--test/integration/targets/ansible-test-sanity-no-get-exception/expected.txt4
-rw-r--r--test/integration/targets/ansible-test-sanity-pylint/ansible_collections/ns/col/plugins/lookup/deprecated.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-pylint/expected.txt2
-rw-r--r--test/integration/targets/ansible-test-sanity-replace-urlopen/ansible_collections/ns/col/do-not-check-me.py2
-rw-r--r--test/integration/targets/ansible-test-sanity-replace-urlopen/ansible_collections/ns/col/plugins/modules/check-me.py2
-rw-r--r--test/integration/targets/ansible-test-sanity-replace-urlopen/expected.txt2
-rw-r--r--test/integration/targets/ansible-test-sanity-use-compat-six/ansible_collections/ns/col/do-not-check-me.py2
-rw-r--r--test/integration/targets/ansible-test-sanity-use-compat-six/ansible_collections/ns/col/plugins/modules/check-me.py2
-rw-r--r--test/integration/targets/ansible-test-sanity-use-compat-six/expected.txt2
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/_not_deprecated.py22
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_1.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_2.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_3.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_4.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_5.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_6.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_7.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/import_order.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_argument_spec_extra_key.py36
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_argument_spec_incorrect_context.py36
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_choice_value.py33
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_yaml_syntax.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/no_callable.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/semantic_markup.py3
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/sidecar.py1
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/unsupported_extension.nope2
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/valid_argument_spec_context.py38
-rw-r--r--test/integration/targets/ansible-test-sanity-validate-modules/expected.txt13
-rw-r--r--test/integration/targets/ansible-test-sanity-yamllint/aliases4
-rw-r--r--test/integration/targets/ansible-test-sanity-yamllint/ansible_collections/ns/col/plugins/inventory/inventory1.py43
-rw-r--r--test/integration/targets/ansible-test-sanity-yamllint/ansible_collections/ns/col/plugins/modules/module1.py40
-rw-r--r--test/integration/targets/ansible-test-sanity-yamllint/expected.txt4
-rwxr-xr-xtest/integration/targets/ansible-test-sanity-yamllint/runme.sh11
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/bad.py3
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/world.py3
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/modules/bad.py3
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/plugin_utils/check_pylint.py3
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/random_directory/bad.py3
-rw-r--r--test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py3
-rw-r--r--test/integration/targets/ansible-test-units-assertions/ansible_collections/ns/col/tests/unit/plugins/modules/test_assertion.py3
-rw-r--r--test/integration/targets/ansible-test-units-constraints/ansible_collections/ns/col/tests/unit/plugins/modules/test_constraints.py3
-rw-r--r--test/integration/targets/ansible-test-units-forked/ansible_collections/ns/col/tests/unit/plugins/modules/test_ansible_forked.py3
-rw-r--r--test/integration/targets/ansible-test-units/ansible_collections/ns/col/plugins/module_utils/my_util.py3
-rw-r--r--test/integration/targets/ansible-test-units/ansible_collections/ns/col/plugins/modules/hello.py3
-rw-r--r--test/integration/targets/ansible-test-units/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_my_util.py3
-rw-r--r--test/integration/targets/ansible-test-units/ansible_collections/ns/col/tests/unit/plugins/modules/test_hello.py3
-rwxr-xr-xtest/integration/targets/ansible-test/venv-pythons.py1
-rwxr-xr-xtest/integration/targets/ansible-vault/faux-editor.py3
-rwxr-xr-xtest/integration/targets/ansible-vault/password-script.py3
-rwxr-xr-xtest/integration/targets/ansible-vault/runme.sh2
-rwxr-xr-xtest/integration/targets/ansible-vault/script/vault-secret.sh9
-rwxr-xr-xtest/integration/targets/ansible-vault/symlink/get-password-symlink9
-rwxr-xr-xtest/integration/targets/ansible-vault/test-vault-client.py3
-rw-r--r--test/integration/targets/ansible/callback_plugins/callback_meta.py3
-rw-r--r--test/integration/targets/ansible_log/aliases2
-rw-r--r--test/integration/targets/ansible_log/logit.yml4
-rwxr-xr-xtest/integration/targets/ansible_log/runme.sh26
-rw-r--r--test/integration/targets/any_errors_fatal/31543.yml12
-rw-r--r--test/integration/targets/any_errors_fatal/36308.yml14
-rw-r--r--test/integration/targets/any_errors_fatal/73246.yml11
-rw-r--r--test/integration/targets/any_errors_fatal/80981.yml17
-rwxr-xr-xtest/integration/targets/any_errors_fatal/runme.sh14
-rw-r--r--test/integration/targets/apt/tasks/apt.yml23
-rw-r--r--test/integration/targets/apt/tasks/url-with-deps.yml32
-rw-r--r--test/integration/targets/apt_repository/tasks/apt.yml89
-rw-r--r--test/integration/targets/argspec/library/argspec.py3
-rw-r--r--test/integration/targets/assemble/tasks/main.yml16
-rw-r--r--test/integration/targets/async/library/async_test.py3
-rw-r--r--test/integration/targets/async/tasks/main.yml27
-rw-r--r--test/integration/targets/async_extra_data/library/junkping.py3
-rw-r--r--test/integration/targets/async_fail/action_plugins/normal.py3
-rw-r--r--test/integration/targets/async_fail/library/async_test.py3
-rw-r--r--test/integration/targets/become/aliases1
-rw-r--r--test/integration/targets/become_unprivileged/action_plugins/tmpdir.py4
-rw-r--r--test/integration/targets/builtin_vars_prompt/test-vars_prompt.py3
-rw-r--r--test/integration/targets/callback_default/callback_default.out.include_role_fails.stderr12
-rw-r--r--test/integration/targets/callback_default/callback_default.out.include_role_fails.stdout9
-rw-r--r--test/integration/targets/callback_default/callback_default.out.result_format_yaml_lossy_verbose.stdout2
-rw-r--r--test/integration/targets/callback_default/callback_default.out.result_format_yaml_verbose.stdout2
-rwxr-xr-xtest/integration/targets/callback_default/runme.sh17
-rw-r--r--test/integration/targets/callback_default/test_include_role_fails.yml5
-rw-r--r--test/integration/targets/cli/test-cli.py4
-rw-r--r--test/integration/targets/cli/test_k_and_K.py4
-rwxr-xr-xtest/integration/targets/collection/update-ignore.py1
-rw-r--r--test/integration/targets/collections/ansiballz_dupe/collections/ansible_collections/duplicate/name/plugins/modules/ping.py2
-rw-r--r--test/integration/targets/collections/collection_root_sys/ansible_collections/testns/coll_in_sys/plugins/modules/systestmodule.py3
-rw-r--r--test/integration/targets/collections/collection_root_sys/ansible_collections/testns/testcoll/plugins/modules/maskedmodule.py3
-rw-r--r--test/integration/targets/collections/collection_root_sys/ansible_collections/testns/testcoll/plugins/modules/testmodule.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/ansible/builtin/plugins/modules/ping.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/ansible/bullcoll/plugins/modules/bullmodule.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testbroken/plugins/filter/broken_filter.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/playbooks/roles/non_coll_role/library/embedded_module.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/action_subdir/subdir_ping_action.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/bypass_host_loop.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/plugin_lookup.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/subclassed_normal.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/uses_redirected_import.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/callback/usercallback.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/connection/localconn.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/doc_fragments/frag.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/filter_subdir/my_subdir_filters.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/myfilters.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/myfilters2.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/lookup_subdir/my_subdir_lookup.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/mylookup.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/mylookup2.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/base.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/leaf.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/nested_same/nested_same/nested_same.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/secondary.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg/submod.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init/__init__.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init/mod_in_subpkg_with_init.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/deprecated_ping.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/module_subdir/subdir_ping_module.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/ping.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/testmodule.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/testmodule_bad_docfrags.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_base_mu_granular_nested_import.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_collection_redirected_mu.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_core_redirected_mu.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_flat_import.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_granular_import.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_module_import_from.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing_redirect_collection.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing_redirect_module.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_nested_same_as_func.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_nested_same_as_module.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/mytests.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/mytests2.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/test_subdir/my_subdir_tests.py3
-rw-r--r--test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/vars/custom_vars.py3
-rw-r--r--test/integration/targets/collections/collections/ansible_collections/me/mycoll1/plugins/action/action1.py3
-rw-r--r--test/integration/targets/collections/collections/ansible_collections/me/mycoll1/plugins/modules/action1.py3
-rw-r--r--test/integration/targets/collections/collections/ansible_collections/me/mycoll2/plugins/modules/module1.py3
-rw-r--r--test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/cache/custom_jsonfile.py4
-rw-r--r--test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/inventory/statichost.py3
-rw-r--r--test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/module_utils/sub1/foomodule.py3
-rw-r--r--test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/modules/contentadjmodule.py3
-rw-r--r--test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/vars/custom_adj_vars.py3
-rw-r--r--test/integration/targets/collections/custom_vars_plugins/v1_vars_plugin.py5
-rw-r--r--test/integration/targets/collections/custom_vars_plugins/v2_vars_plugin.py5
-rw-r--r--test/integration/targets/collections/filter_plugins/override_formerly_core_masked_filter.py3
-rw-r--r--test/integration/targets/collections/library/ping.py3
-rwxr-xr-xtest/integration/targets/collections/runme.sh13
-rw-r--r--test/integration/targets/collections/test_plugins/override_formerly_core_masked_test.py3
-rw-r--r--test/integration/targets/collections/test_task_resolved_plugin/action_plugins/legacy_action.py3
-rw-r--r--test/integration/targets/collections/test_task_resolved_plugin/callback_plugins/display_resolved_action.py3
-rw-r--r--test/integration/targets/collections/test_task_resolved_plugin/collections/ansible_collections/test_ns/test_coll/plugins/action/collection_action.py3
-rw-r--r--test/integration/targets/collections/test_task_resolved_plugin/collections/ansible_collections/test_ns/test_coll/plugins/modules/collection_module.py3
-rw-r--r--test/integration/targets/collections/test_task_resolved_plugin/library/legacy_module.py3
-rw-r--r--test/integration/targets/collections/testcoll2/plugins/modules/testmodule2.py3
-rw-r--r--test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/filter/test_filter.py3
-rw-r--r--test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/lookup/lookup_name.py3
-rw-r--r--test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/lookup/lookup_no_future_boilerplate.py2
-rw-r--r--test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/test/test_test.py3
-rw-r--r--test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util1.py3
-rw-r--r--test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util2.py3
-rw-r--r--test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util3.py3
-rw-r--r--test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/modules/my_module.py3
-rw-r--r--test/integration/targets/collections_runtime_pythonpath/ansible-collection-python-dist-boo/ansible_collections/python/dist/plugins/modules/boo.py3
-rw-r--r--test/integration/targets/collections_runtime_pythonpath/ansible-collection-python-dist-foo/ansible_collections/python/dist/plugins/modules/boo.py3
-rwxr-xr-xtest/integration/targets/collections_runtime_pythonpath/runme.sh15
-rw-r--r--test/integration/targets/command_shell/tasks/main.yml6
-rw-r--r--test/integration/targets/common_network/test_plugins/is_mac.py3
-rw-r--r--test/integration/targets/config/files/types.env3
-rw-r--r--test/integration/targets/config/files/types.ini5
-rw-r--r--test/integration/targets/config/files/types.vars4
-rw-r--r--test/integration/targets/config/lookup_plugins/bogus.py4
-rw-r--r--test/integration/targets/config/lookup_plugins/casting.py59
-rw-r--r--test/integration/targets/config/lookup_plugins/casting_individual.py58
-rw-r--r--test/integration/targets/config/lookup_plugins/types.py14
-rwxr-xr-xtest/integration/targets/config/runme.sh5
-rw-r--r--test/integration/targets/config/type_munging.cfg3
-rw-r--r--test/integration/targets/config/types.yml5
-rw-r--r--test/integration/targets/config/validation.yml7
-rw-r--r--test/integration/targets/connection_delegation/action_plugins/delegation_action.py3
-rw-r--r--test/integration/targets/connection_delegation/connection_plugins/delegation_connection.py3
-rw-r--r--test/integration/targets/connection_remote_is_local/connection_plugins/remote_is_local.py3
-rwxr-xr-xtest/integration/targets/connection_ssh/runme.sh2
-rw-r--r--test/integration/targets/copy/tasks/dest_in_non_existent_directories.yml6
-rw-r--r--test/integration/targets/copy/tasks/dest_in_non_existent_directories_remote_src.yml6
-rw-r--r--test/integration/targets/copy/tasks/selinux.yml4
-rw-r--r--test/integration/targets/copy/tasks/src_file_dest_file_in_non_existent_dir.yml4
-rw-r--r--test/integration/targets/copy/tasks/src_file_dest_file_in_non_existent_dir_remote_src.yml4
-rw-r--r--test/integration/targets/copy/tasks/tests.yml26
-rw-r--r--test/integration/targets/deb822_repository/tasks/test.yml28
-rw-r--r--test/integration/targets/debconf/tasks/main.yml80
-rwxr-xr-xtest/integration/targets/debugger/test_run_once.py1
-rw-r--r--test/integration/targets/delegate_to/connection_plugins/fakelocal.py3
-rw-r--r--test/integration/targets/delegate_to/library/detect_interpreter.py3
-rw-r--r--test/integration/targets/dict_transformations/library/convert_camelCase.py3
-rw-r--r--test/integration/targets/dict_transformations/library/convert_snake_case.py3
-rw-r--r--test/integration/targets/dnf/filter_plugins/dnf_module_list.py40
-rw-r--r--test/integration/targets/dnf/tasks/dnf.yml21
-rw-r--r--test/integration/targets/dnf/tasks/dnf_group_remove.yml141
-rw-r--r--test/integration/targets/dnf/tasks/main.yml32
-rw-r--r--test/integration/targets/dnf/tasks/modularity.yml9
-rw-r--r--test/integration/targets/dnf/tasks/repo.yml213
-rw-r--r--test/integration/targets/dnf/tasks/skip_broken_and_nobest.yml25
-rw-r--r--test/integration/targets/dnf/vars/CentOS.yml2
-rw-r--r--test/integration/targets/dnf/vars/Fedora.yml6
-rw-r--r--test/integration/targets/dnf/vars/RedHat-9.yml2
-rw-r--r--test/integration/targets/dnf/vars/RedHat.yml2
-rw-r--r--test/integration/targets/dnf/vars/main.yml2
-rw-r--r--test/integration/targets/egg-info/lookup_plugins/import_pkg_resources.py3
-rwxr-xr-xtest/integration/targets/entry_points/runme.sh1
-rw-r--r--test/integration/targets/error_from_connection/connection_plugins/dummy.py3
-rw-r--r--test/integration/targets/expect/files/test_command.py3
-rw-r--r--test/integration/targets/fetch/injection/library/slurp.py3
-rw-r--r--test/integration/targets/file/tasks/state_link.yml6
-rw-r--r--test/integration/targets/filter_core/aliases1
-rw-r--r--test/integration/targets/filter_core/meta/main.yml3
-rw-r--r--test/integration/targets/filter_core/tasks/main.yml41
-rw-r--r--test/integration/targets/filter_encryption/aliases1
-rw-r--r--test/integration/targets/filter_encryption/base.yml49
-rwxr-xr-xtest/integration/targets/filter_encryption/runme.sh5
-rw-r--r--test/integration/targets/filter_encryption/tasks/main.yml19
-rw-r--r--test/integration/targets/filter_encryption/vars/main.yml38
-rw-r--r--test/integration/targets/find/aliases3
-rw-r--r--test/integration/targets/find/files/hello_world.gbk1
-rw-r--r--test/integration/targets/find/tasks/main.yml58
-rw-r--r--test/integration/targets/fork_safe_stdio/callback_plugins/spewstdio.py2
-rwxr-xr-xtest/integration/targets/fork_safe_stdio/run-with-pty.py1
-rw-r--r--test/integration/targets/fork_safe_stdio/vendored_pty.py1
-rw-r--r--test/integration/targets/gathering_facts/cache_plugins/none.py3
-rw-r--r--test/integration/targets/gathering_facts/collections/ansible_collections/cisco/ios/plugins/modules/ios_facts.py1
-rw-r--r--test/integration/targets/gathering_facts/library/file_utils.py3
-rw-r--r--test/integration/targets/gathering_facts/test_run_once.yml2
-rw-r--r--test/integration/targets/get_url/files/testserver.py26
-rw-r--r--test/integration/targets/get_url/tasks/hashlib.yml1
-rw-r--r--test/integration/targets/get_url/tasks/main.yml1
-rw-r--r--test/integration/targets/group/files/get_free_gid.py3
-rw-r--r--test/integration/targets/group/files/get_gid_for_group.py3
-rw-r--r--test/integration/targets/handlers/collections/ansible_collections/ns/col/roles/test_handlers_listen/handlers/main.yml4
-rw-r--r--test/integration/targets/handlers/force_handlers_blocks_81533-1.yml16
-rw-r--r--test/integration/targets/handlers/force_handlers_blocks_81533-2.yml12
-rw-r--r--test/integration/targets/handlers/handlers_lockstep_82307.yml25
-rw-r--r--test/integration/targets/handlers/roles/test_handlers_listen/handlers/main.yml5
-rwxr-xr-xtest/integration/targets/handlers/runme.sh15
-rw-r--r--test/integration/targets/handlers/test_handlers_listen.yml15
-rw-r--r--test/integration/targets/ignore_unreachable/fake_connectors/bad_exec.py3
-rw-r--r--test/integration/targets/ignore_unreachable/fake_connectors/bad_put_file.py3
-rw-r--r--test/integration/targets/include_import/playbook/sub_playbook/library/helloworld.py3
-rwxr-xr-xtest/integration/targets/include_import/runme.sh2
-rw-r--r--test/integration/targets/include_import/tasks/task_ansible_loop_index_var.yml5
-rw-r--r--test/integration/targets/include_import/tasks/test_include_tasks.yml7
-rw-r--r--test/integration/targets/include_vars/tasks/main.yml8
-rw-r--r--test/integration/targets/infra/library/test.py3
-rw-r--r--test/integration/targets/interpreter_discovery_python/library/test_echo_module.py3
-rw-r--r--test/integration/targets/interpreter_discovery_python/tasks/main.yml14
-rw-r--r--test/integration/targets/inventory/inventory_plugins/contructed_with_hostvars.py3
-rw-r--r--test/integration/targets/inventory_cache/plugins/inventory/cache_host.py3
-rw-r--r--test/integration/targets/inventory_cache/plugins/inventory/exercise_cache.py3
-rw-r--r--test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/bad_collection_filter.py4
-rw-r--r--test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/bad_collection_filter2.py4
-rw-r--r--test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/good_collection_filter.py4
-rw-r--r--test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/test/bad_collection_test.py4
-rw-r--r--test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/test/good_collection_test.py4
-rw-r--r--test/integration/targets/jinja_plugins/filter_plugins/bad_filter.py4
-rw-r--r--test/integration/targets/jinja_plugins/filter_plugins/good_filter.py4
-rw-r--r--test/integration/targets/jinja_plugins/test_plugins/bad_test.py4
-rw-r--r--test/integration/targets/jinja_plugins/test_plugins/good_test.py4
-rw-r--r--test/integration/targets/keyword_inheritance/aliases1
-rw-r--r--test/integration/targets/known_hosts/defaults/main.yml7
-rw-r--r--test/integration/targets/known_hosts/files/existing_known_hosts1
-rw-r--r--test/integration/targets/known_hosts/tasks/main.yml106
-rw-r--r--test/integration/targets/lineinfile/aliases1
-rw-r--r--test/integration/targets/lineinfile/tasks/acls.yml54
-rw-r--r--test/integration/targets/lineinfile/tasks/main.yml55
-rw-r--r--test/integration/targets/lookup_csvfile/tasks/main.yml1
-rw-r--r--test/integration/targets/lookup_first_found/tasks/main.yml5
-rw-r--r--test/integration/targets/lookup_password/aliases1
-rwxr-xr-xtest/integration/targets/lookup_password/runme.sh4
-rw-r--r--test/integration/targets/lookup_sequence/tasks/main.yml8
-rw-r--r--test/integration/targets/loop-connection/collections/ansible_collections/ns/name/plugins/connection/dummy.py1
-rw-r--r--test/integration/targets/missing_required_lib/library/missing_required_lib.py3
-rw-r--r--test/integration/targets/module_defaults/action_plugins/debug.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/othercoll/plugins/action/other_echoaction.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/othercoll/plugins/modules/other_echo1.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/meta/runtime.yml2
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/echoaction.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/eos.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/ios.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/vyos.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/module_utils/echo_impl.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/echo1.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/echo2.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/eosfacts.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/ios_facts.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/metadata.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/module.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/ping.py3
-rw-r--r--test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/vyosfacts.py3
-rw-r--r--test/integration/targets/module_defaults/library/legacy_ping.py3
-rw-r--r--test/integration/targets/module_defaults/library/test_module_defaults.py3
-rw-r--r--test/integration/targets/module_no_log/library/module_that_has_secret.py3
-rw-r--r--test/integration/targets/module_no_log/library/module_that_logs.py3
-rw-r--r--test/integration/targets/module_precedence/lib_no_extension/ping3
-rw-r--r--test/integration/targets/module_precedence/lib_with_extension/a.ini3
-rw-r--r--test/integration/targets/module_precedence/lib_with_extension/a.py3
-rw-r--r--test/integration/targets/module_precedence/lib_with_extension/ping.ini3
-rw-r--r--test/integration/targets/module_precedence/lib_with_extension/ping.py3
-rw-r--r--test/integration/targets/module_precedence/multiple_roles/bar/library/ping.py3
-rw-r--r--test/integration/targets/module_precedence/multiple_roles/foo/library/ping.py3
-rw-r--r--test/integration/targets/module_precedence/roles_no_extension/foo/library/ping3
-rw-r--r--test/integration/targets/module_precedence/roles_with_extension/foo/library/a.ini3
-rw-r--r--test/integration/targets/module_precedence/roles_with_extension/foo/library/a.py3
-rw-r--r--test/integration/targets/module_precedence/roles_with_extension/foo/library/ping.ini3
-rw-r--r--test/integration/targets/module_precedence/roles_with_extension/foo/library/ping.py3
-rw-r--r--test/integration/targets/module_utils/aliases1
-rw-r--r--test/integration/targets/module_utils/callback/pure_json.py3
-rw-r--r--test/integration/targets/module_utils/collections/ansible_collections/testns/testcoll/plugins/module_utils/legit.py3
-rw-r--r--test/integration/targets/module_utils/library/test.py2
-rw-r--r--test/integration/targets/module_utils/library/test_alias_deprecation.py3
-rw-r--r--test/integration/targets/module_utils/library/test_cwd_missing.py3
-rw-r--r--test/integration/targets/module_utils/library/test_cwd_unreadable.py3
-rw-r--r--test/integration/targets/module_utils/library/test_datetime.py3
-rw-r--r--test/integration/targets/module_utils/library/test_env_override.py3
-rw-r--r--test/integration/targets/module_utils/library/test_failure.py3
-rw-r--r--test/integration/targets/module_utils/library/test_heuristic_log_sanitize.py51
-rw-r--r--test/integration/targets/module_utils/library/test_network.py3
-rw-r--r--test/integration/targets/module_utils/library/test_no_log.py3
-rw-r--r--test/integration/targets/module_utils/library/test_optional.py3
-rw-r--r--test/integration/targets/module_utils/library/test_override.py3
-rw-r--r--test/integration/targets/module_utils/library/test_recursive_diff.py3
-rw-r--r--test/integration/targets/module_utils/module_utils_test.yml4
-rw-r--r--test/integration/targets/module_utils_Ansible.Basic/library/ansible_basic_tests.ps129
-rw-r--r--test/integration/targets/module_utils_ansible_release/library/ansible_release.py3
-rw-r--r--test/integration/targets/module_utils_common.respawn/library/respawnme.py3
-rw-r--r--test/integration/targets/module_utils_urls/library/test_peercert.py3
-rw-r--r--test/integration/targets/no_log/library/module.py3
-rw-r--r--test/integration/targets/old_style_cache_plugins/plugins/cache/configurable_redis.py3
-rw-r--r--test/integration/targets/old_style_cache_plugins/plugins/cache/legacy_redis.py3
-rw-r--r--test/integration/targets/old_style_cache_plugins/plugins/inventory/test.py3
-rw-r--r--test/integration/targets/old_style_vars_plugins/deprecation_warning/v2_vars_plugin.py3
-rw-r--r--test/integration/targets/old_style_vars_plugins/deprecation_warning/vars.py2
-rw-r--r--test/integration/targets/old_style_vars_plugins/vars_plugins/auto_enabled.py2
-rw-r--r--test/integration/targets/old_style_vars_plugins/vars_plugins/implicitly_auto_enabled.py2
-rw-r--r--test/integration/targets/old_style_vars_plugins/vars_plugins/require_enabled.py2
-rw-r--r--test/integration/targets/omit/aliases1
-rw-r--r--test/integration/targets/package/tasks/main.yml38
-rwxr-xr-xtest/integration/targets/packaging_cli-doc/verify.py1
-rwxr-xr-xtest/integration/targets/pause/test-pause.py3
-rw-r--r--test/integration/targets/pip/aliases1
-rw-r--r--test/integration/targets/pip/files/ansible_test_pip_chdir/__init__.py3
-rw-r--r--test/integration/targets/pip/files/sample-project/pyproject.toml7
-rw-r--r--test/integration/targets/pip/files/sample-project/src/sample_project/__init__.py0
-rwxr-xr-xtest/integration/targets/pip/files/setup.py3
-rw-r--r--test/integration/targets/pip/tasks/break_system_packages.yml59
-rw-r--r--test/integration/targets/pip/tasks/main.yml3
-rw-r--r--test/integration/targets/pip/vars/main.yml1
-rw-r--r--test/integration/targets/pkg_resources/lookup_plugins/check_pkg_resources.py3
-rw-r--r--test/integration/targets/plugin_config_for_inventory/cache_plugins/none.py3
-rw-r--r--test/integration/targets/plugin_config_for_inventory/test_inventory.py3
-rw-r--r--test/integration/targets/plugin_loader/collections/ansible_collections/n/c/plugins/action/a.py2
-rw-r--r--test/integration/targets/plugin_loader/normal/action_plugins/self_referential.py3
-rw-r--r--test/integration/targets/plugin_loader/normal/library/_underscore.py3
-rw-r--r--test/integration/targets/plugin_loader/override/filter_plugins/core.py4
-rwxr-xr-xtest/integration/targets/plugin_loader/runme.sh2
-rw-r--r--test/integration/targets/plugin_namespace/filter_plugins/test_filter.py3
-rw-r--r--test/integration/targets/plugin_namespace/lookup_plugins/lookup_name.py3
-rw-r--r--test/integration/targets/plugin_namespace/test_plugins/test_test.py3
-rw-r--r--test/integration/targets/prepare_http_tests/files/openssl_legacy.cnf14
-rw-r--r--test/integration/targets/prepare_http_tests/library/httptester_kinit.py3
-rw-r--r--test/integration/targets/prepare_http_tests/tasks/kerberos.yml24
-rw-r--r--test/integration/targets/rel_plugin_loading/subdir/inventory_plugins/notyaml.py7
-rw-r--r--test/integration/targets/result_pickle_error/action_plugins/result_pickle_error.py3
-rw-r--r--test/integration/targets/roles/no_outside_import.yml6
-rw-r--r--test/integration/targets/roles/privacy.yml22
-rw-r--r--test/integration/targets/roles/roles/a/tasks/subdir/entrypoint.yml1
-rwxr-xr-xtest/integration/targets/roles/runme.sh20
-rw-r--r--test/integration/targets/roles/test_subdirs.yml10
-rw-r--r--test/integration/targets/run_modules/library/test.py3
-rw-r--r--test/integration/targets/script/files/no_shebang.py3
-rw-r--r--test/integration/targets/script/tasks/main.yml2
-rw-r--r--test/integration/targets/service/files/ansible_test_service.py3
-rw-r--r--test/integration/targets/service/tasks/main.yml2
-rw-r--r--test/integration/targets/service/tasks/upstart_cleanup.yml2
-rw-r--r--test/integration/targets/service_facts/files/ansible_test_service.py3
-rwxr-xr-xtest/integration/targets/set_fact/runme.sh3
-rw-r--r--test/integration/targets/set_fact/set_fact_ansible_vars.yml9
-rw-r--r--test/integration/targets/setup_deb_repo/files/package_specs/stable/baz-1.0.011
-rw-r--r--test/integration/targets/setup_epel/tasks/main.yml10
-rw-r--r--test/integration/targets/setup_paramiko/constraints.txt1
-rw-r--r--test/integration/targets/setup_paramiko/library/detect_paramiko.py3
-rwxr-xr-xtest/integration/targets/setup_passlib_controller/runme.sh12
-rw-r--r--test/integration/targets/setup_pexpect/files/constraints.txt1
-rw-r--r--test/integration/targets/setup_rpm_repo/aliases1
-rw-r--r--test/integration/targets/setup_rpm_repo/library/create_repo.py61
-rw-r--r--test/integration/targets/setup_rpm_repo/tasks/main.yml7
-rw-r--r--test/integration/targets/shell/action_plugins/test_shell.py4
-rw-r--r--test/integration/targets/shell/connection_plugins/test_connection_default.py3
-rw-r--r--test/integration/targets/shell/connection_plugins/test_connection_override.py3
-rw-r--r--test/integration/targets/slurp/aliases1
-rw-r--r--test/integration/targets/subversion/roles/subversion/defaults/main.yml6
-rw-r--r--test/integration/targets/subversion/roles/subversion/tasks/setup.yml25
-rw-r--r--test/integration/targets/subversion/roles/subversion/tasks/setup_selinux.yml11
-rw-r--r--test/integration/targets/subversion/roles/subversion/templates/subversion.conf.j26
-rw-r--r--test/integration/targets/support-callback_plugins/callback_plugins/callback_debug.py14
-rw-r--r--test/integration/targets/template/ansible_managed.yml56
-rw-r--r--test/integration/targets/template/ansible_managed_79129.yml29
-rw-r--r--test/integration/targets/template/ansible_managed_templated.cfg2
-rw-r--r--test/integration/targets/template/role_filter/filter_plugins/myplugin.py3
-rwxr-xr-xtest/integration/targets/template/runme.sh6
-rw-r--r--test/integration/targets/template/tasks/main.yml2
-rw-r--r--test/integration/targets/templating_lookups/template_lookups/mock_lookup_plugins/77788.py2
-rwxr-xr-xtest/integration/targets/test_utils/scripts/timeout.py1
-rwxr-xr-xtest/integration/targets/throttle/test_throttle.py3
-rw-r--r--test/integration/targets/unarchive/aliases1
-rw-r--r--test/integration/targets/unarchive/tasks/prepare_tests.yml2
-rw-r--r--test/integration/targets/unarchive/tasks/test_download.yml22
-rw-r--r--test/integration/targets/unarchive/tasks/test_missing_binaries.yml4
-rw-r--r--test/integration/targets/unarchive/tasks/test_symlink.yml62
-rw-r--r--test/integration/targets/unexpected_executor_exception/action_plugins/unexpected.py2
-rw-r--r--test/integration/targets/until/action_plugins/shell_no_failed.py3
-rw-r--r--test/integration/targets/uri/files/testserver.py26
-rw-r--r--test/integration/targets/uri/tasks/install-socat-and-test-unix-socket.yml25
-rw-r--r--test/integration/targets/uri/tasks/main.yml171
-rw-r--r--test/integration/targets/uri/tasks/unix-socket.yml36
-rw-r--r--test/integration/targets/uri/tasks/use_netrc.yml6
-rw-r--r--test/integration/targets/uri/vars/main.yml20
-rw-r--r--test/integration/targets/user/tasks/test_create_user_password.yml14
-rw-r--r--test/integration/targets/user/tasks/test_local.yml2
-rwxr-xr-xtest/integration/targets/var_precedence/ansible-var-precedence-check.py3
-rw-r--r--test/integration/targets/wait_for/files/testserver.py22
-rw-r--r--test/integration/targets/wait_for/files/write_utf16.py3
-rw-r--r--test/integration/targets/wait_for/files/zombie.py3
-rw-r--r--test/integration/targets/wait_for/tasks/main.yml10
-rw-r--r--test/integration/targets/want_json_modules_posix/library/helloworld.py3
-rw-r--r--test/integration/targets/win_exec_wrapper/action_plugins/test_rc_1.py1
-rw-r--r--test/integration/targets/yum/aliases4
-rw-r--r--test/integration/targets/yum/files/yum.conf5
-rw-r--r--test/integration/targets/yum/filter_plugins/filter_list_of_tuples_by_first_param.py23
-rw-r--r--test/integration/targets/yum/meta/main.yml4
-rw-r--r--test/integration/targets/yum/tasks/cacheonly.yml16
-rw-r--r--test/integration/targets/yum/tasks/check_mode_consistency.yml61
-rw-r--r--test/integration/targets/yum/tasks/lock.yml28
-rw-r--r--test/integration/targets/yum/tasks/main.yml82
-rw-r--r--test/integration/targets/yum/tasks/multiarch.yml154
-rw-r--r--test/integration/targets/yum/tasks/proxy.yml186
-rw-r--r--test/integration/targets/yum/tasks/repo.yml729
-rw-r--r--test/integration/targets/yum/tasks/yum.yml884
-rw-r--r--test/integration/targets/yum/tasks/yum_group_remove.yml152
-rw-r--r--test/integration/targets/yum/tasks/yuminstallroot.yml132
-rw-r--r--test/integration/targets/yum/vars/main.yml1
-rw-r--r--test/lib/ansible_test/__init__.py3
-rw-r--r--test/lib/ansible_test/_data/completion/docker.txt16
-rw-r--r--test/lib/ansible_test/_data/completion/remote.txt13
-rw-r--r--test/lib/ansible_test/_data/requirements/ansible-test.txt2
-rw-r--r--test/lib/ansible_test/_data/requirements/constraints.txt8
-rw-r--r--test/lib/ansible_test/_data/requirements/sanity.ansible-doc.txt6
-rw-r--r--test/lib/ansible_test/_data/requirements/sanity.changelog.txt6
-rw-r--r--test/lib/ansible_test/_data/requirements/sanity.import.plugin.txt4
-rw-r--r--test/lib/ansible_test/_data/requirements/sanity.mypy.txt24
-rw-r--r--test/lib/ansible_test/_data/requirements/sanity.pep8.txt2
-rw-r--r--test/lib/ansible_test/_data/requirements/sanity.pylint.txt14
-rw-r--r--test/lib/ansible_test/_data/requirements/sanity.runtime-metadata.txt2
-rw-r--r--test/lib/ansible_test/_data/requirements/sanity.validate-modules.txt6
-rw-r--r--test/lib/ansible_test/_data/requirements/sanity.yamllint.txt4
-rw-r--r--test/lib/ansible_test/_internal/bootstrap.py4
-rw-r--r--test/lib/ansible_test/_internal/classification/__init__.py5
-rw-r--r--test/lib/ansible_test/_internal/commands/integration/cloud/cs.py2
-rw-r--r--test/lib/ansible_test/_internal/commands/integration/cloud/nios.py2
-rw-r--r--test/lib/ansible_test/_internal/commands/sanity/__init__.py28
-rw-r--r--test/lib/ansible_test/_internal/commands/sanity/import.py18
-rw-r--r--test/lib/ansible_test/_internal/commands/sanity/mypy.py17
-rw-r--r--test/lib/ansible_test/_internal/commands/units/__init__.py2
-rw-r--r--test/lib/ansible_test/_internal/config.py1
-rw-r--r--test/lib/ansible_test/_internal/content_config.py5
-rw-r--r--test/lib/ansible_test/_internal/coverage_util.py1
-rw-r--r--test/lib/ansible_test/_internal/docker_util.py2
-rw-r--r--test/lib/ansible_test/_internal/host_profiles.py9
-rw-r--r--test/lib/ansible_test/_internal/python_requirements.py120
-rw-r--r--test/lib/ansible_test/_internal/ssh.py1
-rw-r--r--test/lib/ansible_test/_internal/util.py2
-rw-r--r--test/lib/ansible_test/_internal/util_common.py2
-rw-r--r--test/lib/ansible_test/_internal/venv.py118
-rw-r--r--test/lib/ansible_test/_util/__init__.py3
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/future-import-boilerplate.py46
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/metaclass-boilerplate.json7
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/metaclass-boilerplate.py44
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/no-basestring.json7
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/no-basestring.py21
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iteritems.json7
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iteritems.py21
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iterkeys.json7
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iterkeys.py21
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-itervalues.json7
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-itervalues.py21
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/no-main-display.json10
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/no-main-display.py21
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/no-unicode-literals.json7
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/code-smell/no-unicode-literals.py21
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/mypy/ansible-core.ini6
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/mypy/modules.ini6
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test-target.cfg1
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test.cfg1
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/pylint/config/code-smell.cfg1
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/pylint/config/collection.cfg1
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/pylint/config/default.cfg1
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/pylint/plugins/deprecated.py3
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/shellcheck/exclude.txt1
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py90
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/module_args.py7
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/schema.py12
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/utils.py2
-rw-r--r--test/lib/ansible_test/_util/controller/sanity/yamllint/yamllinter.py20
-rw-r--r--test/lib/ansible_test/_util/controller/tools/sslcheck.py22
-rw-r--r--test/lib/ansible_test/_util/target/__init__.py3
-rwxr-xr-xtest/lib/ansible_test/_util/target/cli/ansible_test_cli_stub.py3
-rw-r--r--test/lib/ansible_test/_util/target/common/__init__.py2
-rw-r--r--test/lib/ansible_test/_util/target/common/constants.py5
-rw-r--r--test/lib/ansible_test/_util/target/injector/python.py23
-rw-r--r--test/lib/ansible_test/_util/target/pytest/plugins/ansible_forked.py11
-rw-r--r--test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_collections.py6
-rw-r--r--test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_coverage.py3
-rw-r--r--test/lib/ansible_test/_util/target/sanity/compile/compile.py15
-rw-r--r--test/lib/ansible_test/_util/target/sanity/import/importer.py13
-rw-r--r--test/lib/ansible_test/_util/target/setup/bootstrap.sh154
-rw-r--r--test/lib/ansible_test/_util/target/setup/probe_cgroups.py3
-rw-r--r--test/lib/ansible_test/_util/target/setup/quiet_pip.py17
-rw-r--r--test/lib/ansible_test/_util/target/setup/requirements.py11
-rw-r--r--test/lib/ansible_test/_util/target/tools/virtualenvcheck.py3
-rw-r--r--test/lib/ansible_test/_util/target/tools/yamlcheck.py3
-rw-r--r--test/sanity/code-smell/ansible-test-future-boilerplate.json10
-rw-r--r--test/sanity/code-smell/boilerplate.json (renamed from test/lib/ansible_test/_util/controller/sanity/code-smell/future-import-boilerplate.json)1
-rw-r--r--test/sanity/code-smell/boilerplate.py (renamed from test/sanity/code-smell/ansible-test-future-boilerplate.py)13
-rw-r--r--test/sanity/code-smell/deprecated-config.py3
-rw-r--r--test/sanity/code-smell/deprecated-config.requirements.txt4
-rw-r--r--test/sanity/code-smell/no-unwanted-characters.json4
-rw-r--r--test/sanity/code-smell/no-unwanted-characters.py27
-rw-r--r--test/sanity/code-smell/package-data.requirements.txt14
-rw-r--r--test/sanity/code-smell/pymarkdown.requirements.txt10
-rw-r--r--test/sanity/code-smell/test-constraints.py7
-rw-r--r--test/sanity/code-smell/update-bundled.py1
-rw-r--r--test/sanity/code-smell/update-bundled.requirements.txt2
-rw-r--r--test/sanity/ignore.txt30
-rw-r--r--test/support/integration/plugins/filter/json_query.py53
-rw-r--r--test/support/integration/plugins/modules/pkgng.py3
-rw-r--r--test/support/integration/plugins/modules/sefcontext.py308
-rw-r--r--test/support/integration/plugins/modules/timezone.py3
-rw-r--r--test/support/integration/plugins/modules/zypper.py539
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/cli_config.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/net_get.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/net_put.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/network.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/connection/network_cli.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/connection/persistent.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/doc_fragments/connection_persistent.py4
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/compat/ipaddress.py2
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/cfg/base.py1
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/config.py2
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/facts/facts.py2
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/netconf.py2
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/network.py1
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/parsing.py1
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/utils.py1
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/modules/cli_config.py4
-rw-r--r--test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/plugin_utils/connection_base.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/action/ios.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/doc_fragments/ios.py1
-rw-r--r--test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/module_utils/network/ios/ios.py2
-rw-r--r--test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/modules/ios_command.py1
-rw-r--r--test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/modules/ios_config.py1
-rw-r--r--test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/terminal/ios.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/action/vyos.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/cliconf/vyos.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/doc_fragments/vyos.py1
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/facts/facts.py4
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py4
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py4
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py4
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py4
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py4
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py4
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py4
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py4
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/facts.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py4
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py4
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/legacy/base.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py4
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/utils/utils.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/vyos.py2
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_command.py1
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_config.py1
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_facts.py1
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp_interfaces.py3
-rw-r--r--test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/terminal/vyos.py3
-rw-r--r--test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/action/win_copy.py6
-rw-r--r--test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/action/win_reboot.py3
-rw-r--r--test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/plugin_utils/_quote.py3
-rw-r--r--test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/plugin_utils/_reboot.py1
-rw-r--r--test/support/windows-integration/plugins/action/win_copy.py6
-rw-r--r--test/support/windows-integration/plugins/action/win_reboot.py3
-rw-r--r--test/support/windows-integration/plugins/action/win_template.py4
-rw-r--r--test/support/windows-integration/plugins/become/runas.py3
-rw-r--r--test/units/_vendor/test_vendor.py1
-rw-r--r--test/units/ansible_test/ci/test_azp.py3
-rw-r--r--test/units/ansible_test/ci/util.py3
-rw-r--r--test/units/ansible_test/conftest.py3
-rw-r--r--test/units/ansible_test/test_diff.py2
-rw-r--r--test/units/ansible_test/test_validate_modules.py63
-rw-r--r--test/units/cli/arguments/test_optparse_helpers.py3
-rw-r--r--test/units/cli/galaxy/test_collection_extract_tar.py3
-rw-r--r--test/units/cli/galaxy/test_display_collection.py3
-rw-r--r--test/units/cli/galaxy/test_display_header.py3
-rw-r--r--test/units/cli/galaxy/test_display_role.py3
-rw-r--r--test/units/cli/galaxy/test_execute_list.py3
-rw-r--r--test/units/cli/galaxy/test_execute_list_collection.py3
-rw-r--r--test/units/cli/galaxy/test_get_collection_widths.py3
-rw-r--r--test/units/cli/test_adhoc.py3
-rw-r--r--test/units/cli/test_cli.py34
-rw-r--r--test/units/cli/test_console.py6
-rw-r--r--test/units/cli/test_data/role_skeleton/meta/main.yml.j218
-rw-r--r--test/units/cli/test_doc.py16
-rw-r--r--test/units/cli/test_galaxy.py11
-rw-r--r--test/units/cli/test_playbook.py6
-rw-r--r--test/units/cli/test_vault.py6
-rw-r--r--test/units/compat/mock.py23
-rw-r--r--test/units/compat/unittest.py29
-rw-r--r--test/units/config/manager/test_find_ini_config_file.py4
-rw-r--r--test/units/config/test_manager.py59
-rw-r--r--test/units/errors/test_errors.py6
-rw-r--r--test/units/executor/module_common/conftest.py2
-rw-r--r--test/units/executor/module_common/test_modify_module.py3
-rw-r--r--test/units/executor/module_common/test_module_common.py4
-rw-r--r--test/units/executor/module_common/test_recursive_finder.py7
-rw-r--r--test/units/executor/test_interpreter_discovery.py46
-rw-r--r--test/units/executor/test_play_iterator.py6
-rw-r--r--test/units/executor/test_playbook_executor.py6
-rw-r--r--test/units/executor/test_task_executor.py11
-rw-r--r--test/units/executor/test_task_queue_manager_callbacks.py7
-rw-r--r--test/units/executor/test_task_result.py6
-rw-r--r--test/units/galaxy/test_api.py17
-rw-r--r--test/units/galaxy/test_collection.py38
-rw-r--r--test/units/galaxy/test_collection_install.py21
-rw-r--r--test/units/galaxy/test_role_install.py4
-rw-r--r--test/units/galaxy/test_role_requirements.py4
-rw-r--r--test/units/galaxy/test_token.py4
-rw-r--r--test/units/galaxy/test_user_agent.py3
-rw-r--r--test/units/inventory/test_group.py5
-rw-r--r--test/units/inventory/test_host.py8
-rw-r--r--test/units/mock/loader.py6
-rw-r--r--test/units/mock/path.py3
-rw-r--r--test/units/mock/procenv.py14
-rw-r--r--test/units/mock/vault_helper.py4
-rw-r--r--test/units/mock/yaml_helper.py3
-rw-r--r--test/units/module_utils/basic/test__log_invocation.py3
-rw-r--r--test/units/module_utils/basic/test__symbolic_mode_to_octal.py4
-rw-r--r--test/units/module_utils/basic/test_argument_spec.py32
-rw-r--r--test/units/module_utils/basic/test_atomic_move.py24
-rw-r--r--test/units/module_utils/basic/test_command_nonexisting.py3
-rw-r--r--test/units/module_utils/basic/test_deprecate_warn.py3
-rw-r--r--test/units/module_utils/basic/test_dict_converters.py5
-rw-r--r--test/units/module_utils/basic/test_exit_json.py8
-rw-r--r--test/units/module_utils/basic/test_filesystem.py9
-rw-r--r--test/units/module_utils/basic/test_get_available_hash_algorithms.py34
-rw-r--r--test/units/module_utils/basic/test_get_file_attributes.py4
-rw-r--r--test/units/module_utils/basic/test_get_module_path.py7
-rw-r--r--test/units/module_utils/basic/test_heuristic_log_sanitize.py6
-rw-r--r--test/units/module_utils/basic/test_imports.py48
-rw-r--r--test/units/module_utils/basic/test_log.py88
-rw-r--r--test/units/module_utils/basic/test_no_log.py7
-rw-r--r--test/units/module_utils/basic/test_platform_distribution.py7
-rw-r--r--test/units/module_utils/basic/test_run_command.py27
-rw-r--r--test/units/module_utils/basic/test_safe_eval.py4
-rw-r--r--test/units/module_utils/basic/test_sanitize_keys.py4
-rw-r--r--test/units/module_utils/basic/test_selinux.py7
-rw-r--r--test/units/module_utils/basic/test_set_cwd.py6
-rw-r--r--test/units/module_utils/basic/test_set_mode_if_different.py10
-rw-r--r--test/units/module_utils/basic/test_tmpdir.py8
-rw-r--r--test/units/module_utils/common/arg_spec/test_aliases.py3
-rw-r--r--test/units/module_utils/common/arg_spec/test_module_validate.py3
-rw-r--r--test/units/module_utils/common/arg_spec/test_sub_spec.py3
-rw-r--r--test/units/module_utils/common/arg_spec/test_validate_invalid.py7
-rw-r--r--test/units/module_utils/common/arg_spec/test_validate_valid.py3
-rw-r--r--test/units/module_utils/common/parameters/test_check_arguments.py19
-rw-r--r--test/units/module_utils/common/parameters/test_handle_aliases.py3
-rw-r--r--test/units/module_utils/common/parameters/test_list_deprecations.py3
-rw-r--r--test/units/module_utils/common/parameters/test_list_no_log_values.py5
-rw-r--r--test/units/module_utils/common/process/test_get_bin_path.py3
-rw-r--r--test/units/module_utils/common/test_collections.py5
-rw-r--r--test/units/module_utils/common/test_dict_transformations.py3
-rw-r--r--test/units/module_utils/common/test_locale.py5
-rw-r--r--test/units/module_utils/common/test_network.py4
-rw-r--r--test/units/module_utils/common/test_sys_info.py7
-rw-r--r--test/units/module_utils/common/test_utils.py3
-rw-r--r--test/units/module_utils/common/text/converters/test_container_to_bytes.py3
-rw-r--r--test/units/module_utils/common/text/converters/test_container_to_text.py3
-rw-r--r--test/units/module_utils/common/text/converters/test_json_encode_fallback.py3
-rw-r--r--test/units/module_utils/common/text/converters/test_jsonify.py3
-rw-r--r--test/units/module_utils/common/text/converters/test_to_str.py9
-rw-r--r--test/units/module_utils/common/text/formatters/test_bytes_to_human.py3
-rw-r--r--test/units/module_utils/common/text/formatters/test_human_to_bytes.py3
-rw-r--r--test/units/module_utils/common/text/formatters/test_lenient_lowercase.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_missing_parameters.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_mutually_exclusive.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_required_arguments.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_required_by.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_required_if.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_required_one_of.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_required_together.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_type_bits.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_type_bool.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_type_bytes.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_type_dict.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_type_float.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_type_int.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_type_jsonarg.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_type_list.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_type_path.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_type_raw.py3
-rw-r--r--test/units/module_utils/common/validation/test_check_type_str.py3
-rw-r--r--test/units/module_utils/common/validation/test_count_terms.py3
-rw-r--r--test/units/module_utils/common/warnings/test_deprecate.py6
-rw-r--r--test/units/module_utils/common/warnings/test_warn.py6
-rw-r--r--test/units/module_utils/compat/test_datetime.py10
-rw-r--r--test/units/module_utils/conftest.py16
-rw-r--r--test/units/module_utils/facts/base.py8
-rw-r--r--test/units/module_utils/facts/hardware/aix_data.py3
-rw-r--r--test/units/module_utils/facts/hardware/linux_data.py3
-rw-r--r--test/units/module_utils/facts/hardware/test_aix_processor.py3
-rw-r--r--test/units/module_utils/facts/hardware/test_linux.py9
-rw-r--r--test/units/module_utils/facts/hardware/test_linux_get_cpu_info.py3
-rw-r--r--test/units/module_utils/facts/hardware/test_sunos_get_uptime_facts.py3
-rw-r--r--test/units/module_utils/facts/network/test_fc_wwn.py5
-rw-r--r--test/units/module_utils/facts/network/test_generic_bsd.py8
-rw-r--r--test/units/module_utils/facts/network/test_iscsi_get_initiator.py5
-rw-r--r--test/units/module_utils/facts/network/test_locally_reachable_ips.py8
-rw-r--r--test/units/module_utils/facts/other/test_facter.py6
-rw-r--r--test/units/module_utils/facts/other/test_ohai.py6
-rw-r--r--test/units/module_utils/facts/system/distribution/conftest.py5
-rw-r--r--test/units/module_utils/facts/system/distribution/fixtures/alp-dolomite.json23
-rw-r--r--test/units/module_utils/facts/system/distribution/fixtures/miracle_linux_9.json39
-rw-r--r--test/units/module_utils/facts/system/distribution/test_distribution_sles4sap.py3
-rw-r--r--test/units/module_utils/facts/system/distribution/test_distribution_version.py5
-rw-r--r--test/units/module_utils/facts/system/distribution/test_parse_distribution_file_ClearLinux.py3
-rw-r--r--test/units/module_utils/facts/system/distribution/test_parse_distribution_file_Slackware.py3
-rw-r--r--test/units/module_utils/facts/system/test_cmdline.py3
-rw-r--r--test/units/module_utils/facts/system/test_lsb.py6
-rw-r--r--test/units/module_utils/facts/system/test_pkg_mgr.py34
-rw-r--r--test/units/module_utils/facts/system/test_user.py4
-rw-r--r--test/units/module_utils/facts/test_ansible_collector.py8
-rw-r--r--test/units/module_utils/facts/test_collector.py6
-rw-r--r--test/units/module_utils/facts/test_collectors.py89
-rw-r--r--test/units/module_utils/facts/test_date_time.py3
-rw-r--r--test/units/module_utils/facts/test_facts.py8
-rw-r--r--test/units/module_utils/facts/test_sysctl.py8
-rw-r--r--test/units/module_utils/facts/test_timeout.py4
-rw-r--r--test/units/module_utils/facts/test_utils.py8
-rw-r--r--test/units/module_utils/facts/virtual/test_linux.py3
-rw-r--r--test/units/module_utils/json_utils/test_filter_non_json_lines.py6
-rw-r--r--test/units/module_utils/parsing/test_convert_bool.py4
-rw-r--r--test/units/module_utils/test_api.py3
-rw-r--r--test/units/module_utils/test_connection.py3
-rw-r--r--test/units/module_utils/test_distro.py12
-rw-r--r--test/units/module_utils/test_text.py10
-rw-r--r--test/units/module_utils/urls/test_RedirectHandlerFactory.py67
-rw-r--r--test/units/module_utils/urls/test_Request.py130
-rw-r--r--test/units/module_utils/urls/test_RequestWithMethod.py22
-rw-r--r--test/units/module_utils/urls/test_channel_binding.py3
-rw-r--r--test/units/module_utils/urls/test_fetch_file.py3
-rw-r--r--test/units/module_utils/urls/test_fetch_url.py58
-rw-r--r--test/units/module_utils/urls/test_generic_urlparse.py34
-rw-r--r--test/units/module_utils/urls/test_gzip.py57
-rw-r--r--test/units/module_utils/urls/test_prepare_multipart.py3
-rw-r--r--test/units/module_utils/urls/test_split.py3
-rw-r--r--test/units/module_utils/urls/test_urls.py84
-rw-r--r--test/units/modules/conftest.py3
-rw-r--r--test/units/modules/test_apt.py83
-rw-r--r--test/units/modules/test_apt_key.py7
-rw-r--r--test/units/modules/test_async_wrapper.py3
-rw-r--r--test/units/modules/test_copy.py4
-rw-r--r--test/units/modules/test_hostname.py8
-rw-r--r--test/units/modules/test_iptables.py2574
-rw-r--r--test/units/modules/test_known_hosts.py5
-rw-r--r--test/units/modules/test_pip.py3
-rw-r--r--test/units/modules/test_service.py6
-rw-r--r--test/units/modules/test_service_facts.py7
-rw-r--r--test/units/modules/test_systemd.py5
-rw-r--r--test/units/modules/test_unarchive.py4
-rw-r--r--test/units/modules/test_uri.py43
-rw-r--r--test/units/modules/test_yum.py222
-rw-r--r--test/units/modules/utils.py7
-rw-r--r--test/units/parsing/test_ajson.py3
-rw-r--r--test/units/parsing/test_dataloader.py23
-rw-r--r--test/units/parsing/test_mod_args.py3
-rw-r--r--test/units/parsing/test_splitter.py4
-rw-r--r--test/units/parsing/test_unquote.py4
-rw-r--r--test/units/parsing/utils/test_addresses.py3
-rw-r--r--test/units/parsing/utils/test_jsonify.py5
-rw-r--r--test/units/parsing/utils/test_yaml.py3
-rw-r--r--test/units/parsing/vault/test_vault.py19
-rw-r--r--test/units/parsing/vault/test_vault_editor.py6
-rw-r--r--test/units/parsing/yaml/test_constructor.py3
-rw-r--r--test/units/parsing/yaml/test_dumper.py6
-rw-r--r--test/units/parsing/yaml/test_loader.py21
-rw-r--r--test/units/parsing/yaml/test_objects.py6
-rw-r--r--test/units/playbook/role/test_include_role.py12
-rw-r--r--test/units/playbook/role/test_role.py6
-rw-r--r--test/units/playbook/test_attribute.py5
-rw-r--r--test/units/playbook/test_base.py11
-rw-r--r--test/units/playbook/test_block.py6
-rw-r--r--test/units/playbook/test_collectionsearch.py3
-rw-r--r--test/units/playbook/test_conditional.py5
-rw-r--r--test/units/playbook/test_helpers.py6
-rw-r--r--test/units/playbook/test_included_file.py7
-rw-r--r--test/units/playbook/test_play.py4
-rw-r--r--test/units/playbook/test_play_context.py4
-rw-r--r--test/units/playbook/test_playbook.py6
-rw-r--r--test/units/playbook/test_taggable.py6
-rw-r--r--test/units/playbook/test_task.py6
-rw-r--r--test/units/plugins/action/test_action.py12
-rw-r--r--test/units/plugins/action/test_gather_facts.py5
-rw-r--r--test/units/plugins/action/test_raw.py42
-rw-r--r--test/units/plugins/action/test_reboot.py4
-rw-r--r--test/units/plugins/become/conftest.py4
-rw-r--r--test/units/plugins/become/test_su.py4
-rw-r--r--test/units/plugins/become/test_sudo.py4
-rw-r--r--test/units/plugins/cache/test_cache.py6
-rw-r--r--test/units/plugins/callback/test_callback.py6
-rw-r--r--test/units/plugins/connection/test_connection.py6
-rw-r--r--test/units/plugins/connection/test_local.py6
-rw-r--r--test/units/plugins/connection/test_paramiko_ssh.py4
-rw-r--r--test/units/plugins/connection/test_psrp.py4
-rw-r--r--test/units/plugins/connection/test_ssh.py94
-rw-r--r--test/units/plugins/connection/test_winrm.py4
-rw-r--r--test/units/plugins/filter/test_core.py3
-rw-r--r--test/units/plugins/inventory/test_constructed.py3
-rw-r--r--test/units/plugins/inventory/test_inventory.py11
-rw-r--r--test/units/plugins/inventory/test_script.py6
-rw-r--r--test/units/plugins/loader_fixtures/import_fixture.py3
-rw-r--r--test/units/plugins/lookup/test_env.py8
-rw-r--r--test/units/plugins/lookup/test_ini.py6
-rw-r--r--test/units/plugins/lookup/test_password.py19
-rw-r--r--test/units/plugins/lookup/test_url.py3
-rw-r--r--test/units/plugins/shell/test_cmd.py3
-rw-r--r--test/units/plugins/shell/test_powershell.py3
-rw-r--r--test/units/plugins/strategy/test_linear.py6
-rw-r--r--test/units/plugins/test_plugins.py6
-rw-r--r--test/units/regex/test_invalid_var_names.py6
-rw-r--r--test/units/template/test_native_concat.py4
-rw-r--r--test/units/template/test_templar.py6
-rw-r--r--test/units/template/test_template_utilities.py6
-rw-r--r--test/units/template/test_vars.py4
-rw-r--r--test/units/test_context.py4
-rw-r--r--test/units/test_no_tty.py2
-rw-r--r--test/units/utils/collection_loader/fixtures/collections/ansible_collections/ansible/builtin/plugins/modules/shouldnotload.py5
-rw-r--r--test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/action/my_action.py5
-rw-r--r--test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/module_utils/my_other_util.py3
-rw-r--r--test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/module_utils/my_util.py4
-rw-r--r--test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/modules/__init__.py5
-rw-r--r--test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/modules/amodule.py6
-rw-r--r--test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/__init__.py5
-rw-r--r--test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/ansible/__init__.py5
-rw-r--r--test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/__init__.py5
-rw-r--r--test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/testcoll/__init__.py5
-rw-r--r--test/units/utils/collection_loader/test_collection_loader.py59
-rw-r--r--test/units/utils/display/test_broken_cowsay.py4
-rw-r--r--test/units/utils/display/test_curses.py3
-rw-r--r--test/units/utils/display/test_display.py3
-rw-r--r--test/units/utils/display/test_logger.py3
-rw-r--r--test/units/utils/display/test_warning.py3
-rw-r--r--test/units/utils/test_cleanup_tmp_file.py3
-rw-r--r--test/units/utils/test_context_objects.py3
-rw-r--r--test/units/utils/test_display.py3
-rw-r--r--test/units/utils/test_encrypt.py101
-rw-r--r--test/units/utils/test_helpers.py3
-rw-r--r--test/units/utils/test_isidentifier.py4
-rw-r--r--test/units/utils/test_plugin_docs.py5
-rw-r--r--test/units/utils/test_shlex.py3
-rw-r--r--test/units/utils/test_unsafe_proxy.py3
-rw-r--r--test/units/utils/test_vars.py17
-rw-r--r--test/units/utils/test_version.py3
-rw-r--r--test/units/vars/test_module_response_deepcopy.py3
-rw-r--r--test/units/vars/test_variable_manager.py11
1013 files changed, 6290 insertions, 9600 deletions
diff --git a/test/integration/targets/ansiballz_python/library/check_rlimit_and_maxfd.py b/test/integration/targets/ansiballz_python/library/check_rlimit_and_maxfd.py
index a01ee99..cc3949b 100644
--- a/test/integration/targets/ansiballz_python/library/check_rlimit_and_maxfd.py
+++ b/test/integration/targets/ansiballz_python/library/check_rlimit_and_maxfd.py
@@ -3,8 +3,7 @@
# Copyright 2018 Red Hat | Ansible
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import resource
import subprocess
diff --git a/test/integration/targets/ansiballz_python/library/custom_module.py b/test/integration/targets/ansiballz_python/library/custom_module.py
index 625823e..2436bb2 100644
--- a/test/integration/targets/ansiballz_python/library/custom_module.py
+++ b/test/integration/targets/ansiballz_python/library/custom_module.py
@@ -1,7 +1,6 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ..module_utils.basic import AnsibleModule # pylint: disable=relative-beyond-top-level
from ..module_utils.custom_util import forty_two # pylint: disable=relative-beyond-top-level
diff --git a/test/integration/targets/ansiballz_python/library/sys_check.py b/test/integration/targets/ansiballz_python/library/sys_check.py
index aa22fe6..8454c07 100644
--- a/test/integration/targets/ansiballz_python/library/sys_check.py
+++ b/test/integration/targets/ansiballz_python/library/sys_check.py
@@ -2,8 +2,7 @@
# https://github.com/ansible/ansible/issues/64664
# https://github.com/ansible/ansible/issues/64479
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import sys
diff --git a/test/integration/targets/ansiballz_python/module_utils/custom_util.py b/test/integration/targets/ansiballz_python/module_utils/custom_util.py
index 0393db4..c9e7ffd 100644
--- a/test/integration/targets/ansiballz_python/module_utils/custom_util.py
+++ b/test/integration/targets/ansiballz_python/module_utils/custom_util.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
def forty_two():
diff --git a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/cache/notjsonfile.py b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/cache/notjsonfile.py
index 9fa25b4..a6203b9 100644
--- a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/cache/notjsonfile.py
+++ b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/cache/notjsonfile.py
@@ -1,9 +1,7 @@
# (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
cache: notjsonfile
diff --git a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/inventory/statichost.py b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/inventory/statichost.py
index dfc1271..eb5f5f3 100644
--- a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/inventory/statichost.py
+++ b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/inventory/statichost.py
@@ -1,8 +1,7 @@
# Copyright (c) 2018 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
inventory: statichost
diff --git a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/lookup/noop.py b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/lookup/noop.py
index 639d3c6..43ac4b2 100644
--- a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/lookup/noop.py
+++ b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/lookup/noop.py
@@ -1,10 +1,8 @@
# (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
+from __future__ import annotations
-__metaclass__ = type
DOCUMENTATION = """
lookup: noop
diff --git a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/fakemodule.py b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/fakemodule.py
index a1caeb1..814cd0a 100644
--- a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/fakemodule.py
+++ b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/fakemodule.py
@@ -1,12 +1,11 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = """
module: fakemodule
broken:
- short_desciption: fake module
+ short_description: fake module
description:
- this is a fake module
version_added: 1.0.0
diff --git a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/notrealmodule.py b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/notrealmodule.py
index 4479f23..b7dcf51 100644
--- a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/notrealmodule.py
+++ b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/notrealmodule.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/randommodule.py b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/randommodule.py
index fb0e319..b017112 100644
--- a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/randommodule.py
+++ b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/modules/randommodule.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/vars/noop_vars_plugin.py b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/vars/noop_vars_plugin.py
index ae0f75e..61de5f4 100644
--- a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/vars/noop_vars_plugin.py
+++ b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/vars/noop_vars_plugin.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
vars: noop_vars_plugin
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/cache/notjsonfile.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/cache/notjsonfile.py
index ea4a722..32abc43 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/cache/notjsonfile.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/cache/notjsonfile.py
@@ -1,9 +1,7 @@
# (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
cache: notjsonfile
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/filter/filter_subdir/in_subdir.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/filter/filter_subdir/in_subdir.py
index a8924e1..d912c02 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/filter/filter_subdir/in_subdir.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/filter/filter_subdir/in_subdir.py
@@ -1,8 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.utils.display import Display
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/filter/grouped.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/filter/grouped.py
index a10c7aa..47ac9c4 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/filter/grouped.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/filter/grouped.py
@@ -1,8 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.utils.display import Display
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/inventory/statichost.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/inventory/statichost.py
index 1870b8e..60c60f9 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/inventory/statichost.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/inventory/statichost.py
@@ -1,8 +1,7 @@
# Copyright (c) 2018 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
inventory: statichost
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/lookup/noop.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/lookup/noop.py
index 7a64a5d..7f69395 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/lookup/noop.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/lookup/noop.py
@@ -1,10 +1,8 @@
# (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
+from __future__ import annotations
-__metaclass__ = type
DOCUMENTATION = """
lookup: noop
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/database/database_type/subdir_module.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/database/database_type/subdir_module.py
index dd41305..a7bcf50 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/database/database_type/subdir_module.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/database/database_type/subdir_module.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/fakemodule.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/fakemodule.py
index 6d18c08..39c4c61 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/fakemodule.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/fakemodule.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = """
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/notrealmodule.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/notrealmodule.py
index 4479f23..b7dcf51 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/notrealmodule.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/notrealmodule.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/randommodule.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/randommodule.py
index aaaecb8..81e8fb8 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/randommodule.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/randommodule.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = r'''
@@ -65,6 +64,15 @@ seealso:
description: See also the Ansible docsite.
- ref: foo_bar
description: Some foo bar.
+notes:
+ - This is a note.
+ - |-
+ This is a multi-paragraph note.
+
+ This is its second paragraph.
+ This is just another line in the second paragraph.
+ Eventually this will break into a new line,
+ depending with which line width this is rendered.
'''
EXAMPLES = '''
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/test/test_test.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/test/test_test.py
index f1c2b3a..160256c 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/test/test_test.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/test/test_test.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def yolo(value):
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/vars/noop_vars_plugin.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/vars/noop_vars_plugin.py
index 94e7feb..93c076b 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/vars/noop_vars_plugin.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/vars/noop_vars_plugin.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
vars: noop_vars_plugin
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/roles/testrole/meta/main.yml b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/roles/testrole/meta/main.yml
index bc6af69..ce79629 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/roles/testrole/meta/main.yml
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/roles/testrole/meta/main.yml
@@ -19,6 +19,10 @@ argument_specs:
description:
- Longer description for testns.testcol.testrole alternate entry point.
author: Ansible Core (@ansible)
+ attributes:
+ check_mode:
+ description: Can run in check_mode and return changed status prediction without modifying target
+ support: full
options:
altopt1:
description: altopt1 description
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/deprecation.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/deprecation.py
index 3942d72..fdb85ab 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/deprecation.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/deprecation.py
@@ -2,8 +2,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class ModuleDocFragment(object):
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/module.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/module.py
index a572363..5fbc352 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/module.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/module.py
@@ -2,8 +2,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class ModuleDocFragment(object):
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/plugin.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/plugin.py
index 2fe4e4a..eddd61e 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/plugin.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/plugin.py
@@ -2,8 +2,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class ModuleDocFragment(object):
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/version_added.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/version_added.py
index 73e5f2f..d901404 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/version_added.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol2/plugins/doc_fragments/version_added.py
@@ -2,8 +2,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class ModuleDocFragment(object):
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol3/plugins/modules/test1.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol3/plugins/modules/test1.py
index 02dfb89..1d2f370 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol3/plugins/modules/test1.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol3/plugins/modules/test1.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = """
diff --git a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol4/plugins/modules/test2.py b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol4/plugins/modules/test2.py
index ddb0c11..d41920b 100644
--- a/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol4/plugins/modules/test2.py
+++ b/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol4/plugins/modules/test2.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = """
diff --git a/test/integration/targets/ansible-doc/fakecollrole.output b/test/integration/targets/ansible-doc/fakecollrole.output
index 3ae9077..77ac928 100644
--- a/test/integration/targets/ansible-doc/fakecollrole.output
+++ b/test/integration/targets/ansible-doc/fakecollrole.output
@@ -1,15 +1,20 @@
-> TESTNS.TESTCOL.TESTROLE (/ansible/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol)
+> ROLE: *testns.testcol.testrole* (test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol)
-ENTRY POINT: alternate - testns.testcol.testrole short description for alternate entry point
+ENTRY POINT: *alternate* - testns.testcol.testrole short description for alternate entry point
- Longer description for testns.testcol.testrole alternate entry
- point.
+ Longer description for testns.testcol.testrole alternate
+ entry point.
-OPTIONS (= is mandatory):
+Options (= indicates it is required):
-= altopt1
- altopt1 description
- type: int
+= altopt1 altopt1 description
+ type: int
+ATTRIBUTES:
+
+ `check_mode:`
+ description: Can run in check_mode and return changed status prediction without modifying
+ target
+ support: full
AUTHOR: Ansible Core (@ansible)
diff --git a/test/integration/targets/ansible-doc/fakemodule.output b/test/integration/targets/ansible-doc/fakemodule.output
index 4fb0776..42fbaad 100644
--- a/test/integration/targets/ansible-doc/fakemodule.output
+++ b/test/integration/targets/ansible-doc/fakemodule.output
@@ -1,16 +1,13 @@
-> TESTNS.TESTCOL.FAKEMODULE (./collections/ansible_collections/testns/testcol/plugins/modules/fakemodule.py)
+> MODULE testns.testcol.fakemodule (./collections/ansible_collections/testns/testcol/plugins/modules/fakemodule.py)
- this is a fake module
+ this is a fake module
-ADDED IN: version 1.0.0 of testns.testcol
+OPTIONS (= indicates it is required):
-OPTIONS (= is mandatory):
-
-- _notreal
- really not a real option
+- _notreal really not a real option
default: null
-
AUTHOR: me
SHORT_DESCIPTION: fake module
+
diff --git a/test/integration/targets/ansible-doc/fakerole.output b/test/integration/targets/ansible-doc/fakerole.output
index bcb53dc..3f4302a 100644
--- a/test/integration/targets/ansible-doc/fakerole.output
+++ b/test/integration/targets/ansible-doc/fakerole.output
@@ -1,32 +1,36 @@
-> TEST_ROLE1 (/ansible/test/integration/targets/ansible-doc/roles/normal_role1)
+> ROLE: *test_role1* (test/integration/targets/ansible-doc/roles/test_role1)
-ENTRY POINT: main - test_role1 from roles subdir
+ENTRY POINT: *main* - test_role1 from roles subdir
- In to am attended desirous raptures *declared* diverted
- confined at. Collected instantly remaining up certainly to
- `necessary' as. Over walk dull into son boy door went new. At
- or happiness commanded daughters as. Is `handsome' an declared
- at received in extended vicinity subjects. Into miss on he
- over been late pain an. Only week bore boy what fat case left
- use. Match round scale now style far times. Your me past an
- much.
+ In to am attended desirous raptures *declared* diverted
+ confined at. Collected instantly remaining up certainly to
+ `necessary' as. Over walk dull into son boy door went new.
+ At or happiness commanded daughters as. Is `handsome` an
+ declared at received in extended vicinity subjects. Into
+ miss on he over been late pain an. Only week bore boy what
+ fat case left use. Match round scale now style far times.
+ Your me past an much.
-OPTIONS (= is mandatory):
+Options (= indicates it is required):
-= myopt1
- First option.
- type: str
+= myopt1 First option.
+ type: str
-- myopt2
- Second option
- default: 8000
- type: int
+- myopt2 Second option
+ default: 8000
+ type: int
-- myopt3
- Third option.
- choices: [choice1, choice2]
- default: null
- type: str
+- myopt3 Third option.
+ choices: [choice1, choice2]
+ default: null
+ type: str
+ATTRIBUTES:
+
+ `diff_mode:`
+ description: Will return details on what has changed (or possibly needs changing in
+ check_mode), when in diff mode
+ details: Not all modules used support this
+ support: partial
AUTHOR: John Doe (@john), Jane Doe (@jane)
diff --git a/test/integration/targets/ansible-doc/filter_plugins/other.py b/test/integration/targets/ansible-doc/filter_plugins/other.py
index 1bc2e17..3392dd5 100644
--- a/test/integration/targets/ansible-doc/filter_plugins/other.py
+++ b/test/integration/targets/ansible-doc/filter_plugins/other.py
@@ -1,8 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.utils.display import Display
diff --git a/test/integration/targets/ansible-doc/fix-urls.py b/test/integration/targets/ansible-doc/fix-urls.py
index 1379a4e..a8e0576 100644
--- a/test/integration/targets/ansible-doc/fix-urls.py
+++ b/test/integration/targets/ansible-doc/fix-urls.py
@@ -1,4 +1,5 @@
"""Unwrap URLs to docs.ansible.com and remove version"""
+from __future__ import annotations
import re
import sys
diff --git a/test/integration/targets/ansible-doc/library/double_doc.py b/test/integration/targets/ansible-doc/library/double_doc.py
index 6f0412a..80bd3dd 100644
--- a/test/integration/targets/ansible-doc/library/double_doc.py
+++ b/test/integration/targets/ansible-doc/library/double_doc.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = r'''
diff --git a/test/integration/targets/ansible-doc/library/test_docs.py b/test/integration/targets/ansible-doc/library/test_docs.py
index 39ae372..ba7817d 100644
--- a/test/integration/targets/ansible-doc/library/test_docs.py
+++ b/test/integration/targets/ansible-doc/library/test_docs.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
diff --git a/test/integration/targets/ansible-doc/library/test_docs_missing_description.py b/test/integration/targets/ansible-doc/library/test_docs_missing_description.py
index 6ed4183..40f39ef 100644
--- a/test/integration/targets/ansible-doc/library/test_docs_missing_description.py
+++ b/test/integration/targets/ansible-doc/library/test_docs_missing_description.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/ansible-doc/library/test_docs_no_metadata.py b/test/integration/targets/ansible-doc/library/test_docs_no_metadata.py
index 4ea86f0..b4344e9 100644
--- a/test/integration/targets/ansible-doc/library/test_docs_no_metadata.py
+++ b/test/integration/targets/ansible-doc/library/test_docs_no_metadata.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/ansible-doc/library/test_docs_no_status.py b/test/integration/targets/ansible-doc/library/test_docs_no_status.py
index 1b0db4e..f870e66 100644
--- a/test/integration/targets/ansible-doc/library/test_docs_no_status.py
+++ b/test/integration/targets/ansible-doc/library/test_docs_no_status.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
diff --git a/test/integration/targets/ansible-doc/library/test_docs_non_iterable_status.py b/test/integration/targets/ansible-doc/library/test_docs_non_iterable_status.py
index 63d080f..6e78ea7 100644
--- a/test/integration/targets/ansible-doc/library/test_docs_non_iterable_status.py
+++ b/test/integration/targets/ansible-doc/library/test_docs_non_iterable_status.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
diff --git a/test/integration/targets/ansible-doc/library/test_docs_removed_precedence.py b/test/integration/targets/ansible-doc/library/test_docs_removed_precedence.py
index 3de1c69..fdba64e 100644
--- a/test/integration/targets/ansible-doc/library/test_docs_removed_precedence.py
+++ b/test/integration/targets/ansible-doc/library/test_docs_removed_precedence.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/ansible-doc/library/test_docs_removed_status.py b/test/integration/targets/ansible-doc/library/test_docs_removed_status.py
index cb48c16..18f32a2 100644
--- a/test/integration/targets/ansible-doc/library/test_docs_removed_status.py
+++ b/test/integration/targets/ansible-doc/library/test_docs_removed_status.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
diff --git a/test/integration/targets/ansible-doc/library/test_docs_returns.py b/test/integration/targets/ansible-doc/library/test_docs_returns.py
index 77c1376..d21abf3 100644
--- a/test/integration/targets/ansible-doc/library/test_docs_returns.py
+++ b/test/integration/targets/ansible-doc/library/test_docs_returns.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/ansible-doc/library/test_docs_returns_broken.py b/test/integration/targets/ansible-doc/library/test_docs_returns_broken.py
index d6d6264..0c3119b 100644
--- a/test/integration/targets/ansible-doc/library/test_docs_returns_broken.py
+++ b/test/integration/targets/ansible-doc/library/test_docs_returns_broken.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/ansible-doc/library/test_docs_suboptions.py b/test/integration/targets/ansible-doc/library/test_docs_suboptions.py
index c922d1d..7f93e22 100644
--- a/test/integration/targets/ansible-doc/library/test_docs_suboptions.py
+++ b/test/integration/targets/ansible-doc/library/test_docs_suboptions.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/ansible-doc/library/test_docs_yaml_anchors.py b/test/integration/targets/ansible-doc/library/test_docs_yaml_anchors.py
index bec0292..419f350 100644
--- a/test/integration/targets/ansible-doc/library/test_docs_yaml_anchors.py
+++ b/test/integration/targets/ansible-doc/library/test_docs_yaml_anchors.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/ansible-doc/library/test_no_docs.py b/test/integration/targets/ansible-doc/library/test_no_docs.py
index 5503aed..2db81ae 100644
--- a/test/integration/targets/ansible-doc/library/test_no_docs.py
+++ b/test/integration/targets/ansible-doc/library/test_no_docs.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
diff --git a/test/integration/targets/ansible-doc/library/test_no_docs_no_metadata.py b/test/integration/targets/ansible-doc/library/test_no_docs_no_metadata.py
index 4887268..fb70e53 100644
--- a/test/integration/targets/ansible-doc/library/test_no_docs_no_metadata.py
+++ b/test/integration/targets/ansible-doc/library/test_no_docs_no_metadata.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/ansible-doc/library/test_no_docs_no_status.py b/test/integration/targets/ansible-doc/library/test_no_docs_no_status.py
index f90c5c7..dba36d1 100644
--- a/test/integration/targets/ansible-doc/library/test_no_docs_no_status.py
+++ b/test/integration/targets/ansible-doc/library/test_no_docs_no_status.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
diff --git a/test/integration/targets/ansible-doc/library/test_no_docs_non_iterable_status.py b/test/integration/targets/ansible-doc/library/test_no_docs_non_iterable_status.py
index 44fbede..0d22a1e 100644
--- a/test/integration/targets/ansible-doc/library/test_no_docs_non_iterable_status.py
+++ b/test/integration/targets/ansible-doc/library/test_no_docs_non_iterable_status.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
diff --git a/test/integration/targets/ansible-doc/lookup_plugins/_deprecated_with_adj_docs.py b/test/integration/targets/ansible-doc/lookup_plugins/_deprecated_with_adj_docs.py
index 81d401d..810521f 100644
--- a/test/integration/targets/ansible-doc/lookup_plugins/_deprecated_with_adj_docs.py
+++ b/test/integration/targets/ansible-doc/lookup_plugins/_deprecated_with_adj_docs.py
@@ -1,5 +1,4 @@
# Copyright (c) 2022 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
diff --git a/test/integration/targets/ansible-doc/lookup_plugins/_deprecated_with_docs.py b/test/integration/targets/ansible-doc/lookup_plugins/_deprecated_with_docs.py
index 4fd63aa..449f392 100644
--- a/test/integration/targets/ansible-doc/lookup_plugins/_deprecated_with_docs.py
+++ b/test/integration/targets/ansible-doc/lookup_plugins/_deprecated_with_docs.py
@@ -1,8 +1,7 @@
# Copyright (c) 2022 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/ansible-doc/noop.output b/test/integration/targets/ansible-doc/noop.output
index 567150a..842f91d 100644
--- a/test/integration/targets/ansible-doc/noop.output
+++ b/test/integration/targets/ansible-doc/noop.output
@@ -15,6 +15,7 @@
"filename": "./collections/ansible_collections/testns/testcol/plugins/lookup/noop.py",
"lookup": "noop",
"options": {},
+ "plugin_name": "testns.testcol.noop",
"short_description": "returns input",
"version_added": "1.0.0",
"version_added_collection": "testns.testcol2"
diff --git a/test/integration/targets/ansible-doc/noop_vars_plugin.output b/test/integration/targets/ansible-doc/noop_vars_plugin.output
index 5c42af3..46b0be7 100644
--- a/test/integration/targets/ansible-doc/noop_vars_plugin.output
+++ b/test/integration/targets/ansible-doc/noop_vars_plugin.output
@@ -32,6 +32,7 @@
"type": "str"
}
},
+ "plugin_name": "testns.testcol.noop_vars_plugin",
"short_description": "Do NOT load host and group vars",
"vars": "noop_vars_plugin"
},
diff --git a/test/integration/targets/ansible-doc/notjsonfile.output b/test/integration/targets/ansible-doc/notjsonfile.output
index a73b1a9..9ad5d1f 100644
--- a/test/integration/targets/ansible-doc/notjsonfile.output
+++ b/test/integration/targets/ansible-doc/notjsonfile.output
@@ -146,6 +146,7 @@
"version_added_collection": "testns.testcol2"
}
},
+ "plugin_name": "testns.testcol.notjsonfile",
"short_description": "JSON formatted files.",
"version_added": "0.7.0",
"version_added_collection": "testns.testcol"
diff --git a/test/integration/targets/ansible-doc/randommodule-text-verbose.output b/test/integration/targets/ansible-doc/randommodule-text-verbose.output
new file mode 100644
index 0000000..cfcba46
--- /dev/null
+++ b/test/integration/targets/ansible-doc/randommodule-text-verbose.output
@@ -0,0 +1,79 @@
+Using /home/bcoca/.ansible.cfg as config file
+> MODULE testns.testcol.randommodule (/home/bcoca/work/ansible/test/integration/targets/ansible-doc/collections/ansible_collections/testns/testcol/plugins/modules/randommodule.py)
+
+ A random module.
+DEPRECATED:
+ Reason: Test deprecation
+ Will be removed in: Ansible 3.0.0
+ Alternatives: Use some other module
+
+OPTIONS (= indicates it is required):
+
+- sub Suboptions.
+ set_via:
+ env:
+ - added_in: version 1.0.0 of ansible-core
+ deprecated:
+ alternative: none
+ removed_in: 2.0.0
+ version: 2.0.0
+ why: Test deprecation
+ name: TEST_ENV
+ default: null
+ type: dict
+ options:
+
+ - subtest2 Another suboption.
+ default: null
+ type: float
+ added in: version 1.1.0
+ suboptions:
+
+ - subtest A suboption.
+ default: null
+ type: int
+ added in: version 1.1.0 of testns.testcol
+
+- test Some text.
+ default: null
+ type: str
+ added in: version 1.2.0 of testns.testcol
+
+- testcol2option An option taken from testcol2
+ default: null
+ type: str
+ added in: version 1.0.0 of testns.testcol2
+
+- testcol2option2 Another option taken from testcol2
+ default: null
+ type: str
+
+ADDED_IN: version 1.0.0 of testns.testcol
+
+AUTHOR: Ansible Core Team
+
+EXAMPLES:
+
+
+RETURN VALUES:
+
+- a_first A first result.
+ returned: success
+ type: str
+
+- m_middle This should be in the middle.
+ Has some more data
+ returned: success and 1st of month
+ type: dict
+ contains:
+
+ - suboption A suboption.
+ choices: [ARF, BARN, c_without_capital_first_letter]
+ type: str
+ added in: version 1.4.0 of testns.testcol
+
+- z_last A last result.
+ returned: success
+ type: str
+ added in: version 1.3.0 of testns.testcol
+
diff --git a/test/integration/targets/ansible-doc/randommodule-text.output b/test/integration/targets/ansible-doc/randommodule-text.output
index ca36134..e890516 100644
--- a/test/integration/targets/ansible-doc/randommodule-text.output
+++ b/test/integration/targets/ansible-doc/randommodule-text.output
@@ -1,28 +1,24 @@
-> TESTNS.TESTCOL.RANDOMMODULE (./collections/ansible_collections/testns/testcol/plugins/modules/randommodule.py)
-
- A random module. See `foo=bar' (of role foo.bar.baz, main
- entrypoint) for how this is used in the [foo.bar.baz]'s `main'
- entrypoint. See the docsite <https://docs.ansible.com/ansible-
- core/devel/> for more information on ansible-core. This module
- is not related to the [ansible.builtin.copy] module.
- ------------- You might also be interested in
- ansible_python_interpreter. Sometimes you have [broken markup]
- that will result in error messages.
-
-ADDED IN: version 1.0.0 of testns.testcol
-
+> MODULE testns.testcol.randommodule (./collections/ansible_collections/testns/testcol/plugins/modules/randommodule.py)
+
+ A random module.
+ See `foo=bar' (of role foo.bar.baz, main entrypoint) for how this is
+ used in the [[foo.bar.baz]]'s `main' entrypoint.
+ See the docsite <https://docs.ansible.com/ansible-core/devel/> for
+ more information on ansible-core.
+ This module is not related to the [ansible.builtin.copy] module.
+ ------------- You might also be interested in
+ ansible_python_interpreter.
+ Sometimes you have [broken markup] that will result in error
+ messages.
DEPRECATED:
-
Reason: Test deprecation
Will be removed in: Ansible 3.0.0
Alternatives: Use some other module
+OPTIONS (= indicates it is required):
-OPTIONS (= is mandatory):
-
-- sub
- Suboptions. Contains `sub.subtest', which can be set to `123'.
- You can use `TEST_ENV' to set this.
+- sub Suboptions. Contains `sub.subtest', which can be set to `123'.
+ You can use `TEST_ENV' to set this.
set_via:
env:
- deprecated:
@@ -33,47 +29,40 @@ OPTIONS (= is mandatory):
name: TEST_ENV
default: null
type: dict
-
- OPTIONS:
-
- - subtest2
- Another suboption. Useful when [ansible.builtin.shuffle]
- is used with value `[a,b,),d\]'.
- default: null
- type: float
- added in: version 1.1.0
-
-
-
- SUBOPTIONS:
-
- - subtest
- A suboption. Not compatible to `path=c:\foo(1).txt' (of
- module ansible.builtin.copy).
- default: null
- type: int
- added in: version 1.1.0 of testns.testcol
-
-
-- test
- Some text. Consider not using `foo=bar'.
+ options:
+
+ - subtest2 Another suboption. Useful when [[ansible.builtin.shuffle]]
+ is used with value `[a,b,),d\]'.
+ default: null
+ type: float
+ added in: version 1.1.0
+ suboptions:
+
+ - subtest A suboption. Not compatible to `path=c:\foo(1).txt' (of
+ module ansible.builtin.copy).
+ default: null
+ type: int
+ added in: version 1.1.0 of testns.testcol
+
+- test Some text. Consider not using `foo=bar'.
default: null
type: str
- added in: version 1.2.0 of testns.testcol
-
-- testcol2option
- An option taken from testcol2
+- testcol2option An option taken from testcol2
default: null
type: str
- added in: version 1.0.0 of testns.testcol2
-
-- testcol2option2
- Another option taken from testcol2
+- testcol2option2 Another option taken from testcol2
default: null
type: str
+NOTES:
+ * This is a note.
+ * This is a multi-paragraph note.
+ This is its second paragraph. This is just another line
+ in the second paragraph. Eventually this will break into
+ a new line, depending with which line width this is
+ rendered.
SEE ALSO:
* Module ansible.builtin.ping
@@ -93,40 +82,32 @@ SEE ALSO:
Some foo bar.
https://docs.ansible.com/ansible-core/devel/#stq=foo_bar&stp=1
-
AUTHOR: Ansible Core Team
EXAMPLES:
-
-
RETURN VALUES:
-- a_first
- A first result. Use `a_first=foo(bar\baz)bam'.
+
+- a_first A first result. Use `a_first=foo(bar\baz)bam'.
returned: success
type: str
-- m_middle
- This should be in the middle.
- Has some more data.
- Check out `m_middle.suboption' and compare it to `a_first=foo'
- and `value' (of lookup plugin community.general.foo).
+- m_middle This should be in the middle.
+ Has some more data.
+ Check out `m_middle.suboption' and compare it to
+ `a_first=foo' and `value' (of lookup plugin
+ community.general.foo).
returned: success and 1st of month
type: dict
+ contains:
- CONTAINS:
-
- - suboption
- A suboption.
- choices: [ARF, BARN, c_without_capital_first_letter]
- type: str
- added in: version 1.4.0 of testns.testcol
-
+ - suboption A suboption.
+ choices: [ARF, BARN, c_without_capital_first_letter]
+ type: str
+ added in: version 1.4.0 of testns.testcol
-- z_last
- A last result.
+- z_last A last result.
returned: success
type: str
- added in: version 1.3.0 of testns.testcol
diff --git a/test/integration/targets/ansible-doc/randommodule.output b/test/integration/targets/ansible-doc/randommodule.output
index f40202a..58eb459 100644
--- a/test/integration/targets/ansible-doc/randommodule.output
+++ b/test/integration/targets/ansible-doc/randommodule.output
@@ -21,6 +21,10 @@
"filename": "./collections/ansible_collections/testns/testcol/plugins/modules/randommodule.py",
"has_action": false,
"module": "randommodule",
+ "notes": [
+ "This is a note.",
+ "This is a multi-paragraph note.\n\nThis is its second paragraph.\nThis is just another line in the second paragraph.\nEventually this will break into a new line,\ndepending with which line width this is rendered."
+ ],
"options": {
"sub": {
"description": "Suboptions. Contains O(sub.subtest), which can be set to V(123). You can use E(TEST_ENV) to set this.",
@@ -74,6 +78,7 @@
"type": "str"
}
},
+ "plugin_name": "testns.testcol.randommodule",
"seealso": [
{
"module": "ansible.builtin.ping"
diff --git a/test/integration/targets/ansible-doc/roles/test_role1/meta/argument_specs.yml b/test/integration/targets/ansible-doc/roles/test_role1/meta/argument_specs.yml
index 0315a1f..42857cd 100644
--- a/test/integration/targets/ansible-doc/roles/test_role1/meta/argument_specs.yml
+++ b/test/integration/targets/ansible-doc/roles/test_role1/meta/argument_specs.yml
@@ -11,7 +11,11 @@ argument_specs:
author:
- John Doe (@john)
- Jane Doe (@jane)
-
+ attributes:
+ diff_mode:
+ description: Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode
+ support: partial
+ details: Not all modules used support this
options:
myopt1:
description:
diff --git a/test/integration/targets/ansible-doc/runme.sh b/test/integration/targets/ansible-doc/runme.sh
index b525766..1cfe211 100755
--- a/test/integration/targets/ansible-doc/runme.sh
+++ b/test/integration/targets/ansible-doc/runme.sh
@@ -6,7 +6,7 @@ set -eu
verbosity=0
# default to silent output for naked grep; -vvv+ will adjust this
-export GREP_OPTS=-q
+GREP_OPTS=(-q)
# shell tracing output is very large from this script; only enable if >= -vvv was passed
while getopts :v opt
@@ -18,47 +18,52 @@ done
if (( verbosity >= 3 ));
then
- set -x;
- export GREP_OPTS= ;
+ set -x
+ GREP_OPTS=()
fi
echo "running playbook-backed docs tests"
ansible-playbook test.yml -i inventory "$@"
# test keyword docs
-ansible-doc -t keyword -l | grep $GREP_OPTS 'vars_prompt: list of variables to prompt for.'
-ansible-doc -t keyword vars_prompt | grep $GREP_OPTS 'description: list of variables to prompt for.'
-ansible-doc -t keyword asldkfjaslidfhals 2>&1 | grep $GREP_OPTS 'Skipping Invalid keyword'
+ansible-doc -t keyword -l | grep "${GREP_OPTS[@]}" 'vars_prompt: list of variables to prompt for.'
+ansible-doc -t keyword vars_prompt | grep "${GREP_OPTS[@]}" 'description: list of variables to prompt for.'
+ansible-doc -t keyword asldkfjaslidfhals 2>&1 | grep "${GREP_OPTS[@]}" 'Skipping Invalid keyword'
# collections testing
(
unset ANSIBLE_PLAYBOOK_DIR
+export ANSIBLE_NOCOLOR=1
+
cd "$(dirname "$0")"
echo "test fakemodule docs from collection"
# we use sed to strip the module path from the first line
-current_out="$(ansible-doc --playbook-dir ./ testns.testcol.fakemodule | sed '1 s/\(^> TESTNS\.TESTCOL\.FAKEMODULE\).*(.*)$/\1/')"
-expected_out="$(sed '1 s/\(^> TESTNS\.TESTCOL\.FAKEMODULE\).*(.*)$/\1/' fakemodule.output)"
+current_out="$(ansible-doc --playbook-dir ./ testns.testcol.fakemodule | sed '1 s/\(^> MODULE testns\.testcol\.fakemodule\).*(.*)$/\1/')"
+expected_out="$(sed '1 s/\(^> MODULE testns\.testcol\.fakemodule\).*(.*)$/\1/' fakemodule.output)"
test "$current_out" == "$expected_out"
echo "test randommodule docs from collection"
# we use sed to strip the plugin path from the first line, and fix-urls.py to unbreak and replace URLs from stable-X branches
-current_out="$(ansible-doc --playbook-dir ./ testns.testcol.randommodule | sed '1 s/\(^> TESTNS\.TESTCOL\.RANDOMMODULE\).*(.*)$/\1/' | python fix-urls.py)"
-expected_out="$(sed '1 s/\(^> TESTNS\.TESTCOL\.RANDOMMODULE\).*(.*)$/\1/' randommodule-text.output)"
+current_out="$(ansible-doc --playbook-dir ./ testns.testcol.randommodule | sed '1 s/\(^> MODULE testns\.testcol\.randommodule\).*(.*)$/\1/' | python fix-urls.py)"
+expected_out="$(sed '1 s/\(^> MODULE testns\.testcol\.randommodule\).*(.*)$/\1/' randommodule-text.output)"
test "$current_out" == "$expected_out"
echo "test yolo filter docs from collection"
# we use sed to strip the plugin path from the first line, and fix-urls.py to unbreak and replace URLs from stable-X branches
-current_out="$(ansible-doc --playbook-dir ./ testns.testcol.yolo --type test | sed '1 s/\(^> TESTNS\.TESTCOL\.YOLO\).*(.*)$/\1/' | python fix-urls.py)"
-expected_out="$(sed '1 s/\(^> TESTNS\.TESTCOL\.YOLO\).*(.*)$/\1/' yolo-text.output)"
+current_out="$(ansible-doc --playbook-dir ./ testns.testcol.yolo --type test | sed '1 s/\(^> TEST testns\.testcol\.yolo\).*(.*)$/\1/' | python fix-urls.py)"
+expected_out="$(sed '1 s/\(^> TEST testns\.testcol\.yolo\).*(.*)$/\1/' yolo-text.output)"
test "$current_out" == "$expected_out"
+# ensure we do work with valid collection name for list
+ansible-doc --list testns.testcol --playbook-dir ./ 2>&1 | grep -v "Invalid collection name"
+
echo "ensure we do work with valid collection name for list"
-ansible-doc --list testns.testcol --playbook-dir ./ 2>&1 | grep $GREP_OPTS -v "Invalid collection name"
+ansible-doc --list testns.testcol --playbook-dir ./ 2>&1 | grep "${GREP_OPTS[@]}" -v "Invalid collection name"
echo "ensure we dont break on invalid collection name for list"
-ansible-doc --list testns.testcol.fakemodule --playbook-dir ./ 2>&1 | grep $GREP_OPTS "Invalid collection name"
+ansible-doc --list testns.testcol.fakemodule --playbook-dir ./ 2>&1 | grep "${GREP_OPTS[@]}" "Invalid collection name"
echo "filter list with more than one collection (1/2)"
output=$(ansible-doc --list testns.testcol3 testns.testcol4 --playbook-dir ./ 2>&1 | wc -l)
@@ -96,12 +101,12 @@ do
list_result=$(ansible-doc -l -t ${ptype} --playbook-dir ./ testns.testcol)
metadata_result=$(ansible-doc --metadata-dump --no-fail-on-errors -t ${ptype} --playbook-dir ./ testns.testcol)
for name in "${expected_names[@]}"; do
- echo "${list_result}" | grep $GREP_OPTS "testns.testcol.${name}"
- echo "${metadata_result}" | grep $GREP_OPTS "testns.testcol.${name}"
+ echo "${list_result}" | grep "${GREP_OPTS[@]}" "testns.testcol.${name}"
+ echo "${metadata_result}" | grep "${GREP_OPTS[@]}" "testns.testcol.${name}"
done
# ensure we get error if passing invalid collection, much less any plugins
- ansible-doc -l -t ${ptype} bogus.boguscoll 2>&1 | grep $GREP_OPTS "unable to locate collection"
+ ansible-doc -l -t ${ptype} bogus.boguscoll 2>&1 | grep "${GREP_OPTS[@]}" "unable to locate collection"
# TODO: do we want per namespace?
# ensure we get 1 plugins when restricting namespace
@@ -113,24 +118,24 @@ done
echo "testing role text output"
# we use sed to strip the role path from the first line
-current_role_out="$(ansible-doc -t role -r ./roles test_role1 | sed '1 s/\(^> TEST_ROLE1\).*(.*)$/\1/')"
-expected_role_out="$(sed '1 s/\(^> TEST_ROLE1\).*(.*)$/\1/' fakerole.output)"
+current_role_out="$(ansible-doc -t role -r ./roles test_role1 | sed '1 s/\(^> ROLE: \*test_role1\*\).*(.*)$/\1/')"
+expected_role_out="$(sed '1 s/\(^> ROLE: \*test_role1\*\).*(.*)$/\1/' fakerole.output)"
test "$current_role_out" == "$expected_role_out"
echo "testing multiple role entrypoints"
# Two collection roles are defined, but only 1 has a role arg spec with 2 entry points
output=$(ansible-doc -t role -l --playbook-dir . testns.testcol | wc -l)
-test "$output" -eq 2
+test "$output" -eq 4
echo "test listing roles with multiple collection filters"
# Two collection roles are defined, but only 1 has a role arg spec with 2 entry points
output=$(ansible-doc -t role -l --playbook-dir . testns.testcol2 testns.testcol | wc -l)
-test "$output" -eq 2
+test "$output" -eq 4
echo "testing standalone roles"
# Include normal roles (no collection filter)
output=$(ansible-doc -t role -l --playbook-dir . | wc -l)
-test "$output" -eq 3
+test "$output" -eq 8
echo "testing role precedence"
# Test that a role in the playbook dir with the same name as a role in the
@@ -141,8 +146,8 @@ output=$(ansible-doc -t role -l --playbook-dir . | grep -c "test_role1 from play
test "$output" -eq 0
echo "testing role entrypoint filter"
-current_role_out="$(ansible-doc -t role --playbook-dir . testns.testcol.testrole -e alternate| sed '1 s/\(^> TESTNS\.TESTCOL\.TESTROLE\).*(.*)$/\1/')"
-expected_role_out="$(sed '1 s/\(^> TESTNS\.TESTCOL\.TESTROLE\).*(.*)$/\1/' fakecollrole.output)"
+current_role_out="$(ansible-doc -t role --playbook-dir . testns.testcol.testrole -e alternate| sed '1 s/\(^> ROLE: \*testns\.testcol\.testrole\*\).*(.*)$/\1/')"
+expected_role_out="$(sed '1 s/\(^> ROLE: \*testns\.testcol\.testrole\*\).*(.*)$/\1/' fakecollrole.output)"
test "$current_role_out" == "$expected_role_out"
)
@@ -230,7 +235,7 @@ echo "testing sidecar docs for jinja plugins"
[ "$(ansible-doc -t filter --playbook-dir ./ ansible.legacy.donothing| wc -l)" -gt "0" ]
echo "testing no docs and no sidecar"
-ansible-doc -t filter --playbook-dir ./ nodocs 2>&1| grep $GREP_OPTS -c 'missing documentation' || true
+ansible-doc -t filter --playbook-dir ./ nodocs 2>&1| grep "${GREP_OPTS[@]}" -c 'missing documentation' || true
echo "testing sidecar docs for module"
[ "$(ansible-doc -M ./library test_win_module| wc -l)" -gt "0" ]
@@ -249,7 +254,7 @@ echo "testing no duplicates for plugins that only exist in ansible.builtin when
[ "$(ansible-doc -l -t filter --playbook-dir ./ |grep -c 'b64encode')" -eq "1" ]
echo "testing with playbook dir, legacy should override"
-ansible-doc -t filter split --playbook-dir ./ |grep $GREP_OPTS histerical
+ansible-doc -t filter split --playbook-dir ./ -v|grep "${GREP_OPTS[@]}" histerical
pyc_src="$(pwd)/filter_plugins/other.py"
pyc_1="$(pwd)/filter_plugins/split.pyc"
@@ -258,11 +263,11 @@ trap 'rm -rf "$pyc_1" "$pyc_2"' EXIT
echo "testing pyc files are not used as adjacent documentation"
python -c "import py_compile; py_compile.compile('$pyc_src', cfile='$pyc_1')"
-ansible-doc -t filter split --playbook-dir ./ |grep $GREP_OPTS histerical
+ansible-doc -t filter split --playbook-dir ./ -v|grep "${GREP_OPTS[@]}" histerical
echo "testing pyc files are not listed as plugins"
python -c "import py_compile; py_compile.compile('$pyc_src', cfile='$pyc_2')"
test "$(ansible-doc -l -t module --playbook-dir ./ 2>&1 1>/dev/null |grep -c "notaplugin")" == 0
echo "testing without playbook dir, builtin should return"
-ansible-doc -t filter split 2>&1 |grep $GREP_OPTS -v histerical
+ansible-doc -t filter split -v 2>&1 |grep "${GREP_OPTS[@]}" -v histerical
diff --git a/test/integration/targets/ansible-doc/test.yml b/test/integration/targets/ansible-doc/test.yml
index a8c992e..f981401 100644
--- a/test/integration/targets/ansible-doc/test.yml
+++ b/test/integration/targets/ansible-doc/test.yml
@@ -2,6 +2,12 @@
gather_facts: no
environment:
ANSIBLE_LIBRARY: "{{ playbook_dir }}/library"
+ ANSIBLE_NOCOLOR: 1
+ ANSIBLE_DEPRECATION_WARNINGS: 1
+ vars:
+ # avoid header that has full path and won't work across random paths for tests
+ actual_output_clean: '{{ actual_output.splitlines()[1:] }}'
+ expected_output_clean: '{{ expected_output.splitlines()[1:] }}'
tasks:
- name: module with missing description return docs
command: ansible-doc test_docs_missing_description
@@ -16,34 +22,32 @@
in result.stderr
- name: module with suboptions (avoid first line as it has full path)
- shell: ansible-doc test_docs_suboptions| tail -n +2
+ shell: ansible-doc test_docs_suboptions| tail -n +3
register: result
ignore_errors: true
- set_fact:
- actual_output: >-
- {{ result.stdout | regex_replace('^(> [A-Z_]+ +\().+library/([a-z_]+.py)\)$', '\1library/\2)', multiline=true) }}
+ actual_output: "{{ result.stdout }}"
expected_output: "{{ lookup('file', 'test_docs_suboptions.output') }}"
- assert:
that:
- result is succeeded
- - actual_output == expected_output
+ - actual_output_clean == expected_output_clean
- name: module with return docs
- shell: ansible-doc test_docs_returns| tail -n +2
+ shell: ansible-doc test_docs_returns| tail -n +3
register: result
ignore_errors: true
- set_fact:
- actual_output: >-
- {{ result.stdout | regex_replace('^(> [A-Z_]+ +\().+library/([a-z_]+.py)\)$', '\1library/\2)', multiline=true) }}
+ actual_output: "{{ result.stdout }}"
expected_output: "{{ lookup('file', 'test_docs_returns.output') }}"
- assert:
that:
- result is succeeded
- - actual_output == expected_output
+ - actual_output_clean == expected_output_clean
- name: module with broken return docs
command: ansible-doc test_docs_returns_broken
@@ -68,7 +72,7 @@
- assert:
that:
- '"WARNING" not in result.stderr'
- - '"TEST_DOCS " in result.stdout'
+ - '"test_docs" in result.stdout'
- '"AUTHOR: Ansible Core Team" in result.stdout'
- name: documented module without metadata
@@ -77,7 +81,7 @@
- assert:
that:
- '"WARNING" not in result.stderr'
- - '"TEST_DOCS_NO_METADATA " in result.stdout'
+ - '"test_docs_no_metadata " in result.stdout'
- '"AUTHOR: Ansible Core Team" in result.stdout'
- name: documented module with no status in metadata
@@ -86,7 +90,7 @@
- assert:
that:
- '"WARNING" not in result.stderr'
- - '"TEST_DOCS_NO_STATUS " in result.stdout'
+ - '"test_docs_no_status " in result.stdout'
- '"AUTHOR: Ansible Core Team" in result.stdout'
- name: documented module with non-iterable status in metadata
@@ -95,7 +99,7 @@
- assert:
that:
- '"WARNING" not in result.stderr'
- - '"TEST_DOCS_NON_ITERABLE_STATUS " in result.stdout'
+ - '"test_docs_non_iterable_status " in result.stdout'
- '"AUTHOR: Ansible Core Team" in result.stdout'
- name: documented module with removed status
@@ -105,7 +109,7 @@
- assert:
that:
- '"WARNING" not in result.stderr'
- - '"TEST_DOCS_REMOVED_STATUS " in result.stdout'
+ - '"test_docs_removed_status " in result.stdout'
- '"AUTHOR: Ansible Core Team" in result.stdout'
- name: empty module
@@ -138,15 +142,18 @@
- '"Alternatives: new_module" in result.stdout'
- name: documented module with YAML anchors
- shell: ansible-doc test_docs_yaml_anchors |tail -n +2
+ shell: ansible-doc test_docs_yaml_anchors |tail -n +3
register: result
+
- set_fact:
actual_output: >-
{{ result.stdout | regex_replace('^(> [A-Z_]+ +\().+library/([a-z_]+.py)\)$', '\1library/\2)', multiline=true) }}
expected_output: "{{ lookup('file', 'test_docs_yaml_anchors.output') }}"
+
- assert:
that:
- actual_output == expected_output
+ - actual_output_clean == expected_output_clean
- name: ensure 'donothing' adjacent filter is loaded
assert:
@@ -154,19 +161,23 @@
- "'x' == ('x'|donothing)"
- name: docs for deprecated plugin
- command: ansible-doc deprecated_with_docs -t lookup
+ command: ansible-doc deprecated_with_docs -t lookup --playbook-dir ./
register: result
+
- assert:
that:
- - '"WARNING" not in result.stderr'
- - '"DEPRECATED_WITH_DOCS " in result.stdout'
+ - '"[WARNING]" not in result.stderr'
+ - '"[DEPRECATION WARNING]" in result.stderr'
+ - '"deprecated_with_docs " in result.stdout'
- '"AUTHOR: Ansible Core Team" in result.stdout'
- name: adjacent docs for deprecated plugin
- command: ansible-doc deprecated_with_adj_docs -t lookup
+ command: ansible-doc deprecated_with_adj_docs -t lookup --playbook-dir ./
register: result
+
- assert:
that:
- - '"WARNING" not in result.stderr'
- - '"DEPRECATED_WITH_ADJ_DOCS " in result.stdout'
+ - '"[WARNING]" not in result.stderr'
+ - '"[DEPRECATION WARNING]" in result.stderr'
+ - '"deprecated_with_adj_docs " in result.stdout'
- '"AUTHOR: Ansible Core Team" in result.stdout'
diff --git a/test/integration/targets/ansible-doc/test_docs_returns.output b/test/integration/targets/ansible-doc/test_docs_returns.output
index 3e23645..3fea978 100644
--- a/test/integration/targets/ansible-doc/test_docs_returns.output
+++ b/test/integration/targets/ansible-doc/test_docs_returns.output
@@ -1,33 +1,27 @@
-
- Test module
+ Test module
AUTHOR: Ansible Core Team
EXAMPLES:
-
-
RETURN VALUES:
-- a_first
- A first result.
+
+- a_first A first result.
returned: success
type: str
-- m_middle
- This should be in the middle.
- Has some more data
+- m_middle This should be in the middle.
+ Has some more data
returned: success and 1st of month
type: dict
+ contains:
- CONTAINS:
-
- - suboption
- A suboption.
- choices: [ARF, BARN, c_without_capital_first_letter]
- type: str
+ - suboption A suboption.
+ choices: [ARF, BARN, c_without_capital_first_letter]
+ type: str
-- z_last
- A last result.
+- z_last A last result.
returned: success
type: str
+
diff --git a/test/integration/targets/ansible-doc/test_docs_suboptions.output b/test/integration/targets/ansible-doc/test_docs_suboptions.output
index 350f90f..2ca3377 100644
--- a/test/integration/targets/ansible-doc/test_docs_suboptions.output
+++ b/test/integration/targets/ansible-doc/test_docs_suboptions.output
@@ -1,42 +1,32 @@
+ Test module
- Test module
+OPTIONS (= indicates it is required):
-OPTIONS (= is mandatory):
-
-- with_suboptions
- An option with suboptions.
- Use with care.
+- with_suboptions An option with suboptions.
+ Use with care.
default: null
type: dict
+ suboptions:
- SUBOPTIONS:
-
- - a_first
- The first suboption.
- default: null
- type: str
-
- - m_middle
- The suboption in the middle.
- Has its own suboptions.
- default: null
-
- SUBOPTIONS:
+ - a_first The first suboption.
+ default: null
+ type: str
- - a_suboption
- A sub-suboption.
- default: null
- type: str
+ - m_middle The suboption in the middle.
+ Has its own suboptions.
+ default: null
+ suboptions:
- - z_last
- The last suboption.
+ - a_suboption A sub-suboption.
default: null
type: str
+ - z_last The last suboption.
+ default: null
+ type: str
AUTHOR: Ansible Core Team
EXAMPLES:
-
diff --git a/test/integration/targets/ansible-doc/test_docs_yaml_anchors.output b/test/integration/targets/ansible-doc/test_docs_yaml_anchors.output
index 5eb2eee..abe26a4 100644
--- a/test/integration/targets/ansible-doc/test_docs_yaml_anchors.output
+++ b/test/integration/targets/ansible-doc/test_docs_yaml_anchors.output
@@ -1,46 +1,35 @@
+ Test module
- Test module
+OPTIONS (= indicates it is required):
-OPTIONS (= is mandatory):
-
-- at_the_top
- Short desc
+- at_the_top Short desc
default: some string
type: str
-- egress
- Egress firewall rules
+- egress Egress firewall rules
default: null
elements: dict
type: list
+ suboptions:
- SUBOPTIONS:
-
- = port
- Rule port
- type: int
+ = port Rule port
+ type: int
-- ingress
- Ingress firewall rules
+- ingress Ingress firewall rules
default: null
elements: dict
type: list
+ suboptions:
- SUBOPTIONS:
-
- = port
- Rule port
- type: int
+ = port Rule port
+ type: int
-- last_one
- Short desc
+- last_one Short desc
default: some string
type: str
-
AUTHOR: Ansible Core Team
EXAMPLES:
-
diff --git a/test/integration/targets/ansible-doc/yolo-text.output b/test/integration/targets/ansible-doc/yolo-text.output
index 647a4f6..f9d4fe8 100644
--- a/test/integration/targets/ansible-doc/yolo-text.output
+++ b/test/integration/targets/ansible-doc/yolo-text.output
@@ -1,14 +1,12 @@
-> TESTNS.TESTCOL.YOLO (./collections/ansible_collections/testns/testcol/plugins/test/yolo.yml)
+> TEST testns.testcol.yolo (./collections/ansible_collections/testns/testcol/plugins/test/yolo.yml)
- This is always true
+ This is always true
-OPTIONS (= is mandatory):
+OPTIONS (= indicates it is required):
-= _input
- does not matter
+= _input does not matter
type: raw
-
SEE ALSO:
* Module ansible.builtin.test
The official documentation on the
@@ -33,15 +31,13 @@ SEE ALSO:
Some foo bar.
https://docs.ansible.com/ansible-core/devel/#stq=foo_bar&stp=1
-
NAME: yolo
EXAMPLES:
-
{{ 'anything' is yolo }}
-
RETURN VALUES:
-- output
- always true
+
+- output always true
type: boolean
+
diff --git a/test/integration/targets/ansible-doc/yolo.output b/test/integration/targets/ansible-doc/yolo.output
index b54cc2d..9083fd5 100644
--- a/test/integration/targets/ansible-doc/yolo.output
+++ b/test/integration/targets/ansible-doc/yolo.output
@@ -14,6 +14,7 @@
"type": "raw"
}
},
+ "plugin_name": "testns.testcol.yolo",
"seealso": [
{
"module": "ansible.builtin.test"
diff --git a/test/integration/targets/ansible-galaxy-collection-cli/files/empty_manifest_galaxy.yml b/test/integration/targets/ansible-galaxy-collection-cli/files/empty_manifest_galaxy.yml
new file mode 100644
index 0000000..e43ba41
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-cli/files/empty_manifest_galaxy.yml
@@ -0,0 +1,8 @@
+namespace: ns
+name: col
+version: 3.0.0
+readme: README.rst
+license_file: GPL
+authors:
+ - Ansible
+manifest:
diff --git a/test/integration/targets/ansible-galaxy-collection-cli/files/expected_empty.txt b/test/integration/targets/ansible-galaxy-collection-cli/files/expected_empty.txt
new file mode 100644
index 0000000..f1e0f8f
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection-cli/files/expected_empty.txt
@@ -0,0 +1,117 @@
+foo.txt
+MANIFEST.json
+FILES.json
+README.rst
+GPL
+LICENSES/
+LICENSES/MIT.txt
+.reuse/
+.reuse/dep5
+changelogs/
+docs/
+playbooks/
+plugins/
+roles/
+tests/
+changelogs/fragments/
+changelogs/fragments/bar.yaml
+changelogs/fragments/foo.yml
+docs/docsite/
+docs/docsite/apple.j2
+docs/docsite/bar.yml
+docs/docsite/baz.yaml
+docs/docsite/foo.rst
+docs/docsite/orange.txt
+docs/docsite/qux.json
+docs/foobar/
+docs/foobar/qux/
+docs/foobar/qux/baz.txt
+playbooks/bar.yaml
+playbooks/baz.json
+playbooks/foo.yml
+plugins/action/
+plugins/become/
+plugins/cache/
+plugins/callback/
+plugins/cliconf/
+plugins/connection/
+plugins/doc_fragments/
+plugins/filter/
+plugins/httpapi/
+plugins/inventory/
+plugins/lookup/
+plugins/module_utils/
+plugins/modules/
+plugins/netconf/
+plugins/shell/
+plugins/strategy/
+plugins/terminal/
+plugins/test/
+plugins/vars/
+plugins/action/test.py
+plugins/become/bar.yml
+plugins/become/baz.yaml
+plugins/become/test.py
+plugins/cache/bar.yml
+plugins/cache/baz.yaml
+plugins/cache/test.py
+plugins/callback/bar.yml
+plugins/callback/baz.yaml
+plugins/callback/test.py
+plugins/cliconf/bar.yml
+plugins/cliconf/baz.yaml
+plugins/cliconf/test.py
+plugins/connection/bar.yml
+plugins/connection/baz.yaml
+plugins/connection/test.py
+plugins/doc_fragments/test.py
+plugins/filter/bar.yml
+plugins/filter/baz.yaml
+plugins/filter/test.py
+plugins/httpapi/bar.yml
+plugins/httpapi/baz.yaml
+plugins/httpapi/test.py
+plugins/inventory/bar.yml
+plugins/inventory/baz.yaml
+plugins/inventory/test.py
+plugins/lookup/bar.yml
+plugins/lookup/baz.yaml
+plugins/lookup/test.py
+plugins/module_utils/bar.ps1
+plugins/module_utils/test.py
+plugins/modules/bar.yaml
+plugins/modules/test2.py
+plugins/modules/foo.yml
+plugins/modules/qux.ps1
+plugins/netconf/bar.yml
+plugins/netconf/baz.yaml
+plugins/netconf/test.py
+plugins/shell/bar.yml
+plugins/shell/baz.yaml
+plugins/shell/test.py
+plugins/strategy/bar.yml
+plugins/strategy/baz.yaml
+plugins/strategy/test.py
+plugins/terminal/test.py
+plugins/test/bar.yml
+plugins/test/baz.yaml
+plugins/test/test.py
+plugins/vars/bar.yml
+plugins/vars/bar.yml.license
+plugins/vars/baz.yaml
+plugins/vars/test.py
+roles/foo/
+roles/foo/tasks/
+roles/foo/templates/
+roles/foo/vars/
+roles/foo/tasks/main.yml
+roles/foo/templates/foo.j2
+roles/foo/vars/main.yaml
+tests/integration/
+tests/units/
+tests/integration/targets/
+tests/integration/targets/foo/
+tests/integration/targets/foo/aliases
+tests/integration/targets/foo/tasks/
+tests/integration/targets/foo/tasks/main.yml
+tests/units/test_foo.py
diff --git a/test/integration/targets/ansible-galaxy-collection-cli/files/make_collection_dir.py b/test/integration/targets/ansible-galaxy-collection-cli/files/make_collection_dir.py
index 60c43cc..e5c3359 100644
--- a/test/integration/targets/ansible-galaxy-collection-cli/files/make_collection_dir.py
+++ b/test/integration/targets/ansible-galaxy-collection-cli/files/make_collection_dir.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import sys
import pathlib
diff --git a/test/integration/targets/ansible-galaxy-collection-cli/tasks/manifest.yml b/test/integration/targets/ansible-galaxy-collection-cli/tasks/manifest.yml
index 5f37c72..ee0a4ab 100644
--- a/test/integration/targets/ansible-galaxy-collection-cli/tasks/manifest.yml
+++ b/test/integration/targets/ansible-galaxy-collection-cli/tasks/manifest.yml
@@ -3,7 +3,7 @@
args:
executable: '{{ ansible_facts.python.executable }}'
-- name: Copy galaxy.yml with manifest_directives_full
+- name: Copy galaxy.yml
copy:
src: galaxy.yml
dest: '{{ output_dir }}/test_manifest_collection/galaxy.yml'
@@ -55,3 +55,32 @@
- assert:
that:
- artifact_contents.stdout_lines|sort == lookup('file', 'expected_full_manifest.txt').splitlines()|sort
+
+- name: Create test collection dir
+ script: make_collection_dir.py "{{ output_dir }}/test_manifest_empty_collection"
+ args:
+ executable: '{{ ansible_facts.python.executable }}'
+
+- name: Copy galaxy.yml with empty_manifest_galaxy
+ copy:
+ src: empty_manifest_galaxy.yml
+ dest: '{{ output_dir }}/test_manifest_empty_collection/galaxy.yml'
+
+- name: Build collection
+ command: ansible-galaxy collection build --output-path {{ output_dir|quote }} -vvv
+ args:
+ chdir: '{{ output_dir }}/test_manifest_empty_collection'
+
+- name: Get artifact contents
+ command: tar tzf '{{ output_dir }}/ns-col-3.0.0.tar.gz'
+ register: artifact_contents
+
+- debug:
+ var: artifact_contents.stdout_lines|sort
+
+- debug:
+ var: lookup('file', 'expected_empty.txt').splitlines()|sort
+
+- assert:
+ that:
+ - artifact_contents.stdout_lines|sort == lookup('file', 'expected_empty.txt').splitlines()|sort
diff --git a/test/integration/targets/ansible-galaxy-collection/files/build_bad_tar.py b/test/integration/targets/ansible-galaxy-collection/files/build_bad_tar.py
index 6182e86..25fb5dd 100644
--- a/test/integration/targets/ansible-galaxy-collection/files/build_bad_tar.py
+++ b/test/integration/targets/ansible-galaxy-collection/files/build_bad_tar.py
@@ -3,8 +3,7 @@
# Copyright: (c) 2020, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import hashlib
import io
@@ -12,6 +11,7 @@ import json
import os
import sys
import tarfile
+from ansible.module_utils.common.file import S_IRWXU_RXG_RXO
manifest = {
'collection_info': {
@@ -47,7 +47,7 @@ files = {
def add_file(tar_file, filename, b_content, update_files=True):
tar_info = tarfile.TarInfo(filename)
tar_info.size = len(b_content)
- tar_info.mode = 0o0755
+ tar_info.mode = S_IRWXU_RXG_RXO
tar_file.addfile(tarinfo=tar_info, fileobj=io.BytesIO(b_content))
if update_files:
diff --git a/test/integration/targets/ansible-galaxy-collection/files/test_module.py b/test/integration/targets/ansible-galaxy-collection/files/test_module.py
index d7e4814..d4bb3c3 100644
--- a/test/integration/targets/ansible-galaxy-collection/files/test_module.py
+++ b/test/integration/targets/ansible-galaxy-collection/files/test_module.py
@@ -4,8 +4,7 @@
# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/ansible-galaxy-collection/handlers/main.yml b/test/integration/targets/ansible-galaxy-collection/handlers/main.yml
new file mode 100644
index 0000000..d58a516
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-collection/handlers/main.yml
@@ -0,0 +1,7 @@
+- name: uninstall gpg
+ command: brew uninstall gpg
+ become: yes
+ become_user: >-
+ {{ brew_stat.stat.pw_name }}
+ environment:
+ HOMEBREW_NO_AUTO_UPDATE: True
diff --git a/test/integration/targets/ansible-galaxy-collection/library/reset_pulp.py b/test/integration/targets/ansible-galaxy-collection/library/reset_pulp.py
index c1f5e1d..90397a5 100644
--- a/test/integration/targets/ansible-galaxy-collection/library/reset_pulp.py
+++ b/test/integration/targets/ansible-galaxy-collection/library/reset_pulp.py
@@ -3,8 +3,7 @@
# Copyright: (c) 2020, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
---
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 423edd9..b7d262a 100644
--- a/test/integration/targets/ansible-galaxy-collection/library/setup_collections.py
+++ b/test/integration/targets/ansible-galaxy-collection/library/setup_collections.py
@@ -3,8 +3,7 @@
# Copyright: (c) 2020, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {
'metadata_version': '1.1',
diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/download.yml b/test/integration/targets/ansible-galaxy-collection/tasks/download.yml
index a554c27..8a2fa56 100644
--- a/test/integration/targets/ansible-galaxy-collection/tasks/download.yml
+++ b/test/integration/targets/ansible-galaxy-collection/tasks/download.yml
@@ -170,6 +170,33 @@
- '"Downloading collection ''ansible_test.my_collection:1.0.0'' to" in download_collection.stdout'
- download_collection_actual.stat.exists
+- block:
+ - name: create skeleton collection for trailing slash test
+ command: ansible-galaxy collection init trailing_dir.name --init-path "{{ galaxy_dir }}"
+
+ - name: install collection with directory source and trailing slash - {{ test_id }}
+ command: ansible-galaxy collection download '{{ galaxy_dir }}/trailing_dir/name/' {{ galaxy_verbosity }}
+ args:
+ chdir: '{{ galaxy_dir }}/download'
+ register: download_dir_slash
+
+ - name: get result of install collections with with trailing slash - {{ test_id }}
+ stat:
+ path: '{{ galaxy_dir }}/download/collections/trailing_dir-name-1.0.0.tar.gz'
+ register: download_dir_slash_actual
+
+ - name: assert install collections with with trailing slash - {{ test_id }}
+ assert:
+ that:
+ - '"Downloading collection ''trailing_dir.name:1.0.0'' to" in download_dir_slash.stdout'
+ - download_dir_slash_actual.stat.exists
+
+ always:
+ - name: remove trailing dir skeleton
+ file:
+ path: '{{ galaxy_dir }}/trailing_dir'
+ state: absent
+
- name: remove test download dir
file:
path: '{{ galaxy_dir }}/download'
diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/init.yml b/test/integration/targets/ansible-galaxy-collection/tasks/init.yml
index 46198fe..6a00553 100644
--- a/test/integration/targets/ansible-galaxy-collection/tasks/init.yml
+++ b/test/integration/targets/ansible-galaxy-collection/tasks/init.yml
@@ -128,11 +128,18 @@
- link: custom_skeleton/galaxy.yml
source: galaxy.yml
+ - name: create j2 file
+ copy:
+ dest: "{{ galaxy_dir }}/scratch/skeleton/custom_skeleton/README.j2"
+ content: !unsafe |
+ Requires ansible-core >={{ min_ansible_version }}
+
- name: initialize a collection using the skeleton
- command: ansible-galaxy collection init ansible_test.my_collection {{ init_path }} {{ skeleton }}
+ command: ansible-galaxy collection init ansible_test.my_collection {{ init_path }} {{ skeleton }} {{ extra }}
vars:
init_path: '--init-path {{ galaxy_dir }}/scratch/skeleton'
skeleton: '--collection-skeleton {{ galaxy_dir }}/scratch/skeleton/custom_skeleton'
+ extra: '-e min_ansible_version="2.17"'
- name: stat expected collection contents
stat:
@@ -143,6 +150,7 @@
- plugins/inventory
- galaxy.yml
- plugins/inventory/foo.py
+ - README
- assert:
that:
@@ -150,7 +158,18 @@
- stat_result.results[1].stat.islnk
- stat_result.results[2].stat.islnk
- stat_result.results[3].stat.isreg
+ - stat_result.results[4].stat.isreg
+
+ - name: Verify the README was templated successfully
+ copy:
+ dest: "{{ galaxy_dir }}/scratch/skeleton/ansible_test/my_collection/README"
+ content: |
+ Requires ansible-core >=2.17
+ register: validate_readme_content
+ - assert:
+ that:
+ - not validate_readme_content.changed
always:
- name: cleanup
file:
diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/install.yml b/test/integration/targets/ansible-galaxy-collection/tasks/install.yml
index 9237826..5959110 100644
--- a/test/integration/targets/ansible-galaxy-collection/tasks/install.yml
+++ b/test/integration/targets/ansible-galaxy-collection/tasks/install.yml
@@ -1141,6 +1141,33 @@
- (install_concrete_pre_actual.results[0].content | b64decode | from_json).collection_info.version == '1.1.0-beta.1'
- (install_concrete_pre_actual.results[1].content | b64decode | from_json).collection_info.version == '1.0.0'
+- block:
+ - name: create skeleton collection for trailing slash test
+ command: ansible-galaxy collection init trailing_dir.name --init-path "{{ galaxy_dir }}/scratch"
+
+ - name: install collection with directory source and trailing slash - {{ test_id }}
+ command: ansible-galaxy collection install '{{ galaxy_dir }}/scratch/trailing_dir/name/' {{ galaxy_verbosity }}
+ environment:
+ ANSIBLE_COLLECTIONS_PATHS: '{{ galaxy_dir }}/ansible_collections'
+ register: install_dir_slash
+
+ - name: get result of install collections with with trailing slash - {{ test_id }}
+ slurp:
+ path: '{{ galaxy_dir }}/ansible_collections/trailing_dir/name/MANIFEST.json'
+ register: install_dir_slash_actual
+
+ - name: assert install collections with with trailing slash - {{ test_id }}
+ assert:
+ that:
+ - '"Installing ''trailing_dir.name:1.0.0'' to" in install_dir_slash.stdout'
+ - (install_dir_slash_actual.content | b64decode | from_json).collection_info.version == '1.0.0'
+
+ always:
+ - name: remove trailing dir skeleton
+ file:
+ path: '{{ galaxy_dir }}/scratch/trailing_dir'
+ state: absent
+
- name: remove collection dir after round of testing - {{ test_id }}
file:
path: '{{ galaxy_dir }}/ansible_collections'
diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/setup_gpg.yml b/test/integration/targets/ansible-galaxy-collection/tasks/setup_gpg.yml
index ddc4d8a..66fe220 100644
--- a/test/integration/targets/ansible-galaxy-collection/tasks/setup_gpg.yml
+++ b/test/integration/targets/ansible-galaxy-collection/tasks/setup_gpg.yml
@@ -7,6 +7,27 @@
- absent
- directory
+- when: ansible_facts.distribution == 'MacOSX'
+ block:
+ - name: MACOS | Find brew binary
+ command: which brew
+ register: brew_which
+
+ - name: MACOS | Get owner of brew binary
+ stat:
+ path: >-
+ {{ brew_which.stdout }}
+ register: brew_stat
+
+ - command: brew install gpg
+ become: yes
+ become_user: >-
+ {{ brew_stat.stat.pw_name }}
+ environment:
+ HOMEBREW_NO_AUTO_UPDATE: True
+ notify:
+ - uninstall gpg
+
- name: get username for generating key
command: whoami
register: user
diff --git a/test/integration/targets/ansible-galaxy-collection/tasks/verify.yml b/test/integration/targets/ansible-galaxy-collection/tasks/verify.yml
index 0fe2f82..2ad9c83 100644
--- a/test/integration/targets/ansible-galaxy-collection/tasks/verify.yml
+++ b/test/integration/targets/ansible-galaxy-collection/tasks/verify.yml
@@ -270,6 +270,16 @@
path: '{{ galaxy_dir }}/ansible_collections/ansible_test/verify/plugins/modules/test_new_dir'
state: directory
+- name: create a new ignore directory
+ file:
+ path: '{{ galaxy_dir }}/ansible_collections/ansible_test/verify/plugins/modules/__pycache__'
+ state: directory
+
+- name: create a new ignore file
+ file:
+ path: '{{ galaxy_dir }}/ansible_collections/ansible_test/verify/plugins/modules/__pycache__/test.cpython-311.pyc'
+ state: touch
+
- name: verify modified collection locally-only (should fail)
command: ansible-galaxy collection verify --offline ansible_test.verify
register: verify
@@ -282,6 +292,7 @@
- "'plugins/modules/test_module.py' in verify.stdout"
- "'plugins/modules/test_new_file.py' in verify.stdout"
- "'plugins/modules/test_new_dir' in verify.stdout"
+ - "'plugins/modules/__pycache__/test.cpython-311.pyc' not in verify.stdout"
# TODO: add a test for offline Galaxy signature metadata
diff --git a/test/integration/targets/ansible-galaxy-role/files/create-role-archive.py b/test/integration/targets/ansible-galaxy-role/files/create-role-archive.py
index 4876663..3e8424b 100755
--- a/test/integration/targets/ansible-galaxy-role/files/create-role-archive.py
+++ b/test/integration/targets/ansible-galaxy-role/files/create-role-archive.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Create a role archive which overwrites an arbitrary file."""
+from __future__ import annotations
import argparse
import os
diff --git a/test/units/compat/__init__.py b/test/integration/targets/ansible-galaxy-role/files/safe-symlinks/defaults/common_vars/subdir/group0/main.yml
index e69de29..e69de29 100644
--- a/test/units/compat/__init__.py
+++ b/test/integration/targets/ansible-galaxy-role/files/safe-symlinks/defaults/common_vars/subdir/group0/main.yml
diff --git a/test/integration/targets/ansible-galaxy-role/files/safe-symlinks/defaults/main.yml b/test/integration/targets/ansible-galaxy-role/files/safe-symlinks/defaults/main.yml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-role/files/safe-symlinks/defaults/main.yml
diff --git a/test/integration/targets/ansible-galaxy-role/files/safe-symlinks/handlers/utils.yml b/test/integration/targets/ansible-galaxy-role/files/safe-symlinks/handlers/utils.yml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-role/files/safe-symlinks/handlers/utils.yml
diff --git a/test/integration/targets/ansible-galaxy-role/files/safe-symlinks/meta/main.yml b/test/integration/targets/ansible-galaxy-role/files/safe-symlinks/meta/main.yml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-role/files/safe-symlinks/meta/main.yml
diff --git a/test/integration/targets/ansible-galaxy-role/files/safe-symlinks/tasks/utils/suite.yml b/test/integration/targets/ansible-galaxy-role/files/safe-symlinks/tasks/utils/suite.yml
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/integration/targets/ansible-galaxy-role/files/safe-symlinks/tasks/utils/suite.yml
diff --git a/test/integration/targets/ansible-galaxy-role/tasks/valid-role-symlinks.yml b/test/integration/targets/ansible-galaxy-role/tasks/valid-role-symlinks.yml
index 8a60b2e..deb544b 100644
--- a/test/integration/targets/ansible-galaxy-role/tasks/valid-role-symlinks.yml
+++ b/test/integration/targets/ansible-galaxy-role/tasks/valid-role-symlinks.yml
@@ -1,78 +1,38 @@
-- name: create test directories
- file:
- path: '{{ remote_tmp_dir }}/dir-traversal/{{ item }}'
- state: directory
- loop:
- - source
- - target
- - roles
-
-- name: create subdir in the role content to test relative symlinks
- file:
- dest: '{{ remote_tmp_dir }}/dir-traversal/source/role_subdir'
- state: directory
-
-- copy:
- dest: '{{ remote_tmp_dir }}/dir-traversal/source/role_subdir/.keep'
- content: ''
-
-- set_fact:
- installed_roles: "{{ remote_tmp_dir | realpath }}/dir-traversal/roles"
-
-- name: build role with symlink to a directory in the role
- script:
- chdir: '{{ remote_tmp_dir }}/dir-traversal/source'
- cmd: create-role-archive.py safe-link-dir.tar ./ role_subdir/..
- executable: '{{ ansible_playbook_python }}'
-
-- name: install role successfully
- command:
- cmd: 'ansible-galaxy role install --roles-path {{ remote_tmp_dir }}/dir-traversal/roles safe-link-dir.tar'
- chdir: '{{ remote_tmp_dir }}/dir-traversal/source'
- register: galaxy_install_ok
-
-- name: check for the directory symlink in the role
- stat:
- path: "{{ installed_roles }}/safe-link-dir.tar/symlink"
- register: symlink_in_role
-
-- assert:
- that:
- - symlink_in_role.stat.exists
- - symlink_in_role.stat.lnk_source == installed_roles + '/safe-link-dir.tar'
-
-- name: remove tarfile for next test
- file:
- path: '{{ remote_tmp_dir }}/dir-traversal/source/safe-link-dir.tar'
- state: absent
-
-- name: build role with safe relative symlink
- script:
- chdir: '{{ remote_tmp_dir }}/dir-traversal/source'
- cmd: create-role-archive.py safe.tar ./ role_subdir/../context.txt
- executable: '{{ ansible_playbook_python }}'
-
-- name: install role successfully
- command:
- cmd: 'ansible-galaxy role install --roles-path {{ remote_tmp_dir }}/dir-traversal/roles safe.tar'
- chdir: '{{ remote_tmp_dir }}/dir-traversal/source'
- register: galaxy_install_ok
-
-- name: check for symlink in role
- stat:
- path: "{{ installed_roles }}/safe.tar/symlink"
- register: symlink_in_role
-
-- assert:
- that:
- - symlink_in_role.stat.exists
- - symlink_in_role.stat.lnk_source == installed_roles + '/safe.tar/context.txt'
-
-- name: remove test directories
- file:
- path: '{{ remote_tmp_dir }}/dir-traversal/{{ item }}'
- state: absent
- loop:
- - source
- - target
- - roles
+- delegate_to: localhost
+ block:
+ - name: Create archive
+ command: "tar -cf safe-symlinks.tar {{ role_path }}/files/safe-symlinks"
+ args:
+ chdir: "{{ remote_tmp_dir }}"
+
+ - name: Install role successfully
+ command: ansible-galaxy role install --roles-path '{{ remote_tmp_dir }}/roles' safe-symlinks.tar
+ args:
+ chdir: "{{ remote_tmp_dir }}"
+
+ - name: Validate each of the symlinks exists
+ stat:
+ path: "{{ remote_tmp_dir }}/roles/safe-symlinks.tar/{{ item }}"
+ loop:
+ - defaults/main.yml
+ - handlers/utils.yml
+ register: symlink_stat
+
+ - assert:
+ that:
+ - symlink_stat.results[0].stat.exists
+ - symlink_stat.results[0].stat.lnk_source == ((dest, 'roles/safe-symlinks.tar/defaults/common_vars/subdir/group0/main.yml') | path_join)
+ - symlink_stat.results[1].stat.exists
+ - symlink_stat.results[1].stat.lnk_source == ((dest, 'roles/safe-symlinks.tar/tasks/utils/suite.yml') | path_join)
+ vars:
+ dest: "{{ remote_tmp_dir | realpath }}"
+
+ always:
+ - name: Clean up
+ file:
+ path: "{{ item }}"
+ state: absent
+ delegate_to: localhost
+ loop:
+ - "{{ remote_tmp_dir }}/roles/"
+ - "{{ remote_tmp_dir }}/safe-symlinks.tar"
diff --git a/test/integration/targets/ansible-galaxy/files/testserver.py b/test/integration/targets/ansible-galaxy/files/testserver.py
index 8cca6a8..077ae13 100644
--- a/test/integration/targets/ansible-galaxy/files/testserver.py
+++ b/test/integration/targets/ansible-galaxy/files/testserver.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import http.server
import socketserver
diff --git a/test/integration/targets/ansible-inventory/filter_plugins/toml.py b/test/integration/targets/ansible-inventory/filter_plugins/toml.py
index 997173c..6d05cf4 100644
--- a/test/integration/targets/ansible-inventory/filter_plugins/toml.py
+++ b/test/integration/targets/ansible-inventory/filter_plugins/toml.py
@@ -1,9 +1,7 @@
# (c) 2017, Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import functools
diff --git a/test/integration/targets/ansible-playbook-callbacks/callback_list_include_role_fail.expected b/test/integration/targets/ansible-playbook-callbacks/callback_list_include_role_fail.expected
new file mode 100644
index 0000000..ea2f4fe
--- /dev/null
+++ b/test/integration/targets/ansible-playbook-callbacks/callback_list_include_role_fail.expected
@@ -0,0 +1,9 @@
+1 __init__
+7 v2_on_any
+1 v2_playbook_on_play_start
+1 v2_playbook_on_start
+1 v2_playbook_on_stats
+1 v2_playbook_on_task_start
+1 v2_runner_on_failed
+1 v2_runner_on_ok
+1 v2_runner_on_start
diff --git a/test/integration/targets/ansible-playbook-callbacks/callbacks_list.expected b/test/integration/targets/ansible-playbook-callbacks/callbacks_list.expected
index 1d064a2..4a785ac 100644
--- a/test/integration/targets/ansible-playbook-callbacks/callbacks_list.expected
+++ b/test/integration/targets/ansible-playbook-callbacks/callbacks_list.expected
@@ -1,8 +1,8 @@
1 __init__
-92 v2_on_any
+93 v2_on_any
1 v2_on_file_diff
4 v2_playbook_on_handler_task_start
- 2 v2_playbook_on_include
+ 3 v2_playbook_on_include
1 v2_playbook_on_no_hosts_matched
3 v2_playbook_on_notify
3 v2_playbook_on_play_start
diff --git a/test/integration/targets/ansible-playbook-callbacks/include_role-fail.yml b/test/integration/targets/ansible-playbook-callbacks/include_role-fail.yml
new file mode 100644
index 0000000..fbfeb46
--- /dev/null
+++ b/test/integration/targets/ansible-playbook-callbacks/include_role-fail.yml
@@ -0,0 +1,5 @@
+- hosts: localhost
+ gather_facts: false
+ tasks:
+ - include_role:
+ name: does-not-exist
diff --git a/test/integration/targets/ansible-playbook-callbacks/runme.sh b/test/integration/targets/ansible-playbook-callbacks/runme.sh
index 933863e..77a5d9b 100755
--- a/test/integration/targets/ansible-playbook-callbacks/runme.sh
+++ b/test/integration/targets/ansible-playbook-callbacks/runme.sh
@@ -5,8 +5,11 @@ set -eux
export ANSIBLE_CALLBACK_PLUGINS=../support-callback_plugins/callback_plugins
export ANSIBLE_ROLES_PATH=../
export ANSIBLE_STDOUT_CALLBACK=callback_debug
-export ANSIBLE_HOST_PATTERN_MISMATCH=warning
-
-ansible-playbook all-callbacks.yml 2>/dev/null | sort | uniq -c | tee callbacks_list.out
+ANSIBLE_HOST_PATTERN_MISMATCH=warning ansible-playbook all-callbacks.yml 2>/dev/null | sort | uniq -c | tee callbacks_list.out
diff -w callbacks_list.out callbacks_list.expected
+
+for strategy in linear free; do
+ ANSIBLE_STRATEGY=$strategy ansible-playbook include_role-fail.yml 2>/dev/null | sort | uniq -c | tee callback_list_include_role_fail.out
+ diff -w callback_list_include_role_fail.out callback_list_include_role_fail.expected
+done
diff --git a/test/integration/targets/ansible-runner/aliases b/test/integration/targets/ansible-runner/aliases
deleted file mode 100644
index f4caffd..0000000
--- a/test/integration/targets/ansible-runner/aliases
+++ /dev/null
@@ -1,4 +0,0 @@
-shippable/posix/group5
-context/controller
-skip/macos
-skip/freebsd
diff --git a/test/integration/targets/ansible-runner/files/adhoc_example1.py b/test/integration/targets/ansible-runner/files/adhoc_example1.py
deleted file mode 100644
index fe7f944..0000000
--- a/test/integration/targets/ansible-runner/files/adhoc_example1.py
+++ /dev/null
@@ -1,28 +0,0 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import json
-import sys
-import ansible_runner
-
-# the first positional arg should be where the artifacts live
-output_dir = sys.argv[1]
-
-# this calls a single module directly, aka "adhoc" mode
-r = ansible_runner.run(
- private_data_dir=output_dir,
- host_pattern='localhost',
- module='shell',
- module_args='whoami'
-)
-
-data = {
- 'rc': r.rc,
- 'status': r.status,
- 'events': [x['event'] for x in r.events],
- 'stats': r.stats
-}
-
-# insert this header for the flask controller
-print('#STARTJSON')
-json.dump(data, sys.stdout)
diff --git a/test/integration/targets/ansible-runner/files/playbook_example1.py b/test/integration/targets/ansible-runner/files/playbook_example1.py
deleted file mode 100644
index 550c185..0000000
--- a/test/integration/targets/ansible-runner/files/playbook_example1.py
+++ /dev/null
@@ -1,41 +0,0 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import json
-import os
-import sys
-import ansible_runner
-
-
-PLAYBOOK = '''
-- hosts: localhost
- gather_facts: False
- tasks:
- - set_fact:
- foo: bar
-'''
-
-# the first positional arg should be where the artifacts live
-output_dir = sys.argv[1]
-
-invdir = os.path.join(output_dir, 'inventory')
-if not os.path.isdir(invdir):
- os.makedirs(invdir)
-with open(os.path.join(invdir, 'hosts'), 'w') as f:
- f.write('localhost\n')
-pbfile = os.path.join(output_dir, 'test.yml')
-with open(pbfile, 'w') as f:
- f.write(PLAYBOOK)
-
-r = ansible_runner.run(private_data_dir=output_dir, playbook='test.yml')
-
-data = {
- 'rc': r.rc,
- 'status': r.status,
- 'events': [x['event'] for x in r.events],
- 'stats': r.stats
-}
-
-# insert this header for the flask controller
-print('#STARTJSON')
-json.dump(data, sys.stdout)
diff --git a/test/integration/targets/ansible-runner/filter_plugins/parse.py b/test/integration/targets/ansible-runner/filter_plugins/parse.py
deleted file mode 100644
index 7842f6c..0000000
--- a/test/integration/targets/ansible-runner/filter_plugins/parse.py
+++ /dev/null
@@ -1,17 +0,0 @@
-from __future__ import (absolute_import, division, print_function)
-
-__metaclass__ = type
-
-import re
-import json
-
-
-def parse_json(value):
- return json.dumps(json.loads(re.sub('^.*\n#STARTJSON\n', '', value, flags=re.DOTALL)), indent=4, sort_keys=True)
-
-
-class FilterModule(object):
- def filters(self):
- return {
- 'parse_json': parse_json,
- }
diff --git a/test/integration/targets/ansible-runner/inventory b/test/integration/targets/ansible-runner/inventory
deleted file mode 100644
index 009f6c3..0000000
--- a/test/integration/targets/ansible-runner/inventory
+++ /dev/null
@@ -1 +0,0 @@
-# no hosts required, test only requires implicit localhost
diff --git a/test/integration/targets/ansible-runner/runme.sh b/test/integration/targets/ansible-runner/runme.sh
deleted file mode 100755
index 97e6f4d..0000000
--- a/test/integration/targets/ansible-runner/runme.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/env bash
-
-set -eux
-
-source virtualenv.sh
-
-ANSIBLE_ROLES_PATH=../ ansible-playbook test.yml -i inventory "$@"
diff --git a/test/integration/targets/ansible-runner/tasks/adhoc_example1.yml b/test/integration/targets/ansible-runner/tasks/adhoc_example1.yml
deleted file mode 100644
index ce174f1..0000000
--- a/test/integration/targets/ansible-runner/tasks/adhoc_example1.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-- name: execute the script
- command: "'{{ ansible_python_interpreter }}' '{{ role_path }}/files/adhoc_example1.py' '{{ lookup('env', 'OUTPUT_DIR') }}'"
- register: script
-
-- name: parse script output
- # work around for ansible-runner showing ansible warnings on stdout
- set_fact:
- adexec1_json: "{{ script.stdout | parse_json }}"
-
-- assert:
- that:
- - "adexec1_json.rc == 0"
- - "adexec1_json.events|length == 4"
- - "'localhost' in adexec1_json.stats.ok"
diff --git a/test/integration/targets/ansible-runner/tasks/main.yml b/test/integration/targets/ansible-runner/tasks/main.yml
deleted file mode 100644
index ba6a3a2..0000000
--- a/test/integration/targets/ansible-runner/tasks/main.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-- block:
- - include_tasks: setup.yml
- - include_tasks: adhoc_example1.yml
- - include_tasks: playbook_example1.yml
diff --git a/test/integration/targets/ansible-runner/tasks/playbook_example1.yml b/test/integration/targets/ansible-runner/tasks/playbook_example1.yml
deleted file mode 100644
index 1fedb53..0000000
--- a/test/integration/targets/ansible-runner/tasks/playbook_example1.yml
+++ /dev/null
@@ -1,21 +0,0 @@
-- name: execute the script
- command: "'{{ ansible_python_interpreter }}' '{{ role_path }}/files/playbook_example1.py' '{{ lookup('env', 'OUTPUT_DIR') }}'"
- register: script
-
-- name: parse script output
- # work around for ansible-runner showing ansible warnings on stdout
- set_fact:
- pbexec_json: "{{ script.stdout | parse_json }}"
- expected_events:
- - playbook_on_start
- - playbook_on_play_start
- - playbook_on_task_start
- - runner_on_start
- - runner_on_ok
- - playbook_on_stats
-
-- assert:
- that:
- - "pbexec_json.rc == 0"
- - "pbexec_json.events == expected_events"
- - "'localhost' in pbexec_json.stats.ok"
diff --git a/test/integration/targets/ansible-runner/tasks/setup.yml b/test/integration/targets/ansible-runner/tasks/setup.yml
deleted file mode 100644
index 7ee66b2..0000000
--- a/test/integration/targets/ansible-runner/tasks/setup.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-- name: Install ansible-runner
- pip:
- name: ansible-runner
- version: 2.2.0
diff --git a/test/integration/targets/ansible-runner/test.yml b/test/integration/targets/ansible-runner/test.yml
deleted file mode 100644
index 113f8e7..0000000
--- a/test/integration/targets/ansible-runner/test.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-- hosts: localhost
- roles:
- - ansible-runner
diff --git a/test/integration/targets/ansible-test-config-invalid/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_test.py b/test/integration/targets/ansible-test-config-invalid/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_test.py
index 06e7782..c960bfe 100644
--- a/test/integration/targets/ansible-test-config-invalid/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_test.py
+++ b/test/integration/targets/ansible-test-config-invalid/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_test.py
@@ -1,2 +1,5 @@
+from __future__ import annotations
+
+
def test_me():
pass
diff --git a/test/integration/targets/ansible-test-config/ansible_collections/ns/col/plugins/module_utils/test.py b/test/integration/targets/ansible-test-config/ansible_collections/ns/col/plugins/module_utils/test.py
index 962dba2..47450f0 100644
--- a/test/integration/targets/ansible-test-config/ansible_collections/ns/col/plugins/module_utils/test.py
+++ b/test/integration/targets/ansible-test-config/ansible_collections/ns/col/plugins/module_utils/test.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import sys
import os
diff --git a/test/integration/targets/ansible-test-config/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_test.py b/test/integration/targets/ansible-test-config/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_test.py
index b320a15..07b8512 100644
--- a/test/integration/targets/ansible-test-config/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_test.py
+++ b/test/integration/targets/ansible-test-config/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_test.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
from ansible_collections.ns.col.plugins.module_utils import test
diff --git a/test/integration/targets/ansible-test-container/runme.py b/test/integration/targets/ansible-test-container/runme.py
index 3c86b6d..be51852 100755
--- a/test/integration/targets/ansible-test-container/runme.py
+++ b/test/integration/targets/ansible-test-container/runme.py
@@ -23,7 +23,8 @@ import time
import typing as t
UNPRIVILEGED_USER_NAME = 'ansible-test'
-CGROUP_SYSTEMD = pathlib.Path('/sys/fs/cgroup/systemd')
+CGROUP_ROOT = pathlib.Path('/sys/fs/cgroup')
+CGROUP_SYSTEMD = CGROUP_ROOT / 'systemd'
LOG_PATH = pathlib.Path('/tmp/results')
# The value of /proc/*/loginuid when it is not set.
@@ -127,6 +128,16 @@ def main() -> None:
sys.exit(1)
+def get_container_completion_entries() -> dict[str, dict[str, str]]:
+ """Parse and return the ansible-test container completion entries."""
+ completion_lines = pathlib.Path(os.environ['PYTHONPATH'], '../test/lib/ansible_test/_data/completion/docker.txt').read_text().splitlines()
+
+ # TODO: consider including testing for the collection default image
+ entries = {name: value for name, value in (parse_completion_entry(line) for line in completion_lines) if name != 'default'}
+
+ return entries
+
+
def get_test_scenarios() -> list[TestScenario]:
"""Generate and return a list of test scenarios."""
@@ -136,10 +147,7 @@ def get_test_scenarios() -> list[TestScenario]:
if not available_engines:
raise ApplicationError(f'No supported container engines found: {", ".join(supported_engines)}')
- completion_lines = pathlib.Path(os.environ['PYTHONPATH'], '../test/lib/ansible_test/_data/completion/docker.txt').read_text().splitlines()
-
- # TODO: consider including testing for the collection default image
- entries = {name: value for name, value in (parse_completion_entry(line) for line in completion_lines) if name != 'default'}
+ entries = get_container_completion_entries()
unprivileged_user = User.get(UNPRIVILEGED_USER_NAME)
@@ -160,7 +168,6 @@ def get_test_scenarios() -> list[TestScenario]:
for engine in available_engines:
# TODO: figure out how to get tests passing using docker without disabling selinux
disable_selinux = os_release.id == 'fedora' and engine == 'docker' and cgroup != 'none'
- expose_cgroup_v1 = cgroup == 'v1-only' and get_docker_info(engine).cgroup_version != 1
debug_systemd = cgroup != 'none'
# The sleep+pkill used to support the cgroup probe causes problems with the centos6 container.
@@ -173,8 +180,7 @@ def get_test_scenarios() -> list[TestScenario]:
# See: https://access.redhat.com/solutions/6816771
enable_sha1 = os_release.id == 'rhel' and os_release.version_id.startswith('9.') and container_name == 'centos6'
- if cgroup != 'none' and get_docker_info(engine).cgroup_version == 1 and not have_cgroup_systemd():
- expose_cgroup_v1 = True # the host uses cgroup v1 but there is no systemd cgroup and the container requires cgroup support
+ cgroup_version = get_docker_info(engine).cgroup_version
user_scenarios = [
# TODO: test rootless docker
@@ -193,6 +199,20 @@ def get_test_scenarios() -> list[TestScenario]:
user_scenarios.append(UserScenario())
for user_scenario in user_scenarios:
+ expose_cgroup_version: int | None = None # by default the host is assumed to provide sufficient cgroup support for the container and scenario
+
+ if cgroup == 'v1-only' and cgroup_version != 1:
+ expose_cgroup_version = 1 # the container requires cgroup v1 support and the host does not use cgroup v1
+ elif cgroup != 'none' and not have_systemd():
+ # the container requires cgroup support and the host does not use systemd
+ if cgroup_version == 1:
+ expose_cgroup_version = 1 # cgroup v1 mount required
+ elif cgroup_version == 2 and engine == 'podman' and user_scenario.actual != ROOT_USER:
+ # Running a systemd container on a non-systemd host with cgroup v2 fails for rootless podman.
+ # It may be possible to support this scenario, but the necessary configuration to do so is unknown.
+ display.warning(f'Skipping testing of {container_name!r} with rootless podman because the host uses cgroup v2 without systemd.')
+ continue
+
scenarios.append(
TestScenario(
user_scenario=user_scenario,
@@ -200,7 +220,7 @@ def get_test_scenarios() -> list[TestScenario]:
container_name=container_name,
image=image,
disable_selinux=disable_selinux,
- expose_cgroup_v1=expose_cgroup_v1,
+ expose_cgroup_version=expose_cgroup_version,
enable_sha1=enable_sha1,
debug_systemd=debug_systemd,
probe_cgroups=probe_cgroups,
@@ -226,16 +246,19 @@ def run_test(scenario: TestScenario) -> TestResult:
if scenario.probe_cgroups:
target_only_options = ['--dev-probe-cgroups', str(LOG_PATH)]
+ entries = get_container_completion_entries()
+ alpine_container = [name for name in entries if name.startswith('alpine')][0]
+
commands = [
# The cgroup probe is only performed for the first test of the target.
# There's no need to repeat the probe again for the same target.
# The controller will be tested separately as a target.
# This ensures that both the probe and no-probe code paths are functional.
[*integration, *integration_options, *target_only_options],
- # For the split test we'll use alpine3 as the controller. There are two reasons for this:
+ # For the split test we'll use Alpine Linux as the controller. There are two reasons for this:
# 1) It doesn't require the cgroup v1 hack, so we can test a target that doesn't need that.
# 2) It doesn't require disabling selinux, so we can test a target that doesn't need that.
- [*integration, '--controller', 'docker:alpine3', *integration_options],
+ [*integration, '--controller', f'docker:{alpine_container}', *integration_options],
]
common_env: dict[str, str] = {}
@@ -282,7 +305,7 @@ def run_test(scenario: TestScenario) -> TestResult:
message = ''
- if scenario.expose_cgroup_v1:
+ if scenario.expose_cgroup_version == 1:
prepare_cgroup_systemd(scenario.user_scenario.actual.name, scenario.engine)
try:
@@ -307,7 +330,7 @@ def run_test(scenario: TestScenario) -> TestResult:
if scenario.disable_selinux:
run_command('setenforce', 'enforcing')
- if scenario.expose_cgroup_v1:
+ if scenario.expose_cgroup_version == 1:
dirs = remove_cgroup_systemd()
else:
dirs = list_group_systemd()
@@ -398,9 +421,9 @@ def cleanup_podman() -> tuple[str, ...]:
return tuple(sorted(set(cleanup)))
-def have_cgroup_systemd() -> bool:
- """Return True if the container host has a systemd cgroup."""
- return pathlib.Path(CGROUP_SYSTEMD).is_dir()
+def have_systemd() -> bool:
+ """Return True if the host uses systemd."""
+ return pathlib.Path('/run/systemd/system').is_dir()
def prepare_cgroup_systemd(username: str, engine: str) -> None:
@@ -556,7 +579,7 @@ class TestScenario:
container_name: str
image: str
disable_selinux: bool
- expose_cgroup_v1: bool
+ expose_cgroup_version: int | None
enable_sha1: bool
debug_systemd: bool
probe_cgroups: bool
@@ -574,8 +597,8 @@ class TestScenario:
if self.disable_selinux:
tags.append('selinux: permissive')
- if self.expose_cgroup_v1:
- tags.append('cgroup: v1')
+ if self.expose_cgroup_version is not None:
+ tags.append(f'cgroup: {self.expose_cgroup_version}')
if self.enable_sha1:
tags.append('sha1: enabled')
@@ -950,6 +973,15 @@ class DnfBootstrapper(Bootstrapper):
# See: https://github.com/containers/netavark/issues/491
packages.append('netavark-1.0.2')
+ if os_release.id == 'fedora' and os_release.version_id == '39':
+ # In Fedora 39, the current version of containerd, 1.6.23, prevents Docker from working.
+ # The previously tested version, 1.6.19, did not have this issue.
+ # See: https://bugzilla.redhat.com/show_bug.cgi?id=2237396
+ run_command(
+ 'dnf', 'install', '-y',
+ 'https://kojipkgs.fedoraproject.org/packages/containerd/1.6.19/2.fc39/x86_64/containerd-1.6.19-2.fc39.x86_64.rpm'
+ )
+
if os_release.id == 'rhel':
# As of the release of RHEL 9.1, installing podman on RHEL 9.0 results in a non-fatal error at install time:
#
@@ -1050,17 +1082,22 @@ class ApkBootstrapper(Bootstrapper):
def run(cls) -> None:
"""Run the bootstrapper."""
# The `openssl` package is used to generate hashed passwords.
- # crun added as podman won't install it as dep if runc is present
- # but we don't want runc as it fails
- # The edge `crun` package installed below requires ip6tables, and in
- # edge, the `iptables` package includes `ip6tables`, but in 3.18 they
- # are separate. Remove `ip6tables` once we update to 3.19.
- packages = ['docker', 'podman', 'openssl', 'crun', 'ip6tables']
+ # The `crun` package must be explicitly installed since podman won't install it as dep if `runc` is present.
+ packages = ['docker', 'podman', 'openssl', 'crun']
+
+ if os_release.version_id.startswith('3.18.'):
+ # The 3.19 `crun` package installed below requires `ip6tables`, but depends on the `iptables` package.
+ # In 3.19, the `iptables` package includes `ip6tables`, but in 3.18 they are separate packages.
+ # Remove once 3.18 is no longer tested.
+ packages.append('ip6tables')
run_command('apk', 'add', *packages)
- # 3.18 only contains crun 1.8.4, to get 1.9.2 to resolve the run/shm issue, install crun from 3.19
- # Remove once we update to 3.19
- run_command('apk', 'upgrade', '-U', '--repository=http://dl-cdn.alpinelinux.org/alpine/v3.19/community', 'crun')
+
+ if os_release.version_id.startswith('3.18.'):
+ # 3.18 only contains `crun` 1.8.4, to get a newer version that resolves the run/shm issue, install `crun` from 3.19.
+ # Remove once 3.18 is no longer tested.
+ run_command('apk', 'upgrade', '-U', '--repository=http://dl-cdn.alpinelinux.org/alpine/v3.19/community', 'crun')
+
run_command('service', 'docker', 'start')
run_command('modprobe', 'tun')
diff --git a/test/integration/targets/ansible-test-coverage/ansible_collections/ns/col/plugins/module_utils/test_util.py b/test/integration/targets/ansible-test-coverage/ansible_collections/ns/col/plugins/module_utils/test_util.py
index 481c4b8..e8d6b91 100644
--- a/test/integration/targets/ansible-test-coverage/ansible_collections/ns/col/plugins/module_utils/test_util.py
+++ b/test/integration/targets/ansible-test-coverage/ansible_collections/ns/col/plugins/module_utils/test_util.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
def test_coverage():
diff --git a/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/doc_fragments/ps_util.py b/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/doc_fragments/ps_util.py
index e69844b..c8e8b70 100644
--- a/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/doc_fragments/ps_util.py
+++ b/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/doc_fragments/ps_util.py
@@ -3,8 +3,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class ModuleDocFragment:
diff --git a/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/module_utils/my_util.py b/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/module_utils/my_util.py
index b9c531c..ff10e2d 100644
--- a/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/module_utils/my_util.py
+++ b/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/module_utils/my_util.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
def hello(name):
diff --git a/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/modules/hello.py b/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/modules/hello.py
index c8a0cf7..a685933 100644
--- a/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/modules/hello.py
+++ b/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/plugins/modules/hello.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
module: hello
diff --git a/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_my_util.py b/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_my_util.py
index 7df8710..84a49ac 100644
--- a/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_my_util.py
+++ b/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_my_util.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from .....plugins.module_utils.my_util import hello
diff --git a/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/modules/test_hello.py b/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/modules/test_hello.py
index 95ee057..46c9de1 100644
--- a/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/modules/test_hello.py
+++ b/test/integration/targets/ansible-test-docker/ansible_collections/ns/col/tests/unit/plugins/modules/test_hello.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from .....plugins.modules.hello import say_hello
diff --git a/test/integration/targets/ansible-test-integration-targets/test.py b/test/integration/targets/ansible-test-integration-targets/test.py
index 8effb64..10fa2d4 100755
--- a/test/integration/targets/ansible-test-integration-targets/test.py
+++ b/test/integration/targets/ansible-test-integration-targets/test.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import annotations
import subprocess
import unittest
diff --git a/test/integration/targets/ansible-test-integration/ansible_collections/ns/col/plugins/module_utils/my_util.py b/test/integration/targets/ansible-test-integration/ansible_collections/ns/col/plugins/module_utils/my_util.py
index b9c531c..ff10e2d 100644
--- a/test/integration/targets/ansible-test-integration/ansible_collections/ns/col/plugins/module_utils/my_util.py
+++ b/test/integration/targets/ansible-test-integration/ansible_collections/ns/col/plugins/module_utils/my_util.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
def hello(name):
diff --git a/test/integration/targets/ansible-test-integration/ansible_collections/ns/col/plugins/modules/hello.py b/test/integration/targets/ansible-test-integration/ansible_collections/ns/col/plugins/modules/hello.py
index 033b6c9..06ff6d4 100644
--- a/test/integration/targets/ansible-test-integration/ansible_collections/ns/col/plugins/modules/hello.py
+++ b/test/integration/targets/ansible-test-integration/ansible_collections/ns/col/plugins/modules/hello.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
module: hello
diff --git a/test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/run-with-pty.py b/test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/run-with-pty.py
index 4639152..b4ccb7b 100755
--- a/test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/run-with-pty.py
+++ b/test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/run-with-pty.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Run a command using a PTY."""
+from __future__ import annotations
import sys
diff --git a/test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/tests/integration/targets/no-tty/assert-no-tty.py b/test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/tests/integration/targets/no-tty/assert-no-tty.py
index a2b094e..d7f3eb7 100755
--- a/test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/tests/integration/targets/no-tty/assert-no-tty.py
+++ b/test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/tests/integration/targets/no-tty/assert-no-tty.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Assert no TTY is available."""
+from __future__ import annotations
import sys
diff --git a/test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/vendored_pty.py b/test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/vendored_pty.py
index bc70803..346bae3 100644
--- a/test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/vendored_pty.py
+++ b/test/integration/targets/ansible-test-no-tty/ansible_collections/ns/col/vendored_pty.py
@@ -7,6 +7,7 @@
# See: W. Richard Stevens. 1992. Advanced Programming in the
# UNIX Environment. Chapter 19.
# Author: Steen Lumholt -- with additions by Guido.
+from __future__ import annotations
from select import select
import os
diff --git a/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/lookup/a/b/lookup2.py b/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/lookup/a/b/lookup2.py
index 5cd2cf0..950b26b 100644
--- a/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/lookup/a/b/lookup2.py
+++ b/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/lookup/a/b/lookup2.py
@@ -1,7 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = """
name: lookup2
diff --git a/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/lookup/lookup1.py b/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/lookup/lookup1.py
index e274f19..45d37f2 100644
--- a/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/lookup/lookup1.py
+++ b/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/lookup/lookup1.py
@@ -1,7 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = """
name: lookup1
diff --git a/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/modules/a/b/module2.py b/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/modules/a/b/module2.py
index 6fafa19..500beaa 100644
--- a/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/modules/a/b/module2.py
+++ b/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/modules/a/b/module2.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
module: module2
diff --git a/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/modules/module1.py b/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/modules/module1.py
index 8847f5b..45e3977 100644
--- a/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/modules/module1.py
+++ b/test/integration/targets/ansible-test-sanity-ansible-doc/ansible_collections/ns/col/plugins/modules/module1.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
module: module1
diff --git a/test/integration/targets/ansible-test-sanity-import/ansible_collections/ns/col/plugins/lookup/vendor1.py b/test/integration/targets/ansible-test-sanity-import/ansible_collections/ns/col/plugins/lookup/vendor1.py
index f662b97..3cf63c0 100644
--- a/test/integration/targets/ansible-test-sanity-import/ansible_collections/ns/col/plugins/lookup/vendor1.py
+++ b/test/integration/targets/ansible-test-sanity-import/ansible_collections/ns/col/plugins/lookup/vendor1.py
@@ -1,7 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
name: vendor1
diff --git a/test/integration/targets/ansible-test-sanity-import/ansible_collections/ns/col/plugins/lookup/vendor2.py b/test/integration/targets/ansible-test-sanity-import/ansible_collections/ns/col/plugins/lookup/vendor2.py
index 38860b0..d22f718 100644
--- a/test/integration/targets/ansible-test-sanity-import/ansible_collections/ns/col/plugins/lookup/vendor2.py
+++ b/test/integration/targets/ansible-test-sanity-import/ansible_collections/ns/col/plugins/lookup/vendor2.py
@@ -1,7 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
name: vendor2
diff --git a/test/integration/targets/ansible-test-sanity-no-get-exception/ansible_collections/ns/col/do-not-check-me.py b/test/integration/targets/ansible-test-sanity-no-get-exception/ansible_collections/ns/col/do-not-check-me.py
index ca25269..9d3779d 100644
--- a/test/integration/targets/ansible-test-sanity-no-get-exception/ansible_collections/ns/col/do-not-check-me.py
+++ b/test/integration/targets/ansible-test-sanity-no-get-exception/ansible_collections/ns/col/do-not-check-me.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
from ansible.module_utils.pycompat24 import get_exception
diff --git a/test/integration/targets/ansible-test-sanity-no-get-exception/ansible_collections/ns/col/plugins/modules/check-me.py b/test/integration/targets/ansible-test-sanity-no-get-exception/ansible_collections/ns/col/plugins/modules/check-me.py
index ca25269..9d3779d 100644
--- a/test/integration/targets/ansible-test-sanity-no-get-exception/ansible_collections/ns/col/plugins/modules/check-me.py
+++ b/test/integration/targets/ansible-test-sanity-no-get-exception/ansible_collections/ns/col/plugins/modules/check-me.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
from ansible.module_utils.pycompat24 import get_exception
diff --git a/test/integration/targets/ansible-test-sanity-no-get-exception/expected.txt b/test/integration/targets/ansible-test-sanity-no-get-exception/expected.txt
index 4c432cb..d076bb7 100644
--- a/test/integration/targets/ansible-test-sanity-no-get-exception/expected.txt
+++ b/test/integration/targets/ansible-test-sanity-no-get-exception/expected.txt
@@ -1,2 +1,2 @@
-plugins/modules/check-me.py:1:44: do not use `get_exception`
-plugins/modules/check-me.py:5:4: do not use `get_exception`
+plugins/modules/check-me.py:3:44: do not use `get_exception`
+plugins/modules/check-me.py:7:4: do not use `get_exception`
diff --git a/test/integration/targets/ansible-test-sanity-pylint/ansible_collections/ns/col/plugins/lookup/deprecated.py b/test/integration/targets/ansible-test-sanity-pylint/ansible_collections/ns/col/plugins/lookup/deprecated.py
index b7908b6..1066e64 100644
--- a/test/integration/targets/ansible-test-sanity-pylint/ansible_collections/ns/col/plugins/lookup/deprecated.py
+++ b/test/integration/targets/ansible-test-sanity-pylint/ansible_collections/ns/col/plugins/lookup/deprecated.py
@@ -1,7 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
name: deprecated
diff --git a/test/integration/targets/ansible-test-sanity-pylint/expected.txt b/test/integration/targets/ansible-test-sanity-pylint/expected.txt
index df7bbc2..9c53a30 100644
--- a/test/integration/targets/ansible-test-sanity-pylint/expected.txt
+++ b/test/integration/targets/ansible-test-sanity-pylint/expected.txt
@@ -1 +1 @@
-plugins/lookup/deprecated.py:27:0: collection-deprecated-version: Deprecated version ('2.0.0') found in call to Display.deprecated or AnsibleModule.deprecate
+plugins/lookup/deprecated.py:26:0: collection-deprecated-version: Deprecated version ('2.0.0') found in call to Display.deprecated or AnsibleModule.deprecate
diff --git a/test/integration/targets/ansible-test-sanity-replace-urlopen/ansible_collections/ns/col/do-not-check-me.py b/test/integration/targets/ansible-test-sanity-replace-urlopen/ansible_collections/ns/col/do-not-check-me.py
index 9b9c7e6..9f70d26 100644
--- a/test/integration/targets/ansible-test-sanity-replace-urlopen/ansible_collections/ns/col/do-not-check-me.py
+++ b/test/integration/targets/ansible-test-sanity-replace-urlopen/ansible_collections/ns/col/do-not-check-me.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import urllib.request
diff --git a/test/integration/targets/ansible-test-sanity-replace-urlopen/ansible_collections/ns/col/plugins/modules/check-me.py b/test/integration/targets/ansible-test-sanity-replace-urlopen/ansible_collections/ns/col/plugins/modules/check-me.py
index 9b9c7e6..9f70d26 100644
--- a/test/integration/targets/ansible-test-sanity-replace-urlopen/ansible_collections/ns/col/plugins/modules/check-me.py
+++ b/test/integration/targets/ansible-test-sanity-replace-urlopen/ansible_collections/ns/col/plugins/modules/check-me.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import urllib.request
diff --git a/test/integration/targets/ansible-test-sanity-replace-urlopen/expected.txt b/test/integration/targets/ansible-test-sanity-replace-urlopen/expected.txt
index 4dd1bfb..45835fa 100644
--- a/test/integration/targets/ansible-test-sanity-replace-urlopen/expected.txt
+++ b/test/integration/targets/ansible-test-sanity-replace-urlopen/expected.txt
@@ -1 +1 @@
-plugins/modules/check-me.py:5:20: use `ansible.module_utils.urls.open_url` instead of `urlopen`
+plugins/modules/check-me.py:7:20: use `ansible.module_utils.urls.open_url` instead of `urlopen`
diff --git a/test/integration/targets/ansible-test-sanity-use-compat-six/ansible_collections/ns/col/do-not-check-me.py b/test/integration/targets/ansible-test-sanity-use-compat-six/ansible_collections/ns/col/do-not-check-me.py
index 7f7f9f5..a3ea929 100644
--- a/test/integration/targets/ansible-test-sanity-use-compat-six/ansible_collections/ns/col/do-not-check-me.py
+++ b/test/integration/targets/ansible-test-sanity-use-compat-six/ansible_collections/ns/col/do-not-check-me.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import six
diff --git a/test/integration/targets/ansible-test-sanity-use-compat-six/ansible_collections/ns/col/plugins/modules/check-me.py b/test/integration/targets/ansible-test-sanity-use-compat-six/ansible_collections/ns/col/plugins/modules/check-me.py
index 7f7f9f5..a3ea929 100644
--- a/test/integration/targets/ansible-test-sanity-use-compat-six/ansible_collections/ns/col/plugins/modules/check-me.py
+++ b/test/integration/targets/ansible-test-sanity-use-compat-six/ansible_collections/ns/col/plugins/modules/check-me.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import six
diff --git a/test/integration/targets/ansible-test-sanity-use-compat-six/expected.txt b/test/integration/targets/ansible-test-sanity-use-compat-six/expected.txt
index 42ba83b..c3b005d 100644
--- a/test/integration/targets/ansible-test-sanity-use-compat-six/expected.txt
+++ b/test/integration/targets/ansible-test-sanity-use-compat-six/expected.txt
@@ -1 +1 @@
-plugins/modules/check-me.py:1:1: use `ansible.module_utils.six` instead of `six`
+plugins/modules/check-me.py:3:1: use `ansible.module_utils.six` instead of `six`
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/_not_deprecated.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/_not_deprecated.py
new file mode 100644
index 0000000..4b4b091
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/_not_deprecated.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import annotations
+
+DOCUMENTATION = '''
+module: _not_deprecated
+short_description: This module is not deprecated
+description: Its name has a leading underscore, but it is not deprecated.
+author:
+ - Ansible Core Team
+'''
+
+EXAMPLES = '''#'''
+RETURN = ''''''
+
+from ansible.module_utils.basic import AnsibleModule
+
+
+if __name__ == '__main__':
+ module = AnsibleModule(argument_spec=dict())
+ module.exit_json()
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_1.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_1.py
index 1b23b49..7f53b26 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_1.py
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_1.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
module: check_mode_attribute_1
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_2.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_2.py
index 0687e9f..263e5b8 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_2.py
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_2.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
module: check_mode_attribute_2
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_3.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_3.py
index 61226e6..a2bf699 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_3.py
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_3.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
module: check_mode_attribute_3
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_4.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_4.py
index 1cb7813..0d442e8 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_4.py
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_4.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
module: check_mode_attribute_4
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_5.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_5.py
index a8d8556..86bc94f 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_5.py
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_5.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
module: check_mode_attribute_5
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_6.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_6.py
index cd5a4fb..966d62c 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_6.py
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_6.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
module: check_mode_attribute_6
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_7.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_7.py
index 73d976c..0b77937 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_7.py
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/check_mode_attribute_7.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
module: check_mode_attribute_7
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/import_order.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/import_order.py
index f4f3c9b..84c2ed9 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/import_order.py
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/import_order.py
@@ -1,9 +1,8 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_argument_spec_extra_key.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_argument_spec_extra_key.py
new file mode 100644
index 0000000..04807a1
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_argument_spec_extra_key.py
@@ -0,0 +1,36 @@
+#!/usr/bin/python
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import annotations
+
+DOCUMENTATION = '''
+module: invalid_argument_spec_extra_key
+short_description: Invalid argument spec extra key schema test module
+description: Invalid argument spec extra key schema test module
+author:
+ - Ansible Core Team
+options:
+ foo:
+ description: foo
+ type: str
+'''
+
+EXAMPLES = '''#'''
+RETURN = ''''''
+
+from ansible.module_utils.basic import AnsibleModule
+
+
+def main():
+ AnsibleModule(
+ argument_spec=dict(
+ foo=dict(
+ type='str',
+ extra_key='bar',
+ ),
+ ),
+ )
+
+
+if __name__ == '__main__':
+ main()
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_argument_spec_incorrect_context.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_argument_spec_incorrect_context.py
new file mode 100644
index 0000000..6e3d244
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_argument_spec_incorrect_context.py
@@ -0,0 +1,36 @@
+#!/usr/bin/python
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import annotations
+
+DOCUMENTATION = '''
+module: invalid_argument_spec_incorrect_context
+short_description: Invalid argument spec incorrect context schema test module
+description: Invalid argument spec incorrect context schema test module
+author:
+ - Ansible Core Team
+options:
+ foo:
+ description: foo
+ type: str
+'''
+
+EXAMPLES = '''#'''
+RETURN = ''''''
+
+from ansible.module_utils.basic import AnsibleModule
+
+
+def main():
+ AnsibleModule(
+ argument_spec=dict(
+ foo=dict(
+ type='str',
+ context='bar',
+ ),
+ ),
+ )
+
+
+if __name__ == '__main__':
+ main()
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_choice_value.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_choice_value.py
new file mode 100644
index 0000000..42b315d
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_choice_value.py
@@ -0,0 +1,33 @@
+#!/usr/bin/python
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import annotations
+
+DOCUMENTATION = """
+module: invalid_choice_value
+short_description: Test for equal length of chocies with correct options
+description: Test for equal length of chocies with correct options
+author:
+ - Ansible Core Team
+options:
+ caching:
+ description:
+ - Type of Caching.
+ type: str
+ choices:
+ - ReadOnly
+ - ReadWrite
+"""
+
+EXAMPLES = """#"""
+RETURN = """"""
+
+from ansible.module_utils.basic import AnsibleModule
+
+
+if __name__ == "__main__":
+ module = AnsibleModule(
+ argument_spec=dict(caching=dict(type="str", choices=["ReadOnly", "ReadOnly"])),
+ supports_check_mode=False,
+ )
+ module.exit_json()
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_yaml_syntax.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_yaml_syntax.py
index 5dd753f..7931798 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_yaml_syntax.py
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/invalid_yaml_syntax.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
- key: "value"wrong
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/no_callable.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/no_callable.py
index 176376a..7004c70 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/no_callable.py
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/no_callable.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
module: no_callable
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/semantic_markup.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/semantic_markup.py
index 587731d..86eca45 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/semantic_markup.py
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/semantic_markup.py
@@ -1,9 +1,8 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
DOCUMENTATION = r'''
module: semantic_markup
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/sidecar.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/sidecar.py
index 8377c40..c5289b8 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/sidecar.py
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/sidecar.py
@@ -1,5 +1,6 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/unsupported_extension.nope b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/unsupported_extension.nope
new file mode 100644
index 0000000..28ec361
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/unsupported_extension.nope
@@ -0,0 +1,2 @@
+This file has an extension which is not supported by validate-modules.
+It should not be treated as a Python file or have Python-specific rules applied to it.
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/valid_argument_spec_context.py b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/valid_argument_spec_context.py
new file mode 100644
index 0000000..2aa67ab
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/ansible_collections/ns/col/plugins/modules/valid_argument_spec_context.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import annotations
+
+DOCUMENTATION = '''
+module: valid_argument_spec_context
+short_description: Valid argument spec context schema test module
+description: Valid argument spec context schema test module
+author:
+ - Ansible Core Team
+options:
+ foo:
+ description: foo
+ type: str
+'''
+
+EXAMPLES = '''#'''
+RETURN = ''''''
+
+from ansible.module_utils.basic import AnsibleModule
+
+
+def main():
+ AnsibleModule(
+ argument_spec=dict(
+ foo=dict(
+ type='str',
+ context=dict(
+ extra_key='bar',
+ ),
+ ),
+ ),
+ )
+
+
+if __name__ == '__main__':
+ main()
diff --git a/test/integration/targets/ansible-test-sanity-validate-modules/expected.txt b/test/integration/targets/ansible-test-sanity-validate-modules/expected.txt
index ca6e52a..3ae113c 100644
--- a/test/integration/targets/ansible-test-sanity-validate-modules/expected.txt
+++ b/test/integration/targets/ansible-test-sanity-validate-modules/expected.txt
@@ -3,12 +3,15 @@ plugins/modules/check_mode_attribute_1.py:0:0: attributes-check-mode: The module
plugins/modules/check_mode_attribute_2.py:0:0: attributes-check-mode: The module does not declare support for check mode, but the check_mode attribute's support value is 'partial' and not 'none'
plugins/modules/check_mode_attribute_3.py:0:0: attributes-check-mode: The module does declare support for check mode, but the check_mode attribute's support value is 'none'
plugins/modules/check_mode_attribute_4.py:0:0: attributes-check-mode-details: The module declares it does not fully support check mode, but has no details on what exactly that means
-plugins/modules/import_order.py:8:0: import-before-documentation: Import found before documentation variables. All imports must appear below DOCUMENTATION/EXAMPLES/RETURN.
+plugins/modules/import_order.py:7:0: import-before-documentation: Import found before documentation variables. All imports must appear below DOCUMENTATION/EXAMPLES/RETURN.
+plugins/modules/invalid_argument_spec_extra_key.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.foo.extra_key: extra keys not allowed @ data['argument_spec']['foo']['extra_key']. Got 'bar'
+plugins/modules/invalid_argument_spec_incorrect_context.py:0:0: invalid-ansiblemodule-schema: AnsibleModule.argument_spec.foo.context: expected dict for dictionary value @ data['argument_spec']['foo']['context']. Got 'bar'
+plugins/modules/invalid_choice_value.py:0:0: doc-choices-do-not-match-spec: Argument 'caching' in argument_spec defines choices as (['ReadOnly', 'ReadOnly']) but documentation defines choices as (['ReadOnly', 'ReadWrite'])
plugins/modules/invalid_yaml_syntax.py:0:0: deprecation-mismatch: "meta/runtime.yml" and DOCUMENTATION.deprecation do not agree.
plugins/modules/invalid_yaml_syntax.py:0:0: missing-documentation: No DOCUMENTATION provided
-plugins/modules/invalid_yaml_syntax.py:8:15: documentation-syntax-error: DOCUMENTATION is not valid YAML
-plugins/modules/invalid_yaml_syntax.py:12:15: invalid-examples: EXAMPLES is not valid YAML
-plugins/modules/invalid_yaml_syntax.py:16:15: return-syntax-error: RETURN is not valid YAML
+plugins/modules/invalid_yaml_syntax.py:7:15: documentation-syntax-error: DOCUMENTATION is not valid YAML
+plugins/modules/invalid_yaml_syntax.py:11:15: invalid-examples: EXAMPLES is not valid YAML
+plugins/modules/invalid_yaml_syntax.py:15:15: return-syntax-error: RETURN is not valid YAML
plugins/modules/semantic_markup.py:0:0: invalid-documentation-markup: DOCUMENTATION.options.a11.suboptions.b1.description.0: While parsing "V(C\(" at index 1: Unnecessarily escaped "(" @ data['options']['a11']['suboptions']['b1']['description'][0]. Got 'V(C\\(foo\\)).'
plugins/modules/semantic_markup.py:0:0: invalid-documentation-markup: DOCUMENTATION.options.a11.suboptions.b1.description.2: While parsing "P(foo.bar#baz)" at index 1: Plugin name "foo.bar" is not a FQCN @ data['options']['a11']['suboptions']['b1']['description'][2]. Got 'P(foo.bar#baz).'
plugins/modules/semantic_markup.py:0:0: invalid-documentation-markup: DOCUMENTATION.options.a11.suboptions.b1.description.3: While parsing "P(foo.bar.baz)" at index 1: Parameter "foo.bar.baz" is not of the form FQCN#type @ data['options']['a11']['suboptions']['b1']['description'][3]. Got 'P(foo.bar.baz).'
@@ -24,3 +27,5 @@ plugins/modules/semantic_markup.py:0:0: invalid-documentation-markup: Directive
plugins/modules/semantic_markup.py:0:0: invalid-documentation-markup: Directive "O(foo.bar=1)" contains a non-existing option "foo.bar"
plugins/modules/semantic_markup.py:0:0: invalid-documentation-markup: Directive "RV(bam)" contains a non-existing return value "bam"
plugins/modules/semantic_markup.py:0:0: invalid-documentation-markup: Directive "RV(does.not.exist=true)" contains a non-existing return value "does.not.exist"
+plugins/modules/unsupported_extension.nope:0:0: invalid-extension: Official Ansible modules must have a .py extension for python modules or a .ps1 for powershell modules
+plugins/modules/unsupported_extension.nope:0:0: missing-gplv3-license: GPLv3 license header not found in the first 20 lines of the module
diff --git a/test/integration/targets/ansible-test-sanity-yamllint/aliases b/test/integration/targets/ansible-test-sanity-yamllint/aliases
new file mode 100644
index 0000000..7741d44
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity-yamllint/aliases
@@ -0,0 +1,4 @@
+shippable/posix/group3 # runs in the distro test containers
+shippable/generic/group1 # runs in the default test container
+context/controller
+needs/target/collection
diff --git a/test/integration/targets/ansible-test-sanity-yamllint/ansible_collections/ns/col/plugins/inventory/inventory1.py b/test/integration/targets/ansible-test-sanity-yamllint/ansible_collections/ns/col/plugins/inventory/inventory1.py
new file mode 100644
index 0000000..b358e53
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity-yamllint/ansible_collections/ns/col/plugins/inventory/inventory1.py
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import annotations
+
+DOCUMENTATION = r"""
+---
+ module: module2
+ short_description: Hello test module
+ description: Hello test module.
+ options:
+ plugin:
+ required: true
+ description: name of the plugin (cache_host)
+ author:
+ - Ansible Core Team
+"""
+
+EXAMPLES = r"""
+---
+
+first_doc:
+some_key:
+
+---
+
+second_doc:
+some_key:
+
+"""
+
+RETURN = r"""
+---
+---
+"""
+
+from ansible.plugins.inventory import BaseInventoryPlugin
+
+
+class InventoryModule(BaseInventoryPlugin):
+
+ NAME = 'inventory1'
diff --git a/test/integration/targets/ansible-test-sanity-yamllint/ansible_collections/ns/col/plugins/modules/module1.py b/test/integration/targets/ansible-test-sanity-yamllint/ansible_collections/ns/col/plugins/modules/module1.py
new file mode 100644
index 0000000..14e7239
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity-yamllint/ansible_collections/ns/col/plugins/modules/module1.py
@@ -0,0 +1,40 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import annotations
+
+DOCUMENTATION = r"""
+module: module1
+short_description: Hello test module
+description: Hello test module.
+options: {}
+author:
+ - Ansible Core Team
+short_description: Duplicate short description
+"""
+
+EXAMPLES = r"""
+- minimal:
+"""
+
+RETURN = r"""
+invalid_yaml:
+ bad_indent:
+ usual_indent:
+"""
+
+from ansible.module_utils.basic import AnsibleModule
+
+
+def main():
+ module = AnsibleModule(
+ argument_spec={},
+ )
+
+ module.exit_json()
+
+
+if __name__ == "__main__":
+ main()
diff --git a/test/integration/targets/ansible-test-sanity-yamllint/expected.txt b/test/integration/targets/ansible-test-sanity-yamllint/expected.txt
new file mode 100644
index 0000000..c9ba525
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity-yamllint/expected.txt
@@ -0,0 +1,4 @@
+plugins/inventory/inventory1.py:34:1: multiple-yaml-documents: RETURN: expected a single document in the stream
+plugins/modules/module1.py:15:1: key-duplicates: DOCUMENTATION: duplication of key "short_description" in mapping
+plugins/modules/module1.py:25:3: error: RETURN: syntax error: expected <block end>, but found '<block mapping start>' (syntax)
+plugins/modules/module1.py:25:3: unparsable-with-libyaml: RETURN: while parsing a block mapping - did not find expected key
diff --git a/test/integration/targets/ansible-test-sanity-yamllint/runme.sh b/test/integration/targets/ansible-test-sanity-yamllint/runme.sh
new file mode 100755
index 0000000..a333ccb
--- /dev/null
+++ b/test/integration/targets/ansible-test-sanity-yamllint/runme.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+set -eu
+
+source ../collection/setup.sh
+
+set -x
+
+ansible-test sanity --test yamllint --color --lint --failure-ok "${@}" > actual.txt
+
+diff -u "${TEST_DIR}/expected.txt" actual.txt
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/bad.py b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/bad.py
index 16e0bc8..617353b 100644
--- a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/bad.py
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/bad.py
@@ -1,7 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
name: bad
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/world.py b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/world.py
index 5cdd096..093447d 100644
--- a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/world.py
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/lookup/world.py
@@ -1,7 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
name: world
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/modules/bad.py b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/modules/bad.py
index 8780e35..72d859a 100644
--- a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/modules/bad.py
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/modules/bad.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
module: bad
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/plugin_utils/check_pylint.py b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/plugin_utils/check_pylint.py
index 1fe4dfa..6ec9023 100644
--- a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/plugin_utils/check_pylint.py
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/plugin_utils/check_pylint.py
@@ -2,8 +2,7 @@
These test cases verify ansible-test version constraints for pylint and its dependencies across Python versions.
The initial test cases were discovered while testing various Python versions against ansible/ansible.
"""
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
# Python 3.8 fails with astroid 2.2.5 but works on 2.3.3
# syntax-error: Cannot import 'string' due to syntax error 'invalid syntax (&lt;unknown&gt;, line 109)'
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/random_directory/bad.py b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/random_directory/bad.py
index e34d1c3..ec2aefa 100644
--- a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/random_directory/bad.py
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/plugins/random_directory/bad.py
@@ -1,7 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
# This is not an allowed import, but since this file is in a plugins/ subdirectory that is not checked,
# the import sanity test will not complain.
diff --git a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py
index a5d896f..d793196 100644
--- a/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py
+++ b/test/integration/targets/ansible-test-sanity/ansible_collections/ns/col/tests/integration/targets/hello/files/bad.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import tempfile
diff --git a/test/integration/targets/ansible-test-units-assertions/ansible_collections/ns/col/tests/unit/plugins/modules/test_assertion.py b/test/integration/targets/ansible-test-units-assertions/ansible_collections/ns/col/tests/unit/plugins/modules/test_assertion.py
index e172200..6b60ae6 100644
--- a/test/integration/targets/ansible-test-units-assertions/ansible_collections/ns/col/tests/unit/plugins/modules/test_assertion.py
+++ b/test/integration/targets/ansible-test-units-assertions/ansible_collections/ns/col/tests/unit/plugins/modules/test_assertion.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
def test_assertion():
diff --git a/test/integration/targets/ansible-test-units-constraints/ansible_collections/ns/col/tests/unit/plugins/modules/test_constraints.py b/test/integration/targets/ansible-test-units-constraints/ansible_collections/ns/col/tests/unit/plugins/modules/test_constraints.py
index 857e8e5..2b50101 100644
--- a/test/integration/targets/ansible-test-units-constraints/ansible_collections/ns/col/tests/unit/plugins/modules/test_constraints.py
+++ b/test/integration/targets/ansible-test-units-constraints/ansible_collections/ns/col/tests/unit/plugins/modules/test_constraints.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import botocore
diff --git a/test/integration/targets/ansible-test-units-forked/ansible_collections/ns/col/tests/unit/plugins/modules/test_ansible_forked.py b/test/integration/targets/ansible-test-units-forked/ansible_collections/ns/col/tests/unit/plugins/modules/test_ansible_forked.py
index 828099c..8ce7d43 100644
--- a/test/integration/targets/ansible-test-units-forked/ansible_collections/ns/col/tests/unit/plugins/modules/test_ansible_forked.py
+++ b/test/integration/targets/ansible-test-units-forked/ansible_collections/ns/col/tests/unit/plugins/modules/test_ansible_forked.py
@@ -1,7 +1,6 @@
"""Unit tests to verify the functionality of the ansible-forked pytest plugin."""
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import os
import pytest
diff --git a/test/integration/targets/ansible-test-units/ansible_collections/ns/col/plugins/module_utils/my_util.py b/test/integration/targets/ansible-test-units/ansible_collections/ns/col/plugins/module_utils/my_util.py
index b9c531c..ff10e2d 100644
--- a/test/integration/targets/ansible-test-units/ansible_collections/ns/col/plugins/module_utils/my_util.py
+++ b/test/integration/targets/ansible-test-units/ansible_collections/ns/col/plugins/module_utils/my_util.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
def hello(name):
diff --git a/test/integration/targets/ansible-test-units/ansible_collections/ns/col/plugins/modules/hello.py b/test/integration/targets/ansible-test-units/ansible_collections/ns/col/plugins/modules/hello.py
index 033b6c9..06ff6d4 100644
--- a/test/integration/targets/ansible-test-units/ansible_collections/ns/col/plugins/modules/hello.py
+++ b/test/integration/targets/ansible-test-units/ansible_collections/ns/col/plugins/modules/hello.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
module: hello
diff --git a/test/integration/targets/ansible-test-units/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_my_util.py b/test/integration/targets/ansible-test-units/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_my_util.py
index 7df8710..84a49ac 100644
--- a/test/integration/targets/ansible-test-units/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_my_util.py
+++ b/test/integration/targets/ansible-test-units/ansible_collections/ns/col/tests/unit/plugins/module_utils/test_my_util.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from .....plugins.module_utils.my_util import hello
diff --git a/test/integration/targets/ansible-test-units/ansible_collections/ns/col/tests/unit/plugins/modules/test_hello.py b/test/integration/targets/ansible-test-units/ansible_collections/ns/col/tests/unit/plugins/modules/test_hello.py
index 95ee057..46c9de1 100644
--- a/test/integration/targets/ansible-test-units/ansible_collections/ns/col/tests/unit/plugins/modules/test_hello.py
+++ b/test/integration/targets/ansible-test-units/ansible_collections/ns/col/tests/unit/plugins/modules/test_hello.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from .....plugins.modules.hello import say_hello
diff --git a/test/integration/targets/ansible-test/venv-pythons.py b/test/integration/targets/ansible-test/venv-pythons.py
index 97998bc..a22ff28 100755
--- a/test/integration/targets/ansible-test/venv-pythons.py
+++ b/test/integration/targets/ansible-test/venv-pythons.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Return target Python options for use with ansible-test."""
+from __future__ import annotations
import argparse
import os
diff --git a/test/integration/targets/ansible-vault/faux-editor.py b/test/integration/targets/ansible-vault/faux-editor.py
index b67c747..fdf01eb 100755
--- a/test/integration/targets/ansible-vault/faux-editor.py
+++ b/test/integration/targets/ansible-vault/faux-editor.py
@@ -16,8 +16,7 @@
# ansible-vault is a script that encrypts/decrypts YAML files. See
# https://docs.ansible.com/ansible/latest/user_guide/vault.html for more details.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import sys
import time
diff --git a/test/integration/targets/ansible-vault/password-script.py b/test/integration/targets/ansible-vault/password-script.py
index 1b7f02b..a65b01d 100755
--- a/test/integration/targets/ansible-vault/password-script.py
+++ b/test/integration/targets/ansible-vault/password-script.py
@@ -16,8 +16,7 @@
# ansible-vault is a script that encrypts/decrypts YAML files. See
# https://docs.ansible.com/ansible/latest/user_guide/vault.html for more details.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import sys
diff --git a/test/integration/targets/ansible-vault/runme.sh b/test/integration/targets/ansible-vault/runme.sh
index 98399ec..3630dd5 100755
--- a/test/integration/targets/ansible-vault/runme.sh
+++ b/test/integration/targets/ansible-vault/runme.sh
@@ -603,6 +603,6 @@ ansible-vault encrypt salted_test3 --vault-password-file example1_password "$@"
out=$(diff salted_test1 salted_test2)
[ "${out}" == "" ]
-# shoudl be diff
+# should be diff
out=$(diff salted_test1 salted_test3 || true)
[ "${out}" != "" ]
diff --git a/test/integration/targets/ansible-vault/script/vault-secret.sh b/test/integration/targets/ansible-vault/script/vault-secret.sh
index 3aa1c2e..7d29998 100755
--- a/test/integration/targets/ansible-vault/script/vault-secret.sh
+++ b/test/integration/targets/ansible-vault/script/vault-secret.sh
@@ -2,17 +2,14 @@
set -eu
-# shellcheck disable=SC2086
-basename="$(basename $0)"
-# shellcheck disable=SC2046
-# shellcheck disable=SC2086
-dirname="$(basename $(dirname $0))"
+basename="$(basename "$0")"
+dirname="$(basename "$(dirname "$0")")"
basename_prefix="get-password"
default_password="foo-bar"
case "${basename}" in
"${basename_prefix}"-*)
- password="${default_password}-${basename#${basename_prefix}-}"
+ password="${default_password}-${basename#"${basename_prefix}-"}"
;;
*)
password="${default_password}"
diff --git a/test/integration/targets/ansible-vault/symlink/get-password-symlink b/test/integration/targets/ansible-vault/symlink/get-password-symlink
index 3aa1c2e..7d29998 100755
--- a/test/integration/targets/ansible-vault/symlink/get-password-symlink
+++ b/test/integration/targets/ansible-vault/symlink/get-password-symlink
@@ -2,17 +2,14 @@
set -eu
-# shellcheck disable=SC2086
-basename="$(basename $0)"
-# shellcheck disable=SC2046
-# shellcheck disable=SC2086
-dirname="$(basename $(dirname $0))"
+basename="$(basename "$0")"
+dirname="$(basename "$(dirname "$0")")"
basename_prefix="get-password"
default_password="foo-bar"
case "${basename}" in
"${basename_prefix}"-*)
- password="${default_password}-${basename#${basename_prefix}-}"
+ password="${default_password}-${basename#"${basename_prefix}-"}"
;;
*)
password="${default_password}"
diff --git a/test/integration/targets/ansible-vault/test-vault-client.py b/test/integration/targets/ansible-vault/test-vault-client.py
index ee46188..c16e309 100755
--- a/test/integration/targets/ansible-vault/test-vault-client.py
+++ b/test/integration/targets/ansible-vault/test-vault-client.py
@@ -1,8 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'status': ['preview'],
'supported_by': 'community',
diff --git a/test/integration/targets/ansible/callback_plugins/callback_meta.py b/test/integration/targets/ansible/callback_plugins/callback_meta.py
index e19c80f..2494b14 100644
--- a/test/integration/targets/ansible/callback_plugins/callback_meta.py
+++ b/test/integration/targets/ansible/callback_plugins/callback_meta.py
@@ -1,8 +1,7 @@
# (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.callback import CallbackBase
import os
diff --git a/test/integration/targets/ansible_log/aliases b/test/integration/targets/ansible_log/aliases
new file mode 100644
index 0000000..498fedd
--- /dev/null
+++ b/test/integration/targets/ansible_log/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group4
+context/controller
diff --git a/test/integration/targets/ansible_log/logit.yml b/test/integration/targets/ansible_log/logit.yml
new file mode 100644
index 0000000..8015726
--- /dev/null
+++ b/test/integration/targets/ansible_log/logit.yml
@@ -0,0 +1,4 @@
+- hosts: localhost
+ gather_facts: false
+ tasks:
+ - ping:
diff --git a/test/integration/targets/ansible_log/runme.sh b/test/integration/targets/ansible_log/runme.sh
new file mode 100755
index 0000000..5295146
--- /dev/null
+++ b/test/integration/targets/ansible_log/runme.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+set -eux
+
+ALOG=${OUTPUT_DIR}/ansible_log_test.log
+
+ansible-playbook logit.yml
+[ ! -f "${ALOG}" ]
+
+ANSIBLE_LOG_PATH=${ALOG} ansible-playbook logit.yml
+[ -f "${ALOG}" ]
+grep -q 'ping' "${ALOG}"
+
+rm "${ALOG}"
+# inline grep should fail if EXEC was present
+set +e
+ANSIBLE_LOG_PATH=${ALOG} ANSIBLE_LOG_VERBOSITY=3 ansible-playbook -v logit.yml | tee /dev/stderr | grep -q EXEC
+rc=$?
+set -e
+if [ "$rc" == "0" ]; then
+ false # fail if we found EXEC in stdout
+fi
+grep -q EXEC "${ALOG}"
+
+# Test that setting verbosity with no log won't crash
+ANSIBLE_LOG_VERBOSITY=2 ansible-playbook logit.yml
diff --git a/test/integration/targets/any_errors_fatal/31543.yml b/test/integration/targets/any_errors_fatal/31543.yml
new file mode 100644
index 0000000..19b0ba8
--- /dev/null
+++ b/test/integration/targets/any_errors_fatal/31543.yml
@@ -0,0 +1,12 @@
+- hosts: testhost,testhost2
+ gather_facts: false
+ any_errors_fatal: true
+ tasks:
+ - block:
+ - fail:
+ when: inventory_hostname == 'testhost'
+ always:
+ - debug:
+
+ - debug:
+ msg: SHOULD NOT HAPPEN
diff --git a/test/integration/targets/any_errors_fatal/36308.yml b/test/integration/targets/any_errors_fatal/36308.yml
new file mode 100644
index 0000000..ec5d1ae
--- /dev/null
+++ b/test/integration/targets/any_errors_fatal/36308.yml
@@ -0,0 +1,14 @@
+- hosts: testhost
+ gather_facts: false
+ any_errors_fatal: true
+ force_handlers: true
+ tasks:
+ - command: echo
+ notify:
+ - handler1
+
+ - fail:
+ handlers:
+ - name: handler1
+ debug:
+ msg: handler1 ran
diff --git a/test/integration/targets/any_errors_fatal/73246.yml b/test/integration/targets/any_errors_fatal/73246.yml
new file mode 100644
index 0000000..50f20d9
--- /dev/null
+++ b/test/integration/targets/any_errors_fatal/73246.yml
@@ -0,0 +1,11 @@
+- hosts: testhost
+ gather_facts: false
+ any_errors_fatal: true
+ tasks:
+ - block:
+ - block:
+ - fail:
+ always:
+ - block:
+ - debug:
+ msg: PASSED
diff --git a/test/integration/targets/any_errors_fatal/80981.yml b/test/integration/targets/any_errors_fatal/80981.yml
new file mode 100644
index 0000000..51cf8df
--- /dev/null
+++ b/test/integration/targets/any_errors_fatal/80981.yml
@@ -0,0 +1,17 @@
+- hosts: testhost,testhost2
+ gather_facts: false
+ any_errors_fatal: true
+ tasks:
+ - block:
+ - fail:
+ when: inventory_hostname == "testhost"
+ - name: any_errors_fatal fails all hosts when any of them fails
+ debug:
+ msg: SHOULD NOT HAPPEN
+ rescue:
+ - name: Rescues both hosts
+ debug:
+ msg: rescue
+ - name: You can recover from fatal errors by adding a rescue section to the block.
+ debug:
+ msg: recovered
diff --git a/test/integration/targets/any_errors_fatal/runme.sh b/test/integration/targets/any_errors_fatal/runme.sh
index c54ea8d..58f0ddf 100755
--- a/test/integration/targets/any_errors_fatal/runme.sh
+++ b/test/integration/targets/any_errors_fatal/runme.sh
@@ -35,3 +35,17 @@ for test_name in test_include_role test_include_tasks; do
exit 1
fi
done
+
+ansible-playbook -i inventory "$@" 31543.yml | tee out.txt
+[ "$(grep -c 'SHOULD NOT HAPPEN' out.txt)" -eq 0 ]
+
+ansible-playbook -i inventory "$@" 36308.yml | tee out.txt
+[ "$(grep -c 'handler1 ran' out.txt)" -eq 1 ]
+
+ansible-playbook -i inventory "$@" 73246.yml | tee out.txt
+[ "$(grep -c 'PASSED' out.txt)" -eq 1 ]
+
+ansible-playbook -i inventory "$@" 80981.yml | tee out.txt
+[ "$(grep -c 'SHOULD NOT HAPPEN' out.txt)" -eq 0 ]
+[ "$(grep -c 'rescue' out.txt)" -eq 2 ]
+[ "$(grep -c 'recovered' out.txt)" -eq 2 ]
diff --git a/test/integration/targets/apt/tasks/apt.yml b/test/integration/targets/apt/tasks/apt.yml
index a0bc199..55ab51d 100644
--- a/test/integration/targets/apt/tasks/apt.yml
+++ b/test/integration/targets/apt/tasks/apt.yml
@@ -594,3 +594,26 @@
- elpa-yaml-mode
state: absent
purge: yes
+
+# https://github.com/ansible/ansible/issues/82611
+- name: clean apt cache
+ apt:
+ clean: true
+
+- name: check for /var/cache/apt/pkgcache.bin
+ stat:
+ path: /var/cache/apt/pkgcache.bin
+ register: pkgcache_bin
+
+- name: check for /var/cache/apt/srcpkgcache.bin
+ stat:
+ path: /var/cache/apt/srcpkgcache.bin
+ register: srcpkgcache_bin
+
+- name: verify apt cache files are cleaned
+ assert:
+ that:
+ - not pkgcache_bin.stat.exists
+ - not srcpkgcache_bin.stat.exists
+ fail_msg: "apt cache files still exist."
+ success_msg: "apt cache files are cleaned."
diff --git a/test/integration/targets/apt/tasks/url-with-deps.yml b/test/integration/targets/apt/tasks/url-with-deps.yml
index 7c70eb9..7e628c9 100644
--- a/test/integration/targets/apt/tasks/url-with-deps.yml
+++ b/test/integration/targets/apt/tasks/url-with-deps.yml
@@ -48,9 +48,37 @@
- dpkg_result is successful
- dpkg_result.rc == 0
+ - name: Install package from local repo
+ apt:
+ deb: "{{ repodir }}/dists/stable/main/binary-all/baz_1.0.0_all.deb"
+ install_recommends: yes
+ register: apt_url_deps
+
+ - name: check to make sure we installed the package
+ shell: dpkg -l | grep baz
+ failed_when: False
+ register: baz_dpkg_result
+
+ - name: check to make sure we installed the package's recommends
+ shell: dpkg -l | grep rolldice
+ failed_when: False
+ register: rolldice_dpkg_result
+
+ - name: verify real installation of bar
+ assert:
+ that:
+ - apt_url_deps is changed
+ - baz_dpkg_result is successful
+ - baz_dpkg_result.rc == 0
+ - rolldice_dpkg_result is successful
+ - rolldice_dpkg_result.rc == 0
+
always:
- - name: uninstall echo-hello with apt
+ - name: uninstall packages with apt
apt:
- pkg: echo-hello
+ pkg:
+ - echo-hello
+ - rolldice
+ - baz
state: absent
purge: yes
diff --git a/test/integration/targets/apt_repository/tasks/apt.yml b/test/integration/targets/apt_repository/tasks/apt.yml
index 2ddf414..d3175f4 100644
--- a/test/integration/targets/apt_repository/tasks/apt.yml
+++ b/test/integration/targets/apt_repository/tasks/apt.yml
@@ -3,21 +3,15 @@
- set_fact:
test_ppa_name: 'ppa:git-core/ppa'
test_ppa_filename: 'git-core'
- test_ppa_spec: 'deb http://ppa.launchpad.net/git-core/ppa/ubuntu {{ansible_distribution_release}} main'
+ test_ppa_spec: 'deb https://ppa.launchpadcontent.net/git-core/ppa/ubuntu {{ansible_distribution_release}} main'
test_ppa_key: 'E1DF1F24' # http://keyserver.ubuntu.com:11371/pks/lookup?search=0xD06AAF4C11DAB86DF421421EFE6B20ECA7AD98A1&op=index
- name: show python version
debug: var=ansible_python_version
-- name: use python-apt
- set_fact:
- python_apt: python-apt
- when: ansible_python_version is version('3', '<')
-
- name: use python3-apt
set_fact:
python_apt: python3-apt
- when: ansible_python_version is version('3', '>=')
# UNINSTALL 'python-apt'
# The `apt_repository` module has the smarts to auto-install `python-apt`. To
@@ -254,6 +248,87 @@
- result.msg == 'Please set argument \'repo\' to a non-empty value'
#
+# TEST: keep symlink
+#
+- import_tasks: 'cleanup.yml'
+
+- name: install local-apt-repository with apt
+ apt: pkg=local-apt-repository state=present
+
+- name: Check if local apt repo file is a symlink
+ stat:
+ path: /etc/apt/sources.list.d/local-apt-repository.list
+ register: stat_result
+
+- name: Assert if local apt repo file is a symlink
+ assert:
+ that:
+ - stat_result.stat.islnk is defined and stat_result.stat.islnk
+ - stat_result.stat.lnk_source == "/usr/lib/local-apt-repository/local-apt-repository.list"
+
+- name: Try installing an invalid repo
+ apt_repository:
+ repo: deb http://dl.google.com/linux/chrome/deb2/ stable main
+ state: present
+ filename: google-chrome
+ ignore_errors: true
+
+- name: Check the stat for the given symlink
+ stat:
+ path: /etc/apt/sources.list.d/local-apt-repository.list
+ register: stat_result2
+
+- name: Assert that the symlink is intact after apt_repository operation
+ assert:
+ that:
+ - stat_result2.stat.islnk is defined and stat_result2.stat.islnk
+ - stat_result2.stat.lnk_source == "/usr/lib/local-apt-repository/local-apt-repository.list"
+
+- name: uninstall local-apt-repository with apt
+ apt: pkg=local-apt-repository state=absent purge=yes
+
+#
+# TEST: PPA HTTPS URL
+#
+- name: Add PPA using HTTPS URL
+ apt_repository:
+ repo: 'ppa:deadsnakes'
+ filename: 'deadsnakes'
+ state: present
+ register: result
+
+- name: Check if PPA using HTTPS URL is added
+ assert:
+ that:
+ - 'result.changed'
+ - 'result.state == "present"'
+ - 'result.repo == "ppa:deadsnakes"'
+
+- name: 'examine source file'
+ stat:
+ path: '/etc/apt/sources.list.d/deadsnakes.list'
+ register: source_file
+
+- name: 'assert source file exists'
+ assert:
+ that:
+ - 'source_file.stat.exists == True'
+
+- name: Check if the PPA URL
+ shell: "grep 'https://ppa.launchpadcontent.net' /etc/apt/sources.list.d/deadsnakes.list"
+ register: r
+
+- name: Test if PPA URL points to https URL
+ assert:
+ that:
+ - r.changed
+ - "'https://ppa.launchpadcontent.net' in r.stdout"
+
+- name: Remove PPA file
+ file:
+ path: '/etc/apt/sources.list.d/deadsnakes.list'
+ state: absent
+#
# TEARDOWN
#
- import_tasks: 'cleanup.yml'
diff --git a/test/integration/targets/argspec/library/argspec.py b/test/integration/targets/argspec/library/argspec.py
index 2d86d77..6db16d7 100644
--- a/test/integration/targets/argspec/library/argspec.py
+++ b/test/integration/targets/argspec/library/argspec.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2020, Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/assemble/tasks/main.yml b/test/integration/targets/assemble/tasks/main.yml
index 14eea3f..add95f9 100644
--- a/test/integration/targets/assemble/tasks/main.yml
+++ b/test/integration/targets/assemble/tasks/main.yml
@@ -152,3 +152,19 @@
that:
- "result.state == 'file'"
- "result.checksum == '505359f48c65b3904127cf62b912991d4da7ed6d'"
+
+- name: test assemble with diff
+ assemble:
+ src: "./"
+ dest: "{{remote_tmp_dir}}/assembled11"
+ remote_src: false
+ diff: true
+ register: result
+
+- name: assert the fragments were assembled with diff
+ assert:
+ that:
+ - result.changed
+ - result.diff.after is defined
+ - result.diff.before is defined
+ - "result.state == 'file'"
diff --git a/test/integration/targets/async/library/async_test.py b/test/integration/targets/async/library/async_test.py
index f89bd10..3905679 100644
--- a/test/integration/targets/async/library/async_test.py
+++ b/test/integration/targets/async/library/async_test.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import sys
diff --git a/test/integration/targets/async/tasks/main.yml b/test/integration/targets/async/tasks/main.yml
index 491be96..6518207 100644
--- a/test/integration/targets/async/tasks/main.yml
+++ b/test/integration/targets/async/tasks/main.yml
@@ -310,3 +310,30 @@
- assert:
that:
- '"ASYNC OK on localhost" in check_task_disabled_output.stdout'
+
+- name: test 'hidden' async, gather_facts does internal on parallel true. Ensure it won't freeze in check_mode due to async_status not supporting it.
+ gather_facts:
+ parallel: true
+ timeout: 60
+ check_mode: true
+ when: "ansible_facts['os_family'] != 'Darwin'"
+ vars:
+ ansible_facts_modules:
+ - setup
+ - package_facts
+ - service_facts
+
+- name: test async in check mode
+ check_mode: true
+ block:
+ - setup:
+ async: 60
+ poll: 0
+ register: gf_async
+ - async_status:
+ jid: "{{ gf_async['ansible_job_id'] }}"
+ register: gf_done
+ until: gf_done is finished
+ retries: 100
+ delay: 10
+ timeout: 30
diff --git a/test/integration/targets/async_extra_data/library/junkping.py b/test/integration/targets/async_extra_data/library/junkping.py
index b61d965..6ad3c11 100644
--- a/test/integration/targets/async_extra_data/library/junkping.py
+++ b/test/integration/targets/async_extra_data/library/junkping.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/async_fail/action_plugins/normal.py b/test/integration/targets/async_fail/action_plugins/normal.py
index 297cbd9..a288290 100644
--- a/test/integration/targets/async_fail/action_plugins/normal.py
+++ b/test/integration/targets/async_fail/action_plugins/normal.py
@@ -14,8 +14,7 @@
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.errors import AnsibleError
from ansible.plugins.action import ActionBase
diff --git a/test/integration/targets/async_fail/library/async_test.py b/test/integration/targets/async_fail/library/async_test.py
index e0cbd6f..e94a6a5 100644
--- a/test/integration/targets/async_fail/library/async_test.py
+++ b/test/integration/targets/async_fail/library/async_test.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import sys
diff --git a/test/integration/targets/become/aliases b/test/integration/targets/become/aliases
index 0c490f1..2d93d9a 100644
--- a/test/integration/targets/become/aliases
+++ b/test/integration/targets/become/aliases
@@ -2,3 +2,4 @@ destructive
shippable/posix/group1
context/target
gather_facts/no
+setup/always/setup_passlib_controller # required for setup_test_user
diff --git a/test/integration/targets/become_unprivileged/action_plugins/tmpdir.py b/test/integration/targets/become_unprivileged/action_plugins/tmpdir.py
index b7cbb7a..8985961 100644
--- a/test/integration/targets/become_unprivileged/action_plugins/tmpdir.py
+++ b/test/integration/targets/become_unprivileged/action_plugins/tmpdir.py
@@ -1,6 +1,4 @@
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
diff --git a/test/integration/targets/builtin_vars_prompt/test-vars_prompt.py b/test/integration/targets/builtin_vars_prompt/test-vars_prompt.py
index 93958fc..435a7eb 100644
--- a/test/integration/targets/builtin_vars_prompt/test-vars_prompt.py
+++ b/test/integration/targets/builtin_vars_prompt/test-vars_prompt.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import pexpect
diff --git a/test/integration/targets/callback_default/callback_default.out.include_role_fails.stderr b/test/integration/targets/callback_default/callback_default.out.include_role_fails.stderr
new file mode 100644
index 0000000..315f17b
--- /dev/null
+++ b/test/integration/targets/callback_default/callback_default.out.include_role_fails.stderr
@@ -0,0 +1,12 @@
++ ansible-playbook -i inventory test_include_role_fails.yml
+++ set +x
+ERROR! the role 'does-not-exist' was not found in TEST_PATH/roles:/root/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:TEST_PATH
+
+The error appears to be in 'TEST_PATH/test_include_role_fails.yml': line 5, column 15, but may
+be elsewhere in the file depending on the exact syntax problem.
+
+The offending line appears to be:
+
+ - include_role:
+ name: does-not-exist
+ ^ here
diff --git a/test/integration/targets/callback_default/callback_default.out.include_role_fails.stdout b/test/integration/targets/callback_default/callback_default.out.include_role_fails.stdout
new file mode 100644
index 0000000..adfd21b
--- /dev/null
+++ b/test/integration/targets/callback_default/callback_default.out.include_role_fails.stdout
@@ -0,0 +1,9 @@
+
+PLAY [testhost] ****************************************************************
+
+TASK [include_role : does-not-exist] *******************************************
+fatal: [testhost]: FAILED! => {"changed": false, "reason": "the role 'does-not-exist' was not found in TEST_PATH/roles:/root/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:TEST_PATH\n\nThe error appears to be in 'TEST_PATH/test_include_role_fails.yml': line 5, column 15, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n - include_role:\n name: does-not-exist\n ^ here\n"}
+
+PLAY RECAP *********************************************************************
+testhost : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
+
diff --git a/test/integration/targets/callback_default/callback_default.out.result_format_yaml_lossy_verbose.stdout b/test/integration/targets/callback_default/callback_default.out.result_format_yaml_lossy_verbose.stdout
index ed45575..51f0251 100644
--- a/test/integration/targets/callback_default/callback_default.out.result_format_yaml_lossy_verbose.stdout
+++ b/test/integration/targets/callback_default/callback_default.out.result_format_yaml_lossy_verbose.stdout
@@ -166,7 +166,7 @@ changed: [testhost] =>
mode: '0644'
owner: root
size: 3
- src: .../source
+ src: .../.source.txt
state: file
uid: 0
diff --git a/test/integration/targets/callback_default/callback_default.out.result_format_yaml_verbose.stdout b/test/integration/targets/callback_default/callback_default.out.result_format_yaml_verbose.stdout
index 3a121a5..8fd5b4f 100644
--- a/test/integration/targets/callback_default/callback_default.out.result_format_yaml_verbose.stdout
+++ b/test/integration/targets/callback_default/callback_default.out.result_format_yaml_verbose.stdout
@@ -173,7 +173,7 @@ changed: [testhost] =>
mode: '0644'
owner: root
size: 3
- src: .../source
+ src: .../.source.txt
state: file
uid: 0
diff --git a/test/integration/targets/callback_default/runme.sh b/test/integration/targets/callback_default/runme.sh
index a815132..4dab4f4 100755
--- a/test/integration/targets/callback_default/runme.sh
+++ b/test/integration/targets/callback_default/runme.sh
@@ -25,16 +25,15 @@ run_test() {
{ ansible-playbook -i inventory "$playbook" "${@:3}" \
> >(set +x; tee "${OUTFILE}.${testname}.stdout"); } \
2> >(set +x; tee "${OUTFILE}.${testname}.stderr" >&2)
- # Scrub deprication warning that shows up in Python 2.6 on CentOS 6
- sed -i -e '/RandomPool_DeprecationWarning/d' "${OUTFILE}.${testname}.stderr"
sed -i -e 's/included: .*\/test\/integration/included: ...\/test\/integration/g' "${OUTFILE}.${testname}.stdout"
sed -i -e 's/@@ -1,1 +1,1 @@/@@ -1 +1 @@/g' "${OUTFILE}.${testname}.stdout"
sed -i -e 's/: .*\/test_diff\.txt/: ...\/test_diff.txt/g' "${OUTFILE}.${testname}.stdout"
- sed -i -e "s#${ANSIBLE_PLAYBOOK_DIR}#TEST_PATH#g" "${OUTFILE}.${testname}.stdout"
+ sed -i -e "s#${ANSIBLE_PLAYBOOK_DIR}#TEST_PATH#g" "${OUTFILE}.${testname}.stdout" "${OUTFILE}.${testname}.stderr"
+ sed -i -e "s#/var/root/#/root/#g" "${OUTFILE}.${testname}.stdout" "${OUTFILE}.${testname}.stderr" # macos
sed -i -e 's/^Using .*//g' "${OUTFILE}.${testname}.stdout"
sed -i -e 's/[0-9]:[0-9]\{2\}:[0-9]\{2\}\.[0-9]\{6\}/0:00:00.000000/g' "${OUTFILE}.${testname}.stdout"
sed -i -e 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\} [0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}\.[0-9]\{6\}/0000-00-00 00:00:00.000000/g' "${OUTFILE}.${testname}.stdout"
- sed -i -e 's#: .*/source$#: .../source#g' "${OUTFILE}.${testname}.stdout"
+ sed -i -e 's#: .*/\.source\.txt$#: .../.source.txt#g' "${OUTFILE}.${testname}.stdout"
sed -i -e '/secontext:/d' "${OUTFILE}.${testname}.stdout"
sed -i -e 's/group: wheel/group: root/g' "${OUTFILE}.${testname}.stdout"
@@ -47,7 +46,7 @@ run_test_dryrun() {
# optional, pass --check to run a dry run
local chk=${2:-}
- # outout was recorded w/o cowsay, ensure we reproduce the same
+ # output was recorded w/o cowsay, ensure we reproduce the same
export ANSIBLE_NOCOWS=1
# This needed to satisfy shellcheck that can not accept unquoted variable
@@ -58,8 +57,6 @@ run_test_dryrun() {
{ $cmd \
> >(set +x; tee "${OUTFILE}.${testname}.stdout"); } \
2> >(set +x; tee "${OUTFILE}.${testname}.stderr" >&2)
- # Scrub deprication warning that shows up in Python 2.6 on CentOS 6
- sed -i -e '/RandomPool_DeprecationWarning/d' "${OUTFILE}.${testname}.stderr"
diff -u "${ORIGFILE}.${testname}.stdout" "${OUTFILE}.${testname}.stdout" || diff_failure
diff -u "${ORIGFILE}.${testname}.stderr" "${OUTFILE}.${testname}.stderr" || diff_failure
@@ -132,6 +129,10 @@ export ANSIBLE_CHECK_MODE_MARKERS=0
run_test default test.yml
+set +e
+ANSIBLE_CALLBACKS_ENABLED=default run_test include_role_fails test_include_role_fails.yml
+set -e
+
# Check for async output
# NOTE: regex to match 1 or more digits works for both BSD and GNU grep
ansible-playbook -i inventory test_async.yml 2>&1 | tee async_test.out
@@ -177,7 +178,7 @@ export ANSIBLE_DISPLAY_OK_HOSTS=1
export ANSIBLE_DISPLAY_FAILED_STDERR=1
export ANSIBLE_TIMEOUT=1
-# Check if UNREACHBLE is available in stderr
+# Check if UNREACHABLE is available in stderr
set +e
ansible-playbook -i inventory test_2.yml > >(set +x; tee "${BASEFILE}.unreachable.stdout";) 2> >(set +x; tee "${BASEFILE}.unreachable.stderr" >&2) || true
set -e
diff --git a/test/integration/targets/callback_default/test_include_role_fails.yml b/test/integration/targets/callback_default/test_include_role_fails.yml
new file mode 100644
index 0000000..3749c90
--- /dev/null
+++ b/test/integration/targets/callback_default/test_include_role_fails.yml
@@ -0,0 +1,5 @@
+- hosts: testhost
+ gather_facts: false
+ tasks:
+ - include_role:
+ name: does-not-exist
diff --git a/test/integration/targets/cli/test-cli.py b/test/integration/targets/cli/test-cli.py
index 9893d66..8d961ff 100644
--- a/test/integration/targets/cli/test-cli.py
+++ b/test/integration/targets/cli/test-cli.py
@@ -2,9 +2,7 @@
# Copyright (c) 2019 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
diff --git a/test/integration/targets/cli/test_k_and_K.py b/test/integration/targets/cli/test_k_and_K.py
index f7077fb..fe9575c 100644
--- a/test/integration/targets/cli/test_k_and_K.py
+++ b/test/integration/targets/cli/test_k_and_K.py
@@ -1,9 +1,7 @@
#!/usr/bin/env python
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import sys
diff --git a/test/integration/targets/collection/update-ignore.py b/test/integration/targets/collection/update-ignore.py
index 92a702c..fb363f1 100755
--- a/test/integration/targets/collection/update-ignore.py
+++ b/test/integration/targets/collection/update-ignore.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Rewrite a sanity ignore file to expand Python versions for import ignores and write the file out with the correct Ansible version in the name."""
+from __future__ import annotations
import os
import sys
diff --git a/test/integration/targets/collections/ansiballz_dupe/collections/ansible_collections/duplicate/name/plugins/modules/ping.py b/test/integration/targets/collections/ansiballz_dupe/collections/ansible_collections/duplicate/name/plugins/modules/ping.py
index d0fdba7..1167149 100644
--- a/test/integration/targets/collections/ansiballz_dupe/collections/ansible_collections/duplicate/name/plugins/modules/ping.py
+++ b/test/integration/targets/collections/ansiballz_dupe/collections/ansible_collections/duplicate/name/plugins/modules/ping.py
@@ -1,3 +1,5 @@
#!/usr/bin/python
+from __future__ import annotations
+
from ansible.module_utils.basic import AnsibleModule
AnsibleModule({}).exit_json(ping='duplicate.name.pong')
diff --git a/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/coll_in_sys/plugins/modules/systestmodule.py b/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/coll_in_sys/plugins/modules/systestmodule.py
index cba3812..eb05be2 100644
--- a/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/coll_in_sys/plugins/modules/systestmodule.py
+++ b/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/coll_in_sys/plugins/modules/systestmodule.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/testcoll/plugins/modules/maskedmodule.py b/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/testcoll/plugins/modules/maskedmodule.py
index e3db81b..9694c59 100644
--- a/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/testcoll/plugins/modules/maskedmodule.py
+++ b/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/testcoll/plugins/modules/maskedmodule.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/testcoll/plugins/modules/testmodule.py b/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/testcoll/plugins/modules/testmodule.py
index cba3812..eb05be2 100644
--- a/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/testcoll/plugins/modules/testmodule.py
+++ b/test/integration/targets/collections/collection_root_sys/ansible_collections/testns/testcoll/plugins/modules/testmodule.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/ansible/builtin/plugins/modules/ping.py b/test/integration/targets/collections/collection_root_user/ansible_collections/ansible/builtin/plugins/modules/ping.py
index 0747670..a6ff449 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/ansible/builtin/plugins/modules/ping.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/ansible/builtin/plugins/modules/ping.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/ansible/bullcoll/plugins/modules/bullmodule.py b/test/integration/targets/collections/collection_root_user/ansible_collections/ansible/bullcoll/plugins/modules/bullmodule.py
index 5ea354e..b190930 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/ansible/bullcoll/plugins/modules/bullmodule.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/ansible/bullcoll/plugins/modules/bullmodule.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testbroken/plugins/filter/broken_filter.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testbroken/plugins/filter/broken_filter.py
index 51fe852..9ffb201 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testbroken/plugins/filter/broken_filter.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testbroken/plugins/filter/broken_filter.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class FilterModule(object):
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/playbooks/roles/non_coll_role/library/embedded_module.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/playbooks/roles/non_coll_role/library/embedded_module.py
index 54402d1..76c1f52 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/playbooks/roles/non_coll_role/library/embedded_module.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/playbooks/roles/non_coll_role/library/embedded_module.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/action_subdir/subdir_ping_action.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/action_subdir/subdir_ping_action.py
index 5af7334..2d108e2 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/action_subdir/subdir_ping_action.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/action_subdir/subdir_ping_action.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/bypass_host_loop.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/bypass_host_loop.py
index b15493d..2625e1c 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/bypass_host_loop.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/bypass_host_loop.py
@@ -1,8 +1,7 @@
# Copyright: (c) 2020, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/plugin_lookup.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/plugin_lookup.py
index 3fa41e8..950e04c 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/plugin_lookup.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/plugin_lookup.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
from ansible.plugins import loader
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/subclassed_normal.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/subclassed_normal.py
index f0eff30..a35a0b7 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/subclassed_normal.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/subclassed_normal.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action.normal import ActionModule as NormalAction
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/uses_redirected_import.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/uses_redirected_import.py
index 701d7b4..4c36ab4 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/uses_redirected_import.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/action/uses_redirected_import.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
from ansible.module_utils.formerly_core import thingtocall
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/callback/usercallback.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/callback/usercallback.py
index b534df2..3eb9764 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/callback/usercallback.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/callback/usercallback.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.callback import CallbackBase
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/connection/localconn.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/connection/localconn.py
index 77f8050..2872005 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/connection/localconn.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/connection/localconn.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.common.text.converters import to_native
from ansible.plugins.connection import ConnectionBase
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/doc_fragments/frag.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/doc_fragments/frag.py
index 4549f2d..8fbcb36 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/doc_fragments/frag.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/doc_fragments/frag.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class ModuleDocFragment(object):
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/filter_subdir/my_subdir_filters.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/filter_subdir/my_subdir_filters.py
index a5498a4..c8e4f84 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/filter_subdir/my_subdir_filters.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/filter_subdir/my_subdir_filters.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def test_subdir_filter(data):
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/myfilters.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/myfilters.py
index 0ce239e..ea56506 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/myfilters.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/myfilters.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def testfilter(data):
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/myfilters2.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/myfilters2.py
index 0723922..29e22d3 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/myfilters2.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/filter/myfilters2.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def testfilter2(data):
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/lookup_subdir/my_subdir_lookup.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/lookup_subdir/my_subdir_lookup.py
index dd9818c..f6d6575 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/lookup_subdir/my_subdir_lookup.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/lookup_subdir/my_subdir_lookup.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.lookup import LookupBase
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/mylookup.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/mylookup.py
index 1cf3d28..a843850 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/mylookup.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/mylookup.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.lookup import LookupBase
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/mylookup2.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/mylookup2.py
index bda671f..2ca2de3 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/mylookup2.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/lookup/mylookup2.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.lookup import LookupBase
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/base.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/base.py
index 0654d18..778c2be 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/base.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/base.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible_collections.testns.testcoll.plugins.module_utils import secondary
import ansible_collections.testns.testcoll.plugins.module_utils.secondary
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/leaf.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/leaf.py
index ad84710..8ccc89a 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/leaf.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/leaf.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def thingtocall():
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/nested_same/nested_same/nested_same.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/nested_same/nested_same/nested_same.py
index 7740756..aeb55ab 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/nested_same/nested_same/nested_same.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/nested_same/nested_same/nested_same.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def nested_same():
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/secondary.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/secondary.py
index 9a31568..a7d7c5e 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/secondary.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/secondary.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def thingtocall():
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg/submod.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg/submod.py
index 3c24bc4..dbf27a8 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg/submod.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg/submod.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def thingtocall():
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init.py
index b48a717..8bcb936 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init.py
@@ -1,6 +1,5 @@
# NB: this module should never be loaded, since we'll see the subpkg_with_init package dir first
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def thingtocall():
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init/__init__.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init/__init__.py
index d424796..665c96a 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init/__init__.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init/__init__.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
# exercise relative imports in package init; they behave differently
from .mod_in_subpkg_with_init import thingtocall as submod_thingtocall
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init/mod_in_subpkg_with_init.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init/mod_in_subpkg_with_init.py
index 27747da..8fab672 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init/mod_in_subpkg_with_init.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/module_utils/subpkg_with_init/mod_in_subpkg_with_init.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def thingtocall():
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/deprecated_ping.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/deprecated_ping.py
index 9698ba6..0dd956a 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/deprecated_ping.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/deprecated_ping.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/module_subdir/subdir_ping_module.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/module_subdir/subdir_ping_module.py
index 5a70174..05d8d12 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/module_subdir/subdir_ping_module.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/module_subdir/subdir_ping_module.py
@@ -1,7 +1,6 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/ping.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/ping.py
index 2ca079c..fc8568e 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/ping.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/ping.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/testmodule.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/testmodule.py
index e2efada..6ec24b4 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/testmodule.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/testmodule.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/testmodule_bad_docfrags.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/testmodule_bad_docfrags.py
index 46ccb76..d39efc8 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/testmodule_bad_docfrags.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/testmodule_bad_docfrags.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_base_mu_granular_nested_import.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_base_mu_granular_nested_import.py
index 4054e36..23d214d 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_base_mu_granular_nested_import.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_base_mu_granular_nested_import.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import sys
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_collection_redirected_mu.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_collection_redirected_mu.py
index b169fde..9020036 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_collection_redirected_mu.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_collection_redirected_mu.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import sys
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_core_redirected_mu.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_core_redirected_mu.py
index 28a0772..c735dbf 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_core_redirected_mu.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_core_redirected_mu.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import sys
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_flat_import.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_flat_import.py
index 295d432..c96028a 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_flat_import.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_flat_import.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import sys
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_granular_import.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_granular_import.py
index 3794f49..1327af9 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_granular_import.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_granular_import.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import sys
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_module_import_from.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_module_import_from.py
index 559e3e5..ae4bb23 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_module_import_from.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_leaf_mu_module_import_from.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import sys
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing.py
index 6f3a19d..1d8c0c3 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ..module_utils import bogusmu # pylint: disable=relative-beyond-top-level,unused-import
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing_redirect_collection.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing_redirect_collection.py
index 6f2320d..c76e0e9 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing_redirect_collection.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing_redirect_collection.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ..module_utils import missing_redirect_target_collection # pylint: disable=relative-beyond-top-level,unused-import
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing_redirect_module.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing_redirect_module.py
index de5c2e5..e7fce3e 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing_redirect_module.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_mu_missing_redirect_module.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ..module_utils import missing_redirect_target_module # pylint: disable=relative-beyond-top-level,unused-import
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_nested_same_as_func.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_nested_same_as_func.py
index 26fa53c..f757666 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_nested_same_as_func.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_nested_same_as_func.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import sys
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_nested_same_as_module.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_nested_same_as_module.py
index e017c14..91ecfea 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_nested_same_as_module.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/uses_nested_same_as_module.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import sys
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/mytests.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/mytests.py
index ba610fb..294a215 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/mytests.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/mytests.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def testtest(data):
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/mytests2.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/mytests2.py
index 183944f..05c969d 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/mytests2.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/mytests2.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def testtest(data):
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/test_subdir/my_subdir_tests.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/test_subdir/my_subdir_tests.py
index 98a8f89..a28fb52 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/test_subdir/my_subdir_tests.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/test/test_subdir/my_subdir_tests.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def subdir_test(data):
diff --git a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/vars/custom_vars.py b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/vars/custom_vars.py
index da4e776..e1997ae 100644
--- a/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/vars/custom_vars.py
+++ b/test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/vars/custom_vars.py
@@ -15,8 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#############################################
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
vars: custom_vars
diff --git a/test/integration/targets/collections/collections/ansible_collections/me/mycoll1/plugins/action/action1.py b/test/integration/targets/collections/collections/ansible_collections/me/mycoll1/plugins/action/action1.py
index e9f9731..43f8ec3 100644
--- a/test/integration/targets/collections/collections/ansible_collections/me/mycoll1/plugins/action/action1.py
+++ b/test/integration/targets/collections/collections/ansible_collections/me/mycoll1/plugins/action/action1.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
diff --git a/test/integration/targets/collections/collections/ansible_collections/me/mycoll1/plugins/modules/action1.py b/test/integration/targets/collections/collections/ansible_collections/me/mycoll1/plugins/modules/action1.py
index 66bb5a4..03b1651 100644
--- a/test/integration/targets/collections/collections/ansible_collections/me/mycoll1/plugins/modules/action1.py
+++ b/test/integration/targets/collections/collections/ansible_collections/me/mycoll1/plugins/modules/action1.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
diff --git a/test/integration/targets/collections/collections/ansible_collections/me/mycoll2/plugins/modules/module1.py b/test/integration/targets/collections/collections/ansible_collections/me/mycoll2/plugins/modules/module1.py
index 00bb993..b0d3f6d 100644
--- a/test/integration/targets/collections/collections/ansible_collections/me/mycoll2/plugins/modules/module1.py
+++ b/test/integration/targets/collections/collections/ansible_collections/me/mycoll2/plugins/modules/module1.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
diff --git a/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/cache/custom_jsonfile.py b/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/cache/custom_jsonfile.py
index 7605dc4..393a43f 100644
--- a/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/cache/custom_jsonfile.py
+++ b/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/cache/custom_jsonfile.py
@@ -2,9 +2,7 @@
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
cache: jsonfile
diff --git a/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/inventory/statichost.py b/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/inventory/statichost.py
index 9269648..b2405e3 100644
--- a/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/inventory/statichost.py
+++ b/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/inventory/statichost.py
@@ -1,8 +1,7 @@
# Copyright (c) 2018 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
inventory: statichost
diff --git a/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/module_utils/sub1/foomodule.py b/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/module_utils/sub1/foomodule.py
index eeffe01..baf4485 100644
--- a/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/module_utils/sub1/foomodule.py
+++ b/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/module_utils/sub1/foomodule.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def importme():
diff --git a/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/modules/contentadjmodule.py b/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/modules/contentadjmodule.py
index 0fa98eb..a7f7f00 100644
--- a/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/modules/contentadjmodule.py
+++ b/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/modules/contentadjmodule.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/vars/custom_adj_vars.py b/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/vars/custom_adj_vars.py
index 0cd9a1d..b98fe7b 100644
--- a/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/vars/custom_adj_vars.py
+++ b/test/integration/targets/collections/collections/ansible_collections/testns/content_adj/plugins/vars/custom_adj_vars.py
@@ -15,8 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#############################################
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
vars: custom_adj_vars
diff --git a/test/integration/targets/collections/custom_vars_plugins/v1_vars_plugin.py b/test/integration/targets/collections/custom_vars_plugins/v1_vars_plugin.py
index b5792d8..ce79baa 100644
--- a/test/integration/targets/collections/custom_vars_plugins/v1_vars_plugin.py
+++ b/test/integration/targets/collections/custom_vars_plugins/v1_vars_plugin.py
@@ -15,15 +15,14 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#############################################
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
vars: v1_vars_plugin
version_added: "2.10"
short_description: load host and group vars
description:
- - 3rd party vars plugin to test loading host and group vars without requiring whitelisting and without a plugin-specific stage option
+ - Third-party vars plugin to test loading host and group vars without enabling and without a plugin-specific stage option
options:
'''
diff --git a/test/integration/targets/collections/custom_vars_plugins/v2_vars_plugin.py b/test/integration/targets/collections/custom_vars_plugins/v2_vars_plugin.py
index fc14016..a6894ac 100644
--- a/test/integration/targets/collections/custom_vars_plugins/v2_vars_plugin.py
+++ b/test/integration/targets/collections/custom_vars_plugins/v2_vars_plugin.py
@@ -15,15 +15,14 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#############################################
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
vars: v2_vars_plugin
version_added: "2.10"
short_description: load host and group vars
description:
- - 3rd party vars plugin to test loading host and group vars without requiring whitelisting and with a plugin-specific stage option
+ - Third party vars plugin to test loading host and group vars without enabling and with a plugin-specific stage option
options:
stage:
choices: ['all', 'inventory', 'task']
diff --git a/test/integration/targets/collections/filter_plugins/override_formerly_core_masked_filter.py b/test/integration/targets/collections/filter_plugins/override_formerly_core_masked_filter.py
index 600b1fd..228de42 100644
--- a/test/integration/targets/collections/filter_plugins/override_formerly_core_masked_filter.py
+++ b/test/integration/targets/collections/filter_plugins/override_formerly_core_masked_filter.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def override_formerly_core_masked_filter(*args, **kwargs):
diff --git a/test/integration/targets/collections/library/ping.py b/test/integration/targets/collections/library/ping.py
index 7a416a6..d770577 100644
--- a/test/integration/targets/collections/library/ping.py
+++ b/test/integration/targets/collections/library/ping.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/collections/runme.sh b/test/integration/targets/collections/runme.sh
index 5f11abe..13352aa 100755
--- a/test/integration/targets/collections/runme.sh
+++ b/test/integration/targets/collections/runme.sh
@@ -6,6 +6,7 @@ export ANSIBLE_COLLECTIONS_PATH=$PWD/collection_root_user:$PWD/collection_root_s
export ANSIBLE_GATHERING=explicit
export ANSIBLE_GATHER_SUBSET=minimal
export ANSIBLE_HOST_PATTERN_MISMATCH=error
+export NO_COLOR=1
unset ANSIBLE_COLLECTIONS_ON_ANSIBLE_VERSION_MISMATCH
# ensure we can call collection module
@@ -72,8 +73,11 @@ cat out.txt
test "$(grep out.txt -ce 'deprecation1' -ce 'deprecation2' -ce 'deprecation3')" == 3
grep out.txt -e 'redirecting (type: filter) testns.testredirect.multi_redirect_filter to testns.testredirect.redirect_filter1'
+grep out.txt -e 'Filter "testns.testredirect.multi_redirect_filter"'
grep out.txt -e 'redirecting (type: filter) testns.testredirect.redirect_filter1 to testns.testredirect.redirect_filter2'
+grep out.txt -e 'Filter "testns.testredirect.redirect_filter1"'
grep out.txt -e 'redirecting (type: filter) testns.testredirect.redirect_filter2 to testns.testcoll.testfilter'
+grep out.txt -e 'Filter "testns.testredirect.redirect_filter2"'
echo "--- validating collections support in playbooks/roles"
# run test playbooks
@@ -148,3 +152,12 @@ fi
./vars_plugin_tests.sh
./test_task_resolved_plugin.sh
+
+# Test tombstoned module/action plugins include the location of the fatal task
+cat <<EOF > test_dead_ping_error.yml
+- hosts: localhost
+ gather_facts: no
+ tasks:
+ - dead_ping:
+EOF
+ansible-playbook test_dead_ping_error.yml 2>&1 >/dev/null | grep -e 'line 4, column 5'
diff --git a/test/integration/targets/collections/test_plugins/override_formerly_core_masked_test.py b/test/integration/targets/collections/test_plugins/override_formerly_core_masked_test.py
index 11c7f7a..3a70685 100644
--- a/test/integration/targets/collections/test_plugins/override_formerly_core_masked_test.py
+++ b/test/integration/targets/collections/test_plugins/override_formerly_core_masked_test.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def override_formerly_core_masked_test(value, *args, **kwargs):
diff --git a/test/integration/targets/collections/test_task_resolved_plugin/action_plugins/legacy_action.py b/test/integration/targets/collections/test_task_resolved_plugin/action_plugins/legacy_action.py
index fa4d514..da81928 100644
--- a/test/integration/targets/collections/test_task_resolved_plugin/action_plugins/legacy_action.py
+++ b/test/integration/targets/collections/test_task_resolved_plugin/action_plugins/legacy_action.py
@@ -1,7 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
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 f1242e1..ba71668 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
@@ -1,8 +1,7 @@
# (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
name: display_resolved_action
diff --git a/test/integration/targets/collections/test_task_resolved_plugin/collections/ansible_collections/test_ns/test_coll/plugins/action/collection_action.py b/test/integration/targets/collections/test_task_resolved_plugin/collections/ansible_collections/test_ns/test_coll/plugins/action/collection_action.py
index fa4d514..da81928 100644
--- a/test/integration/targets/collections/test_task_resolved_plugin/collections/ansible_collections/test_ns/test_coll/plugins/action/collection_action.py
+++ b/test/integration/targets/collections/test_task_resolved_plugin/collections/ansible_collections/test_ns/test_coll/plugins/action/collection_action.py
@@ -1,7 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
diff --git a/test/integration/targets/collections/test_task_resolved_plugin/collections/ansible_collections/test_ns/test_coll/plugins/modules/collection_module.py b/test/integration/targets/collections/test_task_resolved_plugin/collections/ansible_collections/test_ns/test_coll/plugins/modules/collection_module.py
index 8f31226..ddfa909 100644
--- a/test/integration/targets/collections/test_task_resolved_plugin/collections/ansible_collections/test_ns/test_coll/plugins/modules/collection_module.py
+++ b/test/integration/targets/collections/test_task_resolved_plugin/collections/ansible_collections/test_ns/test_coll/plugins/modules/collection_module.py
@@ -3,8 +3,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
---
diff --git a/test/integration/targets/collections/test_task_resolved_plugin/library/legacy_module.py b/test/integration/targets/collections/test_task_resolved_plugin/library/legacy_module.py
index 4fd7587..98fccbb 100644
--- a/test/integration/targets/collections/test_task_resolved_plugin/library/legacy_module.py
+++ b/test/integration/targets/collections/test_task_resolved_plugin/library/legacy_module.py
@@ -3,8 +3,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
---
diff --git a/test/integration/targets/collections/testcoll2/plugins/modules/testmodule2.py b/test/integration/targets/collections/testcoll2/plugins/modules/testmodule2.py
index 7f6eb02..f8db43e 100644
--- a/test/integration/targets/collections/testcoll2/plugins/modules/testmodule2.py
+++ b/test/integration/targets/collections/testcoll2/plugins/modules/testmodule2.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
diff --git a/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/filter/test_filter.py b/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/filter/test_filter.py
index dca094b..aea1bba 100644
--- a/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/filter/test_filter.py
+++ b/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/filter/test_filter.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def filter_name(a):
diff --git a/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/lookup/lookup_name.py b/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/lookup/lookup_name.py
index d0af703..4a8d042 100644
--- a/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/lookup/lookup_name.py
+++ b/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/lookup/lookup_name.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.lookup import LookupBase
diff --git a/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/lookup/lookup_no_future_boilerplate.py b/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/lookup/lookup_no_future_boilerplate.py
index 79e80f6..5dda8b2 100644
--- a/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/lookup/lookup_no_future_boilerplate.py
+++ b/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/lookup/lookup_no_future_boilerplate.py
@@ -1,6 +1,6 @@
# do not add future boilerplate to this plugin
# specifically, do not add absolute_import, as the purpose of this plugin is to test implicit relative imports on Python 2.x
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.lookup import LookupBase
diff --git a/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/test/test_test.py b/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/test/test_test.py
index 1739072..bec061d 100644
--- a/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/test/test_test.py
+++ b/test/integration/targets/collections_plugin_namespace/collection_root/ansible_collections/my_ns/my_col/plugins/test/test_test.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def test_name_ok(value):
diff --git a/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util1.py b/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util1.py
index 196b4ab..6da2705 100644
--- a/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util1.py
+++ b/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util1.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
def one():
diff --git a/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util2.py b/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util2.py
index 0d985bf..50baed0 100644
--- a/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util2.py
+++ b/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util2.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from .my_util1 import one
diff --git a/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util3.py b/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util3.py
index 1529d7b..f04b870 100644
--- a/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util3.py
+++ b/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/module_utils/my_util3.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from . import my_util2
diff --git a/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/modules/my_module.py b/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/modules/my_module.py
index 0cdf500..e3848eb 100644
--- a/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/modules/my_module.py
+++ b/test/integration/targets/collections_relative_imports/collection_root/ansible_collections/my_ns/my_col/plugins/modules/my_module.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
from ..module_utils.my_util2 import two
diff --git a/test/integration/targets/collections_runtime_pythonpath/ansible-collection-python-dist-boo/ansible_collections/python/dist/plugins/modules/boo.py b/test/integration/targets/collections_runtime_pythonpath/ansible-collection-python-dist-boo/ansible_collections/python/dist/plugins/modules/boo.py
index a2313b1..a70c606 100644
--- a/test/integration/targets/collections_runtime_pythonpath/ansible-collection-python-dist-boo/ansible_collections/python/dist/plugins/modules/boo.py
+++ b/test/integration/targets/collections_runtime_pythonpath/ansible-collection-python-dist-boo/ansible_collections/python/dist/plugins/modules/boo.py
@@ -2,8 +2,7 @@
"""Say hello."""
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/collections_runtime_pythonpath/ansible-collection-python-dist-foo/ansible_collections/python/dist/plugins/modules/boo.py b/test/integration/targets/collections_runtime_pythonpath/ansible-collection-python-dist-foo/ansible_collections/python/dist/plugins/modules/boo.py
index 1ef0333..415e826 100644
--- a/test/integration/targets/collections_runtime_pythonpath/ansible-collection-python-dist-foo/ansible_collections/python/dist/plugins/modules/boo.py
+++ b/test/integration/targets/collections_runtime_pythonpath/ansible-collection-python-dist-foo/ansible_collections/python/dist/plugins/modules/boo.py
@@ -2,8 +2,7 @@
"""Say hello in Ukrainian."""
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/collections_runtime_pythonpath/runme.sh b/test/integration/targets/collections_runtime_pythonpath/runme.sh
index 38c6c64..2ec8e7d 100755
--- a/test/integration/targets/collections_runtime_pythonpath/runme.sh
+++ b/test/integration/targets/collections_runtime_pythonpath/runme.sh
@@ -9,10 +9,7 @@ export PIP_DISABLE_PIP_VERSION_CHECK=1
source virtualenv.sh
->&2 echo \
- === Test that the module \
- gets picked up if discoverable \
- via PYTHONPATH env var ===
+>&2 echo '=== Test that the module gets picked up if discoverable via PYTHONPATH env var ==='
PYTHONPATH="${PWD}/ansible-collection-python-dist-boo:$PYTHONPATH" \
ansible \
-m python.dist.boo \
@@ -21,10 +18,7 @@ ansible \
"$@" | grep -E '"greeting": "Hello, Bob!",'
->&2 echo \
- === Test that the module \
- gets picked up if installed \
- into site-packages ===
+>&2 echo '=== Test that the module gets picked up if installed into site-packages ==='
python -m pip install pep517
( # Build a binary Python dist (a wheel) using PEP517:
cp -r ansible-collection-python-dist-boo "${OUTPUT_DIR}/"
@@ -45,10 +39,7 @@ ansible \
"$@" | grep -E '"greeting": "Hello, Frodo!",'
->&2 echo \
- === Test that ansible_collections \
- root takes precedence over \
- PYTHONPATH/site-packages ===
+>&2 echo '=== Test that ansible_collections root takes precedence over PYTHONPATH/site-packages ==='
# This is done by injecting a module with the same FQCN
# into another collection root.
ANSIBLE_COLLECTIONS_PATH="${PWD}/ansible-collection-python-dist-foo" \
diff --git a/test/integration/targets/command_shell/tasks/main.yml b/test/integration/targets/command_shell/tasks/main.yml
index 2cc365d..e2fe122 100644
--- a/test/integration/targets/command_shell/tasks/main.yml
+++ b/test/integration/targets/command_shell/tasks/main.yml
@@ -543,15 +543,9 @@
- 'parent_dir_cd.stdout.endswith(remote_tmp_dir ~ "/www")'
- 'parent_dir_chdir.stdout.endswith(remote_tmp_dir ~ "/www_root")'
-- name: Set print error command for Python 2
- set_fact:
- print_error_command: print >> sys.stderr, msg
- when: ansible_facts.python_version is version('3', '<')
-
- name: Set print error command for Python 3
set_fact:
print_error_command: print(msg, file=sys.stderr)
- when: ansible_facts.python_version is version('3', '>=')
- name: run command with strip
command: '{{ ansible_python_interpreter }} -c "import sys; msg=''hello \n \r''; print(msg); {{ print_error_command }}"'
diff --git a/test/integration/targets/common_network/test_plugins/is_mac.py b/test/integration/targets/common_network/test_plugins/is_mac.py
index 6a4d409..6267281 100644
--- a/test/integration/targets/common_network/test_plugins/is_mac.py
+++ b/test/integration/targets/common_network/test_plugins/is_mac.py
@@ -1,8 +1,7 @@
# Copyright: (c) 2020, Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.common.network import is_mac
diff --git a/test/integration/targets/config/files/types.env b/test/integration/targets/config/files/types.env
index b5fc43e..675d206 100644
--- a/test/integration/targets/config/files/types.env
+++ b/test/integration/targets/config/files/types.env
@@ -9,3 +9,6 @@ ANSIBLE_TYPES_NOTVALID=
# totallynotvalid(list): does nothihng, just for testing values
ANSIBLE_TYPES_TOTALLYNOTVALID=
+
+# str_mustunquote(string): does nothihng, just for testing values
+ANSIBLE_TYPES_STR_MUSTUNQUOTE=
diff --git a/test/integration/targets/config/files/types.ini b/test/integration/targets/config/files/types.ini
index c04b6d5..15af0a3 100644
--- a/test/integration/targets/config/files/types.ini
+++ b/test/integration/targets/config/files/types.ini
@@ -11,3 +11,8 @@ totallynotvalid=
# (list) does nothihng, just for testing values
valid=
+
+[string_values]
+# (string) does nothihng, just for testing values
+str_mustunquote=
+
diff --git a/test/integration/targets/config/files/types.vars b/test/integration/targets/config/files/types.vars
index d1427fc..7c9d1fe 100644
--- a/test/integration/targets/config/files/types.vars
+++ b/test/integration/targets/config/files/types.vars
@@ -13,3 +13,7 @@ ansible_types_notvalid: ''
# totallynotvalid(list): does nothihng, just for testing values
ansible_types_totallynotvalid: ''
+
+# str_mustunquote(string): does nothihng, just for testing values
+ansible_types_str_mustunquote: ''
+
diff --git a/test/integration/targets/config/lookup_plugins/bogus.py b/test/integration/targets/config/lookup_plugins/bogus.py
index 34dc98a..3a31c35 100644
--- a/test/integration/targets/config/lookup_plugins/bogus.py
+++ b/test/integration/targets/config/lookup_plugins/bogus.py
@@ -1,10 +1,8 @@
# (c) 2021 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
+from __future__ import annotations
-__metaclass__ = type
DOCUMENTATION = """
name: bogus
diff --git a/test/integration/targets/config/lookup_plugins/casting.py b/test/integration/targets/config/lookup_plugins/casting.py
new file mode 100644
index 0000000..4e7338d
--- /dev/null
+++ b/test/integration/targets/config/lookup_plugins/casting.py
@@ -0,0 +1,59 @@
+# (c) 2021 Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import annotations
+
+
+DOCUMENTATION = """
+ name: casting
+ author: Ansible Core Team
+ version_added: histerical
+ short_description: returns what you gave it
+ description:
+ - this is mostly a noop
+ options:
+ _terms:
+ description: stuff to pass through
+ test_list:
+ description: does nothihng, just for testing values
+ type: list
+ test_int:
+ description: does nothihng, just to test casting
+ type: int
+ test_bool:
+ description: does nothihng, just to test casting
+ type: bool
+ test_str:
+ description: does nothihng, just to test casting
+ type: str
+"""
+
+EXAMPLES = """
+- name: like some other plugins, this is mostly useless
+ debug: msg={{ q('casting', [1,2,3])}}
+"""
+
+RETURN = """
+ _list:
+ description: basically the same as you fed in
+ type: list
+ elements: raw
+"""
+
+from ansible.plugins.lookup import LookupBase
+
+
+class LookupModule(LookupBase):
+
+ def run(self, terms, variables=None, **kwargs):
+
+ self.set_options(var_options=variables, direct=kwargs)
+
+ for cast in (list, int, bool, str):
+ option = 'test_%s' % str(cast).replace("<class '", '').replace("'>", '')
+ value = self.get_option(option)
+ if value is None or type(value) is cast:
+ continue
+ raise Exception('%s is not a %s: got %s/%s' % (option, cast, type(value), value))
+
+ return terms
diff --git a/test/integration/targets/config/lookup_plugins/casting_individual.py b/test/integration/targets/config/lookup_plugins/casting_individual.py
new file mode 100644
index 0000000..af1f60a
--- /dev/null
+++ b/test/integration/targets/config/lookup_plugins/casting_individual.py
@@ -0,0 +1,58 @@
+# (c) 2021 Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import annotations
+
+
+DOCUMENTATION = """
+ name: casting_individual
+ author: Ansible Core Team
+ version_added: histerical
+ short_description: returns what you gave it
+ description:
+ - this is mostly a noop
+ options:
+ _terms:
+ description: stuff to pass through
+ test_list:
+ description: does nothihng, just for testing values
+ type: list
+ test_int:
+ description: does nothihng, just to test casting
+ type: int
+ test_bool:
+ description: does nothihng, just to test casting
+ type: bool
+ test_str:
+ description: does nothihng, just to test casting
+ type: str
+"""
+
+EXAMPLES = """
+- name: like some other plugins, this is mostly useless
+ debug: msg={{ q('casting_individual', [1,2,3])}}
+"""
+
+RETURN = """
+ _list:
+ description: basically the same as you fed in
+ type: list
+ elements: raw
+"""
+
+from ansible.plugins.lookup import LookupBase
+
+
+class LookupModule(LookupBase):
+
+ def run(self, terms, variables=None, **kwargs):
+
+ for cast in (list, int, bool, str):
+ option = 'test_%s' % str(cast).replace("<class '", '').replace("'>", '')
+ if option in kwargs:
+ self.set_option(option, kwargs[option])
+ value = self.get_option(option)
+ if type(value) is not cast:
+ raise Exception('%s is not a %s: got %s/%s' % (option, cast, type(value), value))
+
+ return terms
diff --git a/test/integration/targets/config/lookup_plugins/types.py b/test/integration/targets/config/lookup_plugins/types.py
index d309229..0b1e978 100644
--- a/test/integration/targets/config/lookup_plugins/types.py
+++ b/test/integration/targets/config/lookup_plugins/types.py
@@ -1,10 +1,8 @@
# (c) 2021 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
+from __future__ import annotations
-__metaclass__ = type
DOCUMENTATION = """
name: types
@@ -56,6 +54,16 @@ DOCUMENTATION = """
- name: ANSIBLE_TYPES_TOTALLYNOTVALID
vars:
- name: ansible_types_totallynotvalid
+ str_mustunquote:
+ description: does nothihng, just for testing values
+ type: string
+ ini:
+ - section: string_values
+ key: str_mustunquote
+ env:
+ - name: ANSIBLE_TYPES_STR_MUSTUNQUOTE
+ vars:
+ - name: ansible_types_str_mustunquote
"""
EXAMPLES = """
diff --git a/test/integration/targets/config/runme.sh b/test/integration/targets/config/runme.sh
index 5b999e3..b7a5244 100755
--- a/test/integration/targets/config/runme.sh
+++ b/test/integration/targets/config/runme.sh
@@ -2,9 +2,8 @@
set -eux
-# ignore empty env var and use default
-# shellcheck disable=SC1007
-ANSIBLE_TIMEOUT= ansible -m ping testhost -i ../../inventory "$@"
+# use default timeout
+ANSIBLE_TIMEOUT='' ansible -m ping testhost -i ../../inventory "$@"
# env var is wrong type, this should be a fatal error pointing at the setting
ANSIBLE_TIMEOUT='lola' ansible -m ping testhost -i ../../inventory "$@" 2>&1|grep 'Invalid type for configuration option setting: DEFAULT_TIMEOUT (from env: ANSIBLE_TIMEOUT)'
diff --git a/test/integration/targets/config/type_munging.cfg b/test/integration/targets/config/type_munging.cfg
index d6aeaab..14b84cb 100644
--- a/test/integration/targets/config/type_munging.cfg
+++ b/test/integration/targets/config/type_munging.cfg
@@ -6,3 +6,6 @@ valid = 1, 2, 3
mustunquote = '1', '2', '3'
notvalid = [1, 2, 3]
totallynotvalid = ['1', '2', '3']
+
+[string_values]
+str_mustunquote = 'foo'
diff --git a/test/integration/targets/config/types.yml b/test/integration/targets/config/types.yml
index 650a96f..fe7e6df 100644
--- a/test/integration/targets/config/types.yml
+++ b/test/integration/targets/config/types.yml
@@ -1,7 +1,7 @@
- hosts: localhost
gather_facts: false
tasks:
- - name: ensures we got the list we expected
+ - name: ensures we got the values we expected
block:
- name: initialize plugin
debug: msg={{ lookup('types', 'starting test') }}
@@ -11,6 +11,7 @@
mustunquote: '{{ lookup("config", "mustunquote", plugin_type="lookup", plugin_name="types") }}'
notvalid: '{{ lookup("config", "notvalid", plugin_type="lookup", plugin_name="types") }}'
totallynotvalid: '{{ lookup("config", "totallynotvalid", plugin_type="lookup", plugin_name="types") }}'
+ str_mustunquote: '{{ lookup("config", "str_mustunquote", plugin_type="lookup", plugin_name="types") }}'
- assert:
that:
@@ -18,8 +19,10 @@
- 'mustunquote|type_debug == "list"'
- 'notvalid|type_debug == "list"'
- 'totallynotvalid|type_debug == "list"'
+ - 'str_mustunquote|type_debug == "AnsibleUnsafeText"'
- valid[0]|int == 1
- mustunquote[0]|int == 1
- "notvalid[0] == '[1'"
# using 'and true' to avoid quote hell
- totallynotvalid[0] == "['1'" and True
+ - str_mustunquote == "foo"
diff --git a/test/integration/targets/config/validation.yml b/test/integration/targets/config/validation.yml
index 1c81e66..20800e0 100644
--- a/test/integration/targets/config/validation.yml
+++ b/test/integration/targets/config/validation.yml
@@ -15,3 +15,10 @@
- bad_input is failed
- '"Invalid value " in bad_input.msg'
- '"valid values are:" in bad_input.msg'
+
+ - name: test config option casting
+ set_fact:
+ direct: "{{ lookup('casting', 1, test_list=[1,2,3], test_int=1, test_bool=True, test_str='lola') }}"
+ from_strings: "{{ lookup('casting', 1, test_list='1,2,3', test_int='1', test_bool='true', test_str='lola') }}"
+ direct_individual: "{{ lookup('casting_individual', 1, test_list='1,2,3', test_int='1', test_bool='true', test_str='lola') }}"
+ from_strings_individual: "{{ lookup('casting_individual', 1, test_list='1,2,3', test_int='1', test_bool='true', test_str='lola') }}"
diff --git a/test/integration/targets/connection_delegation/action_plugins/delegation_action.py b/test/integration/targets/connection_delegation/action_plugins/delegation_action.py
index 9d419e7..3a8e1ca 100644
--- a/test/integration/targets/connection_delegation/action_plugins/delegation_action.py
+++ b/test/integration/targets/connection_delegation/action_plugins/delegation_action.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
diff --git a/test/integration/targets/connection_delegation/connection_plugins/delegation_connection.py b/test/integration/targets/connection_delegation/connection_plugins/delegation_connection.py
index f61846c..4a7e1d3 100644
--- a/test/integration/targets/connection_delegation/connection_plugins/delegation_connection.py
+++ b/test/integration/targets/connection_delegation/connection_plugins/delegation_connection.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = """
author: Ansible Core Team
diff --git a/test/integration/targets/connection_remote_is_local/connection_plugins/remote_is_local.py b/test/integration/targets/connection_remote_is_local/connection_plugins/remote_is_local.py
index 818bca4..20a309f 100644
--- a/test/integration/targets/connection_remote_is_local/connection_plugins/remote_is_local.py
+++ b/test/integration/targets/connection_remote_is_local/connection_plugins/remote_is_local.py
@@ -1,7 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/connection_ssh/runme.sh b/test/integration/targets/connection_ssh/runme.sh
index ad817c8..5fee431 100755
--- a/test/integration/targets/connection_ssh/runme.sh
+++ b/test/integration/targets/connection_ssh/runme.sh
@@ -66,7 +66,7 @@ fi
# sftp
./posix.sh "$@"
# scp
-ANSIBLE_SCP_IF_SSH=true ./posix.sh "$@" "${scp_args[@]}"
+ANSIBLE_SSH_TRANSFER_METHOD=scp ./posix.sh "$@" "${scp_args[@]}"
# piped
ANSIBLE_SSH_TRANSFER_METHOD=piped ./posix.sh "$@"
diff --git a/test/integration/targets/copy/tasks/dest_in_non_existent_directories.yml b/test/integration/targets/copy/tasks/dest_in_non_existent_directories.yml
index c86caa1..12d47b3 100644
--- a/test/integration/targets/copy/tasks/dest_in_non_existent_directories.yml
+++ b/test/integration/targets/copy/tasks/dest_in_non_existent_directories.yml
@@ -2,13 +2,13 @@
# checks that dest is created
- name: Ensure that dest top directory doesn't exist
file:
- path: '{{ remote_dir }}/{{ item.dest.split("/")[0] }}'
+ path: '{{ remote_dir }}/{{ item.dest.split("/")[0] }}'
state: absent
- name: Copy file, dest is a nonexistent target directory
copy:
- src: '{{ item.src }}'
- dest: '{{ remote_dir }}/{{ item.dest }}'
+ src: '{{ item.src }}'
+ dest: '{{ remote_dir }}/{{ item.dest }}'
register: copy_result
- name: assert copy worked
diff --git a/test/integration/targets/copy/tasks/dest_in_non_existent_directories_remote_src.yml b/test/integration/targets/copy/tasks/dest_in_non_existent_directories_remote_src.yml
index fad53e7..d42318f 100644
--- a/test/integration/targets/copy/tasks/dest_in_non_existent_directories_remote_src.yml
+++ b/test/integration/targets/copy/tasks/dest_in_non_existent_directories_remote_src.yml
@@ -2,7 +2,7 @@
# checks that dest is created
- name: Ensure that dest top directory doesn't exist
file:
- path: '{{ remote_dir }}/{{ item.dest.split("/")[0] }}'
+ path: '{{ remote_dir }}/{{ item.dest.split("/")[0] }}'
state: absent
- name: create subdir
@@ -20,8 +20,8 @@
- name: Copy file, dest is a nonexistent target directory
copy:
- src: '{{ item.src }}'
- dest: '{{ remote_dir }}/{{ item.dest }}'
+ src: '{{ item.src }}'
+ dest: '{{ remote_dir }}/{{ item.dest }}'
remote_src: true
register: copy_result
diff --git a/test/integration/targets/copy/tasks/selinux.yml b/test/integration/targets/copy/tasks/selinux.yml
index dddee6f..4a58706 100644
--- a/test/integration/targets/copy/tasks/selinux.yml
+++ b/test/integration/targets/copy/tasks/selinux.yml
@@ -2,7 +2,7 @@
# https://github.com/ansible/ansible/issues/70244
- block:
- name: Install dosfstools
- yum:
+ dnf:
name: dosfstools
state: present
@@ -31,6 +31,6 @@
state: absent
- name: Uninstall dosfstools
- yum:
+ dnf:
name: dosfstools
state: absent
diff --git a/test/integration/targets/copy/tasks/src_file_dest_file_in_non_existent_dir.yml b/test/integration/targets/copy/tasks/src_file_dest_file_in_non_existent_dir.yml
index f4ab999..b7b77ba 100644
--- a/test/integration/targets/copy/tasks/src_file_dest_file_in_non_existent_dir.yml
+++ b/test/integration/targets/copy/tasks/src_file_dest_file_in_non_existent_dir.yml
@@ -1,6 +1,6 @@
- name: Ensure that dest top directory doesn't exist
file:
- path: '{{ remote_dir }}/{{ dest.split("/")[0] }}'
+ path: '{{ remote_dir }}/{{ dest.split("/")[0] }}'
state: absent
- name: Copy file, dest is a file in non-existing target directory
@@ -17,7 +17,7 @@
- name: Stat dest path
stat:
- path: '{{ remote_dir }}/{{ dest.split("/")[0] }}'
+ path: '{{ remote_dir }}/{{ dest.split("/")[0] }}'
register: stat_file_in_dir_result
- name: assert that dest doesn't exist
diff --git a/test/integration/targets/copy/tasks/src_file_dest_file_in_non_existent_dir_remote_src.yml b/test/integration/targets/copy/tasks/src_file_dest_file_in_non_existent_dir_remote_src.yml
index 61d8796..2f51cb5 100644
--- a/test/integration/targets/copy/tasks/src_file_dest_file_in_non_existent_dir_remote_src.yml
+++ b/test/integration/targets/copy/tasks/src_file_dest_file_in_non_existent_dir_remote_src.yml
@@ -1,6 +1,6 @@
- name: Ensure that dest top directory doesn't exist
file:
- path: '{{ remote_dir }}/{{ dest.split("/")[0] }}'
+ path: '{{ remote_dir }}/{{ dest.split("/")[0] }}'
state: absent
- name: create src file
@@ -23,7 +23,7 @@
- name: Stat dest path
stat:
- path: '{{ remote_dir }}/{{ dest.split("/")[0] }}'
+ path: '{{ remote_dir }}/{{ dest.split("/")[0] }}'
register: stat_file_in_dir_result
- name: assert that dest doesn't exist
diff --git a/test/integration/targets/copy/tasks/tests.yml b/test/integration/targets/copy/tasks/tests.yml
index 40ea9de..50a3465 100644
--- a/test/integration/targets/copy/tasks/tests.yml
+++ b/test/integration/targets/copy/tasks/tests.yml
@@ -92,6 +92,18 @@
- "stat_results.stat.issock == false"
- "stat_results.stat.checksum == ('foo.txt\n'|hash('sha1'))"
+- name: Test copying content with force=false when the dest already exists
+ copy:
+ content: other_data
+ dest: "{{ remote_file }}"
+ mode: 0444
+ force: False
+ register: repeat_copy_result
+
+- name: Assert no changes are made
+ assert:
+ that: repeat_copy_result is not changed
+
- name: Overwrite the file via same means
copy:
src: foo.txt
@@ -987,13 +999,13 @@
- name: Create a directory outside of the tree
file:
- path: '{{ local_temp_dir }}/source2'
+ path: '{{ local_temp_dir }}/source2'
state: directory
- name: Create a symlink to a directory outside of the tree
file:
path: '{{ local_temp_dir }}/source1/link'
- src: '{{ local_temp_dir }}/source2'
+ src: '{{ local_temp_dir }}/source2'
state: link
- name: Create a circular link back to the tree
@@ -1063,7 +1075,7 @@
- name: Create a file inside of the directory
copy:
content: "testing"
- dest: '{{ local_temp_dir }}/source_recursive/file'
+ dest: '{{ local_temp_dir }}/source_recursive/file'
- name: Create a directory to place the test output in
file:
@@ -1444,7 +1456,7 @@
block:
- name: Create a test dir to copy
file:
- path: '{{ local_temp_dir }}/top_dir'
+ path: '{{ local_temp_dir }}/top_dir'
state: directory
- name: Create a test dir to symlink to
@@ -1454,7 +1466,7 @@
- name: Create a file in the test dir
copy:
- dest: '{{ local_temp_dir }}/linked_dir/file1'
+ dest: '{{ local_temp_dir }}/linked_dir/file1'
content: 'hello world'
- name: Create a link to the test dir
@@ -1477,7 +1489,7 @@
- name: Copy the directory's link
copy:
- src: '{{ local_temp_dir }}/top_dir'
+ src: '{{ local_temp_dir }}/top_dir'
dest: '{{ remote_dir }}/new_dir'
local_follow: True
@@ -2044,7 +2056,7 @@
dest: '{{ remote_dir }}/testcase5_remote_src_subdirs_src'
- name: Create a 2nd level subdirectory
file:
- path: '{{ remote_dir }}/testcase5_remote_src_subdirs_src/subdir/subdir2/'
+ path: '{{ remote_dir }}/testcase5_remote_src_subdirs_src/subdir/subdir2/'
state: directory
- name: execute - Copy the directory on remote
copy:
diff --git a/test/integration/targets/deb822_repository/tasks/test.yml b/test/integration/targets/deb822_repository/tasks/test.yml
index 4911bb9..345ccb7 100644
--- a/test/integration/targets/deb822_repository/tasks/test.yml
+++ b/test/integration/targets/deb822_repository/tasks/test.yml
@@ -53,6 +53,19 @@
date_max_future: 10
register: deb822_create_1_idem
+- name: Create deb822 repo (changed order of parameters) idempotency
+ deb822_repository:
+ uris: http://us.archive.ubuntu.com/ubuntu
+ name: ansible-test focal archive
+ date_max_future: 10
+ components:
+ - main
+ - restricted
+ suites:
+ - focal
+ - focal-updates
+ register: deb822_create_2_idem
+
- name: Create deb822 repo - check_mode
deb822_repository:
name: ansible-test focal archive
@@ -97,18 +110,19 @@
- deb822_create_1.repo|trim == focal_archive_expected
- deb822_create_1_idem is not changed
+ - deb822_create_2_idem is not changed
- deb822_create_1_mode is changed
- deb822_create_1_stat_1.stat.mode == '0644'
- deb822_create_1_stat_2.stat.mode == '0600'
vars:
focal_archive_expected: |-
- X-Repolib-Name: ansible-test focal archive
- URIs: http://us.archive.ubuntu.com/ubuntu
- Suites: focal focal-updates
Components: main restricted
Date-Max-Future: 10
+ X-Repolib-Name: ansible-test focal archive
+ Suites: focal focal-updates
Types: deb
+ URIs: http://us.archive.ubuntu.com/ubuntu
- name: Remove repos
deb822_repository:
@@ -177,11 +191,8 @@
'BEGIN' not in signed_by_url.repo
vars:
signed_by_inline_expected: |-
- X-Repolib-Name: ansible-test
- Types: deb
- URIs: https://deb.debian.org
- Suites: stable
Components: main contrib non-free
+ X-Repolib-Name: ansible-test
Signed-By:
-----BEGIN PGP PUBLIC KEY BLOCK-----
.
@@ -192,6 +203,9 @@
3bHcln8DMpIJVXht78sL
=IE0r
-----END PGP PUBLIC KEY BLOCK-----
+ Suites: stable
+ Types: deb
+ URIs: https://deb.debian.org
- name: remove ansible-test repo
deb822_repository:
diff --git a/test/integration/targets/debconf/tasks/main.yml b/test/integration/targets/debconf/tasks/main.yml
index f923626..4021349 100644
--- a/test/integration/targets/debconf/tasks/main.yml
+++ b/test/integration/targets/debconf/tasks/main.yml
@@ -66,6 +66,86 @@
assert:
that:
- not debconf_test2.changed
+
+ - name: Multiselect value
+ debconf:
+ name: libnss-ldapd
+ question: libnss-ldapd/nsswitch
+ vtype: multiselect
+ value:
+ - passwd
+ - group
+ - shadow
+ register: debconf_multiselect_test
+
+ - name: validate results for multiselect test
+ assert:
+ that:
+ - debconf_multiselect_test.changed
+
+ - name: Multiselect value again (idempotency)
+ debconf:
+ name: libnss-ldapd
+ question: libnss-ldapd/nsswitch
+ vtype: multiselect
+ value:
+ - passwd
+ - group
+ - shadow
+ register: debconf_multiselect_test_idem
+
+ - name: validate results for multiselect test (idempotency)
+ assert:
+ that:
+ - not debconf_multiselect_test_idem.changed
+
+ - name: Multiselect value to check if ordered value
+ debconf:
+ name: libnss-ldapd
+ question: libnss-ldapd/nsswitch
+ vtype: multiselect
+ value:
+ - group
+ - shadow
+ - passwd
+ register: debconf_multiselect_test_idem_2
+
+ - name: validate results for multiselect test for ordered value
+ assert:
+ that:
+ - not debconf_multiselect_test_idem_2.changed
+
+ - name: Multiselect value to check backward compatibility
+ debconf:
+ name: libnss-ldapd
+ question: libnss-ldapd/nsswitch
+ vtype: multiselect
+ value: group, shadow, passwd
+ register: debconf_multiselect_test_idem_3
+
+ - name: validate results for multiselect test for backward compatibility
+ assert:
+ that:
+ - debconf_multiselect_test_idem_3.changed
+
+ - name: Multiselect value to check if value contains invalid user input
+ debconf:
+ name: libnss-ldapd
+ question: libnss-ldapd/nsswitch
+ vtype: multiselect
+ value:
+ - group
+ - 1
+ - passwd
+ register: debconf_multiselect_test_idem_4
+ ignore_errors: yes
+
+ - name: validate results for multiselect test for invalid value
+ assert:
+ that:
+ - not debconf_multiselect_test_idem_4.changed
+ - '"Invalid value provided" in debconf_multiselect_test_idem_4.msg'
+
always:
- name: uninstall debconf-utils
apt:
diff --git a/test/integration/targets/debugger/test_run_once.py b/test/integration/targets/debugger/test_run_once.py
index 237f9c2..0b65c42 100755
--- a/test/integration/targets/debugger/test_run_once.py
+++ b/test/integration/targets/debugger/test_run_once.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import annotations
import io
import os
diff --git a/test/integration/targets/delegate_to/connection_plugins/fakelocal.py b/test/integration/targets/delegate_to/connection_plugins/fakelocal.py
index 59ddcf0..e0ecdfd 100644
--- a/test/integration/targets/delegate_to/connection_plugins/fakelocal.py
+++ b/test/integration/targets/delegate_to/connection_plugins/fakelocal.py
@@ -1,7 +1,6 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
connection: fakelocal
diff --git a/test/integration/targets/delegate_to/library/detect_interpreter.py b/test/integration/targets/delegate_to/library/detect_interpreter.py
index 1f40167..381ab7e 100644
--- a/test/integration/targets/delegate_to/library/detect_interpreter.py
+++ b/test/integration/targets/delegate_to/library/detect_interpreter.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import sys
diff --git a/test/integration/targets/dict_transformations/library/convert_camelCase.py b/test/integration/targets/dict_transformations/library/convert_camelCase.py
index 50ca34c..0bc267c 100644
--- a/test/integration/targets/dict_transformations/library/convert_camelCase.py
+++ b/test/integration/targets/dict_transformations/library/convert_camelCase.py
@@ -3,8 +3,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/dict_transformations/library/convert_snake_case.py b/test/integration/targets/dict_transformations/library/convert_snake_case.py
index 4c13fbc..b645eb7 100644
--- a/test/integration/targets/dict_transformations/library/convert_snake_case.py
+++ b/test/integration/targets/dict_transformations/library/convert_snake_case.py
@@ -3,8 +3,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/dnf/filter_plugins/dnf_module_list.py b/test/integration/targets/dnf/filter_plugins/dnf_module_list.py
new file mode 100644
index 0000000..3ef9874
--- /dev/null
+++ b/test/integration/targets/dnf/filter_plugins/dnf_module_list.py
@@ -0,0 +1,40 @@
+# Copyright: Contributors to the Ansible project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import annotations
+
+from collections import Counter
+
+
+def parse_module_list(stdout):
+ lines = stdout.splitlines()
+ name_offset = 0
+ empty_offset = -1
+ modules = []
+ for i, line in enumerate(lines):
+ if line.startswith('Name '):
+ name_offset = i + 1
+ if not line.strip():
+ empty_offset = i
+ for line in lines[name_offset:empty_offset]:
+ cols = line.split()[:3]
+ modules.append({
+ 'name': cols[0],
+ 'version': cols[1],
+ 'profile': cols[2].rstrip(','), # Just the first profile
+ })
+ return modules
+
+
+def get_first_single_version_module(stdout):
+ modules = parse_module_list(stdout)
+ name = Counter([m['name'] for m in modules]).most_common()[-1][0]
+ module, = [m for m in modules if m['name'] == name]
+ return module
+
+
+class FilterModule:
+ def filters(self):
+ return {
+ 'get_first_single_version_module': get_first_single_version_module,
+ }
diff --git a/test/integration/targets/dnf/tasks/dnf.yml b/test/integration/targets/dnf/tasks/dnf.yml
index c5f0173..4110d4b 100644
--- a/test/integration/targets/dnf/tasks/dnf.yml
+++ b/test/integration/targets/dnf/tasks/dnf.yml
@@ -120,6 +120,19 @@
that:
- "not dnf_result.changed"
+- name: install sos again with empty string enablerepo
+ dnf:
+ name: sos
+ state: present
+ enablerepo: ""
+ register: dnf_result
+
+- name: verify no change on third install with empty string enablerepo
+ assert:
+ that:
+ - "dnf_result is success"
+ - "not dnf_result is changed"
+
# Multiple packages
- name: uninstall sos and dos2unix
dnf: name=sos,dos2unix state=removed
@@ -434,10 +447,6 @@
name: landsidescalping
state: absent
-# cleanup until https://github.com/ansible/ansible/issues/27377 is resolved
-- shell: 'dnf -y group install "Custom Group" && dnf -y group remove "Custom Group"'
- register: shell_dnf_result
-
- dnf:
name: "@Custom Group"
state: absent
@@ -458,9 +467,6 @@
- dnf_result is changed
- "'results' in dnf_result"
-# cleanup until https://github.com/ansible/ansible/issues/27377 is resolved
-- shell: dnf -y group install "Custom Group" && dnf -y group remove "Custom Group"
-
- dnf:
name: "@Custom Group"
state: absent
@@ -515,6 +521,7 @@
that:
- "dnf_result is failed"
- "not dnf_result.changed"
+ - "'Failure downloading' in dnf_result.msg or 'Failed to download' in dnf_result.msg"
- name: verify dnf module outputs
assert:
diff --git a/test/integration/targets/dnf/tasks/dnf_group_remove.yml b/test/integration/targets/dnf/tasks/dnf_group_remove.yml
new file mode 100644
index 0000000..c6d4011
--- /dev/null
+++ b/test/integration/targets/dnf/tasks/dnf_group_remove.yml
@@ -0,0 +1,141 @@
+- name: install a group to test and dnf-utils
+ dnf:
+ name: "{{ pkgs }}"
+ state: present
+ vars:
+ pkgs:
+ - "@Custom Group"
+ - dnf-utils
+
+- name: check mode remove the group
+ dnf:
+ name: "@Custom Group"
+ state: absent
+ check_mode: yes
+ register: dnf_result
+
+- name: verify changed
+ assert:
+ that:
+ - "dnf_result.changed"
+
+- name: verify dnf module outputs
+ assert:
+ that:
+ - "'changed' in dnf_result"
+ - "'results' in dnf_result"
+
+- name: remove the group
+ dnf:
+ name: "@Custom Group"
+ state: absent
+ register: dnf_result
+
+- name: verify changed
+ assert:
+ that:
+ - "dnf_result.rc == 0"
+ - "dnf_result.changed"
+
+- name: verify dnf module outputs
+ assert:
+ that:
+ - "'changed' in dnf_result"
+ - "'msg' in dnf_result"
+ - "'results' in dnf_result"
+
+- name: remove the group again
+ dnf:
+ name: "@Custom Group"
+ state: absent
+ register: dnf_result
+
+- name: verify changed
+ assert:
+ that:
+ - "not dnf_result.changed"
+
+- name: verify dnf module outputs
+ assert:
+ that:
+ - "'changed' in dnf_result"
+ - "'msg' in dnf_result"
+ - "'results' in dnf_result"
+
+- name: check mode remove the group again
+ dnf:
+ name: "@Custom Group"
+ state: absent
+ check_mode: yes
+ register: dnf_result
+
+- name: verify changed
+ assert:
+ that:
+ - "not dnf_result.changed"
+
+- name: verify dnf module outputs
+ assert:
+ that:
+ - "'changed' in dnf_result"
+ - "'results' in dnf_result"
+
+- name: install a group and a package to test
+ dnf:
+ name: "@Custom Group,sos"
+ state: present
+ register: dnf_output
+
+- name: check mode remove the group along with the package
+ dnf:
+ name: "@Custom Group,sos"
+ state: absent
+ register: dnf_result
+ check_mode: yes
+
+- name: verify changed
+ assert:
+ that:
+ - "dnf_result.changed"
+
+- name: verify dnf module outputs
+ assert:
+ that:
+ - "'changed' in dnf_result"
+ - "'results' in dnf_result"
+
+- name: remove the group along with the package
+ dnf:
+ name: "@Custom Group,sos"
+ state: absent
+ register: dnf_result
+
+- name: verify changed
+ assert:
+ that:
+ - "dnf_result.changed"
+
+- name: verify dnf module outputs
+ assert:
+ that:
+ - "'changed' in dnf_result"
+ - "'msg' in dnf_result"
+ - "'results' in dnf_result"
+
+- name: check mode remove the group along with the package
+ dnf:
+ name: "@Custom Group,sos"
+ state: absent
+ register: dnf_result
+ check_mode: yes
+
+- name: verify not changed
+ assert:
+ that:
+ - "not dnf_result.changed"
+
+- name: verify dnf module outputs
+ assert:
+ that:
+ - "'changed' in dnf_result"
+ - "'results' in dnf_result"
diff --git a/test/integration/targets/dnf/tasks/main.yml b/test/integration/targets/dnf/tasks/main.yml
index 4941e2c..8d9bda4 100644
--- a/test/integration/targets/dnf/tasks/main.yml
+++ b/test/integration/targets/dnf/tasks/main.yml
@@ -47,6 +47,11 @@
when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
(ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))
+- include_tasks: dnf_group_remove.yml
+ when:
+ - (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
+ (ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))
+
- include_tasks: dnfinstallroot.yml
when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('23', '>=')) or
(ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))
@@ -57,13 +62,30 @@
- ansible_distribution == 'Fedora'
- ansible_distribution_major_version is version('23', '>=')
-- include_tasks: modularity.yml
- when:
- - (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('29', '>=')) or
+- when:
+ - (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('39', '<')) or
(ansible_distribution in ['RedHat', 'CentOS'] and ansible_distribution_major_version is version('8', '>='))
- not dnf5|default(false)
- tags:
- - dnf_modularity
+ block:
+ # FUTURE - look at including AppStream support in our local repo
+ - name: list modules
+ command: dnf module list -q
+ register: module_list
+
+ # A module that only has a single version
+ - name: Find a module that meets our testing needs
+ set_fact:
+ astream_name: '@{{ module.name }}:{{ module.version }}/{{ module.profile }}'
+ astream_name_no_stream: '@{{ module.name }}/{{ module.profile }}'
+ vars:
+ module: '{{ module_list.stdout|get_first_single_version_module }}'
+
+ - include_tasks: modularity.yml
+ tags:
+ - dnf_modularity
+ rescue:
+ # Just in case something crazy happens when listing or parsing modules
+ - meta: noop
- include_tasks: logging.yml
when: (ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('31', '>=')) or
diff --git a/test/integration/targets/dnf/tasks/modularity.yml b/test/integration/targets/dnf/tasks/modularity.yml
index 94f43a4..6a97bf6 100644
--- a/test/integration/targets/dnf/tasks/modularity.yml
+++ b/test/integration/targets/dnf/tasks/modularity.yml
@@ -1,12 +1,3 @@
-# FUTURE - look at including AppStream support in our local repo
-- name: Include distribution specific variables
- include_vars: "{{ item }}"
- with_first_found:
- - files:
- - "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
- - "{{ ansible_facts.distribution }}.yml"
- paths: ../vars
-
- name: install "{{ astream_name }}" module
dnf:
name: "{{ astream_name }}"
diff --git a/test/integration/targets/dnf/tasks/repo.yml b/test/integration/targets/dnf/tasks/repo.yml
index 4f82899..7e34aed 100644
--- a/test/integration/targets/dnf/tasks/repo.yml
+++ b/test/integration/targets/dnf/tasks/repo.yml
@@ -101,6 +101,30 @@
that:
- "'results' in dnf_result"
# ============================================================================
+ - name: Install dinginessentail-1.0-1 from a file (higher version is already installed)
+ dnf:
+ name: "{{ repodir }}/dinginessentail-1.0-1.{{ ansible_architecture }}.rpm"
+ state: present
+ disable_gpg_check: True
+ register: dnf_result
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+
+ - name: Verify installation
+ assert:
+ that:
+ - "not dnf_result.changed"
+ - "rpm_result.stdout.startswith('dinginessentail-1.1-1')"
+
+ - name: Verify dnf module outputs
+ assert:
+ that:
+ - "'msg' in dnf_result"
+ - "'rc' in dnf_result"
+ - "'results' in dnf_result"
+ # ============================================================================
- name: Install dinginessentail-1.0-1 from a file (downgrade)
dnf:
name: "{{ repodir }}/dinginessentail-1.0-1.{{ ansible_architecture }}.rpm"
@@ -307,3 +331,192 @@
- dinginessentail-with-weak-dep
- dinginessentail-weak-dep
state: absent
+
+- block:
+ - dnf:
+ name: dinginessentail
+ state: present
+
+ - dnf:
+ list: dinginessentail*
+ register: list_out
+
+ - name: check that dnf returns nevra for backwards compat
+ assert:
+ that:
+ - '"envra" in list_out["results"][0]'
+ - '"nevra" in list_out["results"][0]'
+
+ - set_fact:
+ passed: true
+ loop: "{{ list_out.results }}"
+ when: item.yumstate == 'installed'
+
+ - name: Test that there is yumstate=installed in the result
+ assert:
+ that:
+ - passed is defined
+ always:
+ - name: Clean up
+ dnf:
+ name: dinginessentail
+ state: absent
+
+- block:
+ - name: Install dinginessentail-1.0-2
+ dnf:
+ name: "dinginessentail-1.0-2"
+ state: present
+ register: dnf_result
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+
+ - name: Verify installation
+ assert:
+ that:
+ - "dnf_result.changed"
+ - "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
+
+ - name: Verify dnf module outputs
+ assert:
+ that:
+ - "'msg' in dnf_result"
+ - "'rc' in dnf_result"
+ - "'results' in dnf_result"
+ always:
+ - name: Clean up
+ dnf:
+ name: dinginessentail
+ state: absent
+
+- block:
+ - name: Install dinginessentail < 1.1
+ dnf:
+ name: "dinginessentail < 1.1"
+ state: present
+ register: dnf_result
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+
+ - name: Verify installation
+ assert:
+ that:
+ - "dnf_result.changed"
+ - "rpm_result.stdout.startswith('dinginessentail-1.0')"
+
+ - name: Install dinginessentail >= 1.1
+ dnf:
+ name: "dinginessentail >= 1.1"
+ state: present
+ register: dnf_result
+
+ - name: Check dinginessentail with rpm
+ shell: rpm -q dinginessentail
+ register: rpm_result
+
+ - name: Verify installation
+ assert:
+ that:
+ - "dnf_result.changed"
+ - "rpm_result.stdout.startswith('dinginessentail-1.1')"
+
+ - name: Verify dnf module outputs
+ assert:
+ that:
+ - "'msg' in dnf_result"
+ - "'rc' in dnf_result"
+ - "'results' in dnf_result"
+ always:
+ - name: Clean up
+ dnf:
+ name: dinginessentail
+ state: absent
+
+- name: >
+ test that when a package providing a file is installed then installing by specifying the file doesn't result in
+ installing a different package providing the same file
+ block:
+ - dnf:
+ name: provides_foo_b
+ state: "{{ item }}"
+ loop:
+ - absent
+ - present
+
+ - dnf:
+ name: /foo.gif
+ state: present
+ register: dnf_result
+
+ - command: rpm -q package_foo_a
+ ignore_errors: true
+ register: rpm_result
+
+ - assert:
+ that:
+ - dnf_result is not changed
+ - rpm_result.rc == 1
+ always:
+ - name: Clean up
+ dnf:
+ name: "{{ item }}"
+ state: absent
+ loop:
+ - provides_foo_b
+
+- name: ensure that a package named "$str-$number-$str" is parsed correctly
+ block:
+ - dnf:
+ name: number-11-name-11.0
+ state: "{{ item }}"
+ loop:
+ - absent
+ - present
+
+ - dnf:
+ name: number-11-name
+ state: present
+ register: dnf_result
+
+ - assert:
+ that:
+ - dnf_result is not changed
+
+ - dnf:
+ name: number-11-name
+ state: latest
+ update_only: true
+ register: dnf_result
+
+ - assert:
+ that:
+ - dnf_result is changed
+ always:
+ - name: Clean up
+ dnf:
+ name: number-11-name
+ state: absent
+
+- name: test that epochs are handled the same way as via DNF on the command line
+ block:
+ - dnf:
+ name: "{{ item }}"
+ state: present
+ loop:
+ - "epochone-1.0-1.noarch"
+ - "epochone-1.1-1.noarch"
+ register: dnf_results
+
+ - assert:
+ that:
+ - dnf_results["results"][0] is changed
+ - dnf_results["results"][1] is changed
+ always:
+ - name: Clean up
+ dnf:
+ name: epochone
+ state: absent
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 f54c0a8..3747966 100644
--- a/test/integration/targets/dnf/tasks/skip_broken_and_nobest.yml
+++ b/test/integration/targets/dnf/tasks/skip_broken_and_nobest.yml
@@ -264,6 +264,7 @@
name:
- broken-a
state: latest
+ best: true
ignore_errors: true
register: dnf_fail
@@ -304,7 +305,26 @@
that:
- res is not changed
- # Case 7 is already tested quite extensively above in the earlier tests.
+ # Case 7 is already tested quite extensively above in the earlier tests.
+ # ######################################################################
+
+ - block:
+ - name: Test available package is installed while unavailable one is skipped due to skip_broken=true
+ dnf:
+ name:
+ - dinginessentail
+ - not-in-repo
+ skip_broken: true
+ register: res
+
+ - assert:
+ that:
+ - res is changed
+ # There is a change in dnf5 that splits skip_broken into two options:
+ # skip_broken and skip_unavailable.
+ # TODO: for this test to pass on dnf5 the skip_unavailable option would have to be
+ # added to the dnf5 module and used here instead of skip_broken.
+ when: not dnf5|default(false)
always:
- name: Remove test yum repo
@@ -313,7 +333,8 @@
state: absent
- name: Remove all test packages installed
- yum:
+ dnf:
name:
- broken-*
+ - dinginessentail
state: absent
diff --git a/test/integration/targets/dnf/vars/CentOS.yml b/test/integration/targets/dnf/vars/CentOS.yml
deleted file mode 100644
index c70d853..0000000
--- a/test/integration/targets/dnf/vars/CentOS.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-astream_name: '@php:7.2/minimal'
-astream_name_no_stream: '@php/minimal'
diff --git a/test/integration/targets/dnf/vars/Fedora.yml b/test/integration/targets/dnf/vars/Fedora.yml
deleted file mode 100644
index fff6f4b..0000000
--- a/test/integration/targets/dnf/vars/Fedora.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-astream_name: '@varnish:6.0/default'
-
-# For this to work, it needs to be that only shows once in `dnf module list`.
-# Such packages, that exist on all the versions we test on, are hard to come by.
-# TODO: This would be solved by using our own repo with modularity/streams.
-astream_name_no_stream: '@varnish/default'
diff --git a/test/integration/targets/dnf/vars/RedHat-9.yml b/test/integration/targets/dnf/vars/RedHat-9.yml
deleted file mode 100644
index 680157d..0000000
--- a/test/integration/targets/dnf/vars/RedHat-9.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-astream_name: '@php:8.1/minimal'
-astream_name_no_stream: '@php/minimal'
diff --git a/test/integration/targets/dnf/vars/RedHat.yml b/test/integration/targets/dnf/vars/RedHat.yml
deleted file mode 100644
index c70d853..0000000
--- a/test/integration/targets/dnf/vars/RedHat.yml
+++ /dev/null
@@ -1,2 +0,0 @@
-astream_name: '@php:7.2/minimal'
-astream_name_no_stream: '@php/minimal'
diff --git a/test/integration/targets/dnf/vars/main.yml b/test/integration/targets/dnf/vars/main.yml
index 3f7b43a..90b6856 100644
--- a/test/integration/targets/dnf/vars/main.yml
+++ b/test/integration/targets/dnf/vars/main.yml
@@ -3,4 +3,4 @@ dnf_log_files:
- /var/log/dnf.rpm.log
- /var/log/dnf.librepo.log
-skip_broken_repo_baseurl: "https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/dnf/skip-broken/RPMS/"
+skip_broken_repo_baseurl: "https://ci-files.testing.ansible.com/test/integration/targets/dnf/skip-broken/RPMS/"
diff --git a/test/integration/targets/egg-info/lookup_plugins/import_pkg_resources.py b/test/integration/targets/egg-info/lookup_plugins/import_pkg_resources.py
index 28227fc..cba386b 100644
--- a/test/integration/targets/egg-info/lookup_plugins/import_pkg_resources.py
+++ b/test/integration/targets/egg-info/lookup_plugins/import_pkg_resources.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pkg_resources # pylint: disable=unused-import
diff --git a/test/integration/targets/entry_points/runme.sh b/test/integration/targets/entry_points/runme.sh
index cabf153..f8d6fe5 100755
--- a/test/integration/targets/entry_points/runme.sh
+++ b/test/integration/targets/entry_points/runme.sh
@@ -4,7 +4,6 @@ set -eu -o pipefail
source virtualenv.sh
set +x
unset PYTHONPATH
-export SETUPTOOLS_USE_DISTUTILS=stdlib
base_dir="$(dirname "$(dirname "$(dirname "$(dirname "${OUTPUT_DIR}")")")")"
bin_dir="$(dirname "$(command -v pip)")"
diff --git a/test/integration/targets/error_from_connection/connection_plugins/dummy.py b/test/integration/targets/error_from_connection/connection_plugins/dummy.py
index d322fe0..8450b7b 100644
--- a/test/integration/targets/error_from_connection/connection_plugins/dummy.py
+++ b/test/integration/targets/error_from_connection/connection_plugins/dummy.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = """
author:
diff --git a/test/integration/targets/expect/files/test_command.py b/test/integration/targets/expect/files/test_command.py
index 0e0e264..c723e7c 100644
--- a/test/integration/targets/expect/files/test_command.py
+++ b/test/integration/targets/expect/files/test_command.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import sys
diff --git a/test/integration/targets/fetch/injection/library/slurp.py b/test/integration/targets/fetch/injection/library/slurp.py
index 7b78ba1..1fcd5c2 100644
--- a/test/integration/targets/fetch/injection/library/slurp.py
+++ b/test/integration/targets/fetch/injection/library/slurp.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = """
diff --git a/test/integration/targets/file/tasks/state_link.yml b/test/integration/targets/file/tasks/state_link.yml
index 6f96cdc..ab41b07 100644
--- a/test/integration/targets/file/tasks/state_link.yml
+++ b/test/integration/targets/file/tasks/state_link.yml
@@ -186,11 +186,11 @@
- name: Delete unprivileged user home and tempdir
file:
- path: "{{ item }}"
+ path: "{{ item }}"
state: absent
loop:
- '{{ tempdir.path }}'
- - '{{ user.home }}'
+ - '{{ user.home }}'
- name: verify that link was created
assert:
@@ -199,7 +199,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 3005e4b..9f90774 100644
--- a/test/integration/targets/filter_core/aliases
+++ b/test/integration/targets/filter_core/aliases
@@ -1 +1,2 @@
shippable/posix/group4
+setup/always/setup_passlib_controller # required for setup_test_user
diff --git a/test/integration/targets/filter_core/meta/main.yml b/test/integration/targets/filter_core/meta/main.yml
deleted file mode 100644
index e430ea6..0000000
--- a/test/integration/targets/filter_core/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-dependencies:
- - role: setup_passlib
- when: ansible_facts.distribution == 'MacOSX'
diff --git a/test/integration/targets/filter_core/tasks/main.yml b/test/integration/targets/filter_core/tasks/main.yml
index 9d287a1..8b325a9 100644
--- a/test/integration/targets/filter_core/tasks/main.yml
+++ b/test/integration/targets/filter_core/tasks/main.yml
@@ -335,6 +335,27 @@
that:
- '"hElLo there"|regex_replace("hello", "hi", ignorecase=True) == "hi there"'
+- name: Verify regex_replace with count
+ assert:
+ that:
+ - '"foo=bar=baz"|regex_replace("=", ":", count=1) == "foo:bar=baz"'
+
+- name: Verify regex_replace with correct mandatory_count
+ assert:
+ that:
+ - '"foo=bar=baz"|regex_replace("=", ":", mandatory_count=2) == "foo:bar:baz"'
+
+- name: Verify regex_replace with incorrect mandatory_count
+ debug:
+ msg: "{{ 'foo=bar=baz'|regex_replace('=', ':', mandatory_count=1) }}"
+ ignore_errors: yes
+ register: incorrect_mandatory_count
+
+- assert:
+ that:
+ - "incorrect_mandatory_count is failed"
+ - "' times, but matches ' in incorrect_mandatory_count.msg"
+
- name: Verify case-insensitive regex_findall
assert:
that:
@@ -454,38 +475,18 @@
- password_hash_2 is failed
- "'not support' in password_hash_2.msg"
-- name: install passlib if needed
- pip:
- name: passlib
- state: present
- register: installed_passlib
-
- name: test using passlib with an unsupported hash type
set_fact:
foo: '{{"hey"|password_hash("msdcc")}}'
ignore_errors: yes
register: unsupported_hash_type
-- name: remove passlib if it was installed
- pip:
- name: passlib
- state: absent
- when: installed_passlib.changed
-
- assert:
that:
- unsupported_hash_type.msg == msg
vars:
msg: "msdcc is not in the list of supported passlib algorithms: md5, blowfish, sha256, sha512"
-- name: test password_hash can work with bcrypt without passlib installed
- debug:
- msg: "{{ 'somestring'|password_hash('bcrypt') }}"
- register: crypt_bcrypt
- # Some implementations of crypt do not fail outright and return some short value.
- failed_when: crypt_bcrypt is failed or (crypt_bcrypt.msg|length|int) != 60
- when: ansible_facts.os_family in ['RedHat', 'Debian']
-
- name: Verify to_uuid throws on weird namespace
set_fact:
foo: '{{"hey"|to_uuid(namespace=22)}}'
diff --git a/test/integration/targets/filter_encryption/aliases b/test/integration/targets/filter_encryption/aliases
index 3005e4b..4d41cf4 100644
--- a/test/integration/targets/filter_encryption/aliases
+++ b/test/integration/targets/filter_encryption/aliases
@@ -1 +1,2 @@
shippable/posix/group4
+gather_facts/no
diff --git a/test/integration/targets/filter_encryption/base.yml b/test/integration/targets/filter_encryption/base.yml
deleted file mode 100644
index 1479f73..0000000
--- a/test/integration/targets/filter_encryption/base.yml
+++ /dev/null
@@ -1,49 +0,0 @@
-- hosts: localhost
- gather_facts: true
- vars:
- data: secret
- data2: 'foo: bar\n'
- dvault: '{{ "secret"|vault("test")}}'
- password: test
- s_32: '{{(2**31-1)}}'
- s_64: '{{(2**63-1)}}'
- vaultedstring_32: "$ANSIBLE_VAULT;1.2;AES256;filter_default\n33360a30386436633031333665316161303732656333373131373935623033393964633637346464\n6234613765313539306138373564366363306533356464613334320a666339363037303764636538\n3131633564326637303237313463613864626231\n"
- vaultedstring_64: "$ANSIBLE_VAULT;1.2;AES256;filter_default\n33370a34333734353636633035656232613935353432656132646533346233326431346232616261\n6133383034376566366261316365633931356133633337396363370a376664386236313834326561\n6338373864623763613165366636633031303739\n"
- vault: !vault |
- $ANSIBLE_VAULT;1.1;AES256
- 33323332333033383335333533383338333333303339333733323339333833303334333133313339
- 33373339333133323331333833373335333933323338333633343338333133343334333733383334
- 33333335333433383337333133303339333433353332333333363339333733363335333233303330
- 3337333733353331333633313335333733373334333733320a373938666533366165653830313163
- 62386564343438653437333564383664646538653364343138303831613039313232636437336530
- 3438376662373764650a633366646563386335623161646262366137393635633464333265613938
- 6661
- # allow testing against 32b/64b limited archs, normally you can set higher values for random (2**256)
- is_64: '{{ "64" in ansible_facts["architecture"] }}'
- salt: '{{ is_64|bool|ternary(s_64, s_32)|random(seed=inventory_hostname)}}'
- vaultedstring: '{{ is_64|bool|ternary(vaultedstring_64, vaultedstring_32) }}'
- # command line vaulted data2
- vaulted_id: !vault |
- $ANSIBLE_VAULT;1.2;AES256;test1
- 36383733336533656264393332663131613335333332346439356164383935656234663631356430
- 3533353537343834333538356366376233326364613362640a623832636339363966336238393039
- 35316562626335306534356162623030613566306235623863373036626531346364626166656134
- 3063376436656635330a363636376131663362633731313964353061663661376638326461393736
- 3863
- vaulted_to_id: "{{data2|vault('test1@secret', vault_id='test1')}}"
-
- tasks:
- - name: check vaulting
- assert:
- that:
- - data|vault(password, salt=salt) == vaultedstring
- - "data|vault(password, salt=salt)|type_debug != 'AnsibleVaultEncryptedUnicode'"
- - "data|vault(password, salt=salt, wrap_object=True)|type_debug == 'AnsibleVaultEncryptedUnicode'"
-
- - name: check unvaulting
- assert:
- that:
- - vaultedstring|unvault(password) == data
- - vault|unvault(password) == data
- - vaulted_id|unvault('test1@secret', vault_id='test1')
- - vaulted_to_id|unvault('test1@secret', vault_id='test1')
diff --git a/test/integration/targets/filter_encryption/runme.sh b/test/integration/targets/filter_encryption/runme.sh
deleted file mode 100755
index 41b30b1..0000000
--- a/test/integration/targets/filter_encryption/runme.sh
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-set -eux
-
-ANSIBLE_GATHER_SUBSET='min' ansible-playbook base.yml "$@"
diff --git a/test/integration/targets/filter_encryption/tasks/main.yml b/test/integration/targets/filter_encryption/tasks/main.yml
new file mode 100644
index 0000000..4eb765d
--- /dev/null
+++ b/test/integration/targets/filter_encryption/tasks/main.yml
@@ -0,0 +1,19 @@
+- name: check vaulting
+ assert:
+ that:
+ - data1_plaintext|vault(data1_password, salt=data1_salt) == data1_vaulted_string_with_id
+ - data1_plaintext|vault(data1_password, salt=data1_salt)|type_debug != 'AnsibleVaultEncryptedUnicode'
+ - data1_plaintext|vault(data1_password, salt=data1_salt, wrap_object=True)|type_debug == 'AnsibleVaultEncryptedUnicode'
+
+- name: check round-trip without salt
+ assert:
+ that:
+ - data2_plaintext|vault(data2_password, vault_id=data2_vault_id)|unvault(data2_password, vault_id=data2_vault_id) == data2_plaintext
+
+- name: check unvaulting
+ assert:
+ that:
+ - data1_vaulted_string_with_id|unvault(data1_password) == data1_plaintext
+ - data1_vaulted|unvault(data1_password) == data1_plaintext
+ - data2_vaulted_with_id|unvault(data2_password, vault_id=data2_vault_id) == data2_plaintext
+ - data2_vaulted_string_with_id|unvault(data2_password, vault_id=data2_vault_id) == data2_plaintext
diff --git a/test/integration/targets/filter_encryption/vars/main.yml b/test/integration/targets/filter_encryption/vars/main.yml
new file mode 100644
index 0000000..ca672f5
--- /dev/null
+++ b/test/integration/targets/filter_encryption/vars/main.yml
@@ -0,0 +1,38 @@
+data1_salt: 7
+data1_password: test
+data1_plaintext: secret
+# value from template: {{ data1_plaintext | vault(data1_password, vault_id='filter_default', salt=data1_salt) }}
+data1_vaulted_string_with_id: |
+ $ANSIBLE_VAULT;1.2;AES256;filter_default
+ 33370a34333734353636633035656232613935353432656132646533346233326431346232616261
+ 6133383034376566366261316365633931356133633337396363370a376664386236313834326561
+ 6338373864623763613165366636633031303739
+data1_vaulted: !vault |
+ $ANSIBLE_VAULT;1.1;AES256
+ 33323332333033383335333533383338333333303339333733323339333833303334333133313339
+ 33373339333133323331333833373335333933323338333633343338333133343334333733383334
+ 33333335333433383337333133303339333433353332333333363339333733363335333233303330
+ 3337333733353331333633313335333733373334333733320a373938666533366165653830313163
+ 62386564343438653437333564383664646538653364343138303831613039313232636437336530
+ 3438376662373764650a633366646563386335623161646262366137393635633464333265613938
+ 6661
+
+data2_vault_id: test1
+data2_password: test1@secret
+data2_plaintext: 'foo: bar\n'
+# value from template: {{ data2_plaintext | vault(data2_password, vault_id=data2_vault_id) }}
+data2_vaulted_string_with_id: |
+ $ANSIBLE_VAULT;1.2;AES256;test1
+ 65383166333033626133363239373635393635353232316433386430316265316639663234326638
+ 6637623162613135623965386334313361383365326466340a316465653939333339393464623664
+ 32303038646437326134363662393038666538643065613136316361306132636231336233333362
+ 3665646531363138390a643530333038333936343262343638626535653564616537313635353633
+ 3865
+# value from template: {{ data2_plaintext | vault(data2_password, vault_id=data2_vault_id) }}
+data2_vaulted_with_id: !vault |
+ $ANSIBLE_VAULT;1.2;AES256;test1
+ 65383166333033626133363239373635393635353232316433386430316265316639663234326638
+ 6637623162613135623965386334313361383365326466340a316465653939333339393464623664
+ 32303038646437326134363662393038666538643065613136316361306132636231336233333362
+ 3665646531363138390a643530333038333936343262343638626535653564616537313635353633
+ 3865
diff --git a/test/integration/targets/find/aliases b/test/integration/targets/find/aliases
index cdd75ef..aa171eb 100644
--- a/test/integration/targets/find/aliases
+++ b/test/integration/targets/find/aliases
@@ -1,3 +1,4 @@
shippable/posix/group1
destructive
-needs/root \ No newline at end of file
+needs/root
+setup/always/setup_passlib_controller # required for setup_test_user
diff --git a/test/integration/targets/find/files/hello_world.gbk b/test/integration/targets/find/files/hello_world.gbk
new file mode 100644
index 0000000..8e3d158
--- /dev/null
+++ b/test/integration/targets/find/files/hello_world.gbk
@@ -0,0 +1 @@
+ÄãºÃÊÀ½ç
diff --git a/test/integration/targets/find/tasks/main.yml b/test/integration/targets/find/tasks/main.yml
index c526dc7..c1198ca 100644
--- a/test/integration/targets/find/tasks/main.yml
+++ b/test/integration/targets/find/tasks/main.yml
@@ -124,6 +124,7 @@
with_items:
- a.txt
- log.txt
+ - hello_world.gbk
- name: Ensure '$' only matches the true end of the file with read_whole_file, not a line
find:
@@ -195,6 +196,51 @@
that:
- no_match_line_boundaries.matched == 0
+- name: read a gbk file by utf-8
+ find:
+ paths: "{{ remote_tmp_dir_test }}"
+ patterns: "*.gbk"
+ contains: "你好世界"
+ encoding: "utf-8"
+ register: fail_to_read_wrong_encoding_file
+
+- debug: var=fail_to_read_wrong_encoding_file
+
+- assert:
+ that:
+ - fail_to_read_wrong_encoding_file.msg == 'Not all paths examined, check warnings for details'
+ - >-
+ fail_to_read_wrong_encoding_file.skipped_paths[remote_tmp_dir_test] ==
+ ("Failed to read the file %s/hello_world.gbk due to an encoding error. current encoding: utf-8" % (remote_tmp_dir_test))
+
+- name: read a gbk file by gbk
+ find:
+ paths: "{{ remote_tmp_dir_test }}"
+ encoding: "gbk"
+ patterns: "*.gbk"
+ contains: "你好世界"
+ register: success_to_read_right_encoding_file
+
+- debug: var=success_to_read_right_encoding_file
+
+- assert:
+ that:
+ - success_to_read_right_encoding_file.matched == 1
+
+- name: read a gbk file by non-exists encoding
+ find:
+ paths: "{{ remote_tmp_dir_test }}"
+ encoding: "idontexist"
+ patterns: "*.gbk"
+ contains: "你好世界"
+ register: fail_to_search_file_by_non_exists_encoding
+
+- debug: var=fail_to_search_file_by_non_exists_encoding
+
+- assert:
+ that:
+ - 'fail_to_search_file_by_non_exists_encoding.skipped_paths[remote_tmp_dir_test] == "unknown encoding: idontexist"'
+
- block:
- set_fact:
mypath: /idontexist{{lookup('pipe', 'mktemp')}}
@@ -221,8 +267,8 @@
- assert:
that:
- - total_contents.matched == 18
- - total_contents.examined == 18
+ - total_contents.matched == 19
+ - total_contents.examined == 19
- name: Get files and directories with depth
find:
@@ -234,10 +280,10 @@
- assert:
that:
- - contents_with_depth.matched == 8
+ - contents_with_depth.matched == 9
# dir contents are considered until the depth exceeds the requested depth
# there are 8 files/directories in the requested depth and 4 that exceed it by 1
- - contents_with_depth.examined == 12
+ - contents_with_depth.examined == 13
- name: Find files with depth
find:
@@ -248,10 +294,10 @@
- assert:
that:
- - files_with_depth.matched == 4
+ - files_with_depth.matched == 5
# dir contents are considered until the depth exceeds the requested depth
# there are 8 files/directories in the requested depth and 4 that exceed it by 1
- - files_with_depth.examined == 12
+ - files_with_depth.examined == 13
- name: exclude with regex
find:
diff --git a/test/integration/targets/fork_safe_stdio/callback_plugins/spewstdio.py b/test/integration/targets/fork_safe_stdio/callback_plugins/spewstdio.py
index 6ed6ef3..dba00a9 100644
--- a/test/integration/targets/fork_safe_stdio/callback_plugins/spewstdio.py
+++ b/test/integration/targets/fork_safe_stdio/callback_plugins/spewstdio.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import atexit
import os
import sys
diff --git a/test/integration/targets/fork_safe_stdio/run-with-pty.py b/test/integration/targets/fork_safe_stdio/run-with-pty.py
index 4639152..b4ccb7b 100755
--- a/test/integration/targets/fork_safe_stdio/run-with-pty.py
+++ b/test/integration/targets/fork_safe_stdio/run-with-pty.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""Run a command using a PTY."""
+from __future__ import annotations
import sys
diff --git a/test/integration/targets/fork_safe_stdio/vendored_pty.py b/test/integration/targets/fork_safe_stdio/vendored_pty.py
index bc70803..346bae3 100644
--- a/test/integration/targets/fork_safe_stdio/vendored_pty.py
+++ b/test/integration/targets/fork_safe_stdio/vendored_pty.py
@@ -7,6 +7,7 @@
# See: W. Richard Stevens. 1992. Advanced Programming in the
# UNIX Environment. Chapter 19.
# Author: Steen Lumholt -- with additions by Guido.
+from __future__ import annotations
from select import select
import os
diff --git a/test/integration/targets/gathering_facts/cache_plugins/none.py b/test/integration/targets/gathering_facts/cache_plugins/none.py
index 5681dee..715f7ae 100644
--- a/test/integration/targets/gathering_facts/cache_plugins/none.py
+++ b/test/integration/targets/gathering_facts/cache_plugins/none.py
@@ -3,8 +3,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.cache import BaseCacheModule
diff --git a/test/integration/targets/gathering_facts/collections/ansible_collections/cisco/ios/plugins/modules/ios_facts.py b/test/integration/targets/gathering_facts/collections/ansible_collections/cisco/ios/plugins/modules/ios_facts.py
index b79f794..8974181 100644
--- a/test/integration/targets/gathering_facts/collections/ansible_collections/cisco/ios/plugins/modules/ios_facts.py
+++ b/test/integration/targets/gathering_facts/collections/ansible_collections/cisco/ios/plugins/modules/ios_facts.py
@@ -1,4 +1,5 @@
#!/usr/bin/python
+from __future__ import annotations
DOCUMENTATION = """
---
diff --git a/test/integration/targets/gathering_facts/library/file_utils.py b/test/integration/targets/gathering_facts/library/file_utils.py
index 38fa926..29da29b 100644
--- a/test/integration/targets/gathering_facts/library/file_utils.py
+++ b/test/integration/targets/gathering_facts/library/file_utils.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.facts.utils import (
diff --git a/test/integration/targets/gathering_facts/test_run_once.yml b/test/integration/targets/gathering_facts/test_run_once.yml
index 37023b2..35591f2 100644
--- a/test/integration/targets/gathering_facts/test_run_once.yml
+++ b/test/integration/targets/gathering_facts/test_run_once.yml
@@ -24,7 +24,7 @@
- name: "Check that run_once doesn't prevent fact gathering (#39453)"
assert:
that: 'hostvars.facthost1.ansible_local.uuid != hostvars.facthost2.ansible_local.uuid'
- msg: "{{ 'Same value for ansible_local.uuid on both hosts: ' ~ hostvars.facthost1.ansible_local.uuid }}"
+ msg: "{{ 'Same value for ansible_local.uuid on both hosts: ' ~ hostvars.facthost1.ansible_local.uuid }}"
always:
- name: remove test local facts
file:
diff --git a/test/integration/targets/get_url/files/testserver.py b/test/integration/targets/get_url/files/testserver.py
index 24967d4..3a83724 100644
--- a/test/integration/targets/get_url/files/testserver.py
+++ b/test/integration/targets/get_url/files/testserver.py
@@ -1,23 +1,15 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
+import http.server
+import socketserver
import sys
if __name__ == '__main__':
- if sys.version_info[0] >= 3:
- import http.server
- import socketserver
- PORT = int(sys.argv[1])
+ PORT = int(sys.argv[1])
- class Handler(http.server.SimpleHTTPRequestHandler):
- pass
+ class Handler(http.server.SimpleHTTPRequestHandler):
+ pass
- Handler.extensions_map['.json'] = 'application/json'
- httpd = socketserver.TCPServer(("", PORT), Handler)
- httpd.serve_forever()
- else:
- import mimetypes
- mimetypes.init()
- mimetypes.add_type('application/json', '.json')
- import SimpleHTTPServer
- SimpleHTTPServer.test()
+ Handler.extensions_map['.json'] = 'application/json'
+ httpd = socketserver.TCPServer(("", PORT), Handler)
+ httpd.serve_forever()
diff --git a/test/integration/targets/get_url/tasks/hashlib.yml b/test/integration/targets/get_url/tasks/hashlib.yml
index cc50ad7..e67555e 100644
--- a/test/integration/targets/get_url/tasks/hashlib.yml
+++ b/test/integration/targets/get_url/tasks/hashlib.yml
@@ -17,4 +17,3 @@
loop: "{{ algorithms.keys() }}"
loop_control:
loop_var: algorithm
- when: ansible_python_version.startswith('3.') or not algorithm.startswith('sha3_')
diff --git a/test/integration/targets/get_url/tasks/main.yml b/test/integration/targets/get_url/tasks/main.yml
index c26cc08..ba1c933 100644
--- a/test/integration/targets/get_url/tasks/main.yml
+++ b/test/integration/targets/get_url/tasks/main.yml
@@ -667,6 +667,7 @@
environment:
KRB5_CONFIG: '{{ krb5_config }}'
KRB5CCNAME: FILE:{{ remote_tmp_dir }}/krb5.cc
+ OPENSSL_CONF: '{{ krb5_openssl_conf }}'
when: krb5_config is defined
- name: Test ciphers
diff --git a/test/integration/targets/group/files/get_free_gid.py b/test/integration/targets/group/files/get_free_gid.py
index 4c07b5e..155254d 100644
--- a/test/integration/targets/group/files/get_free_gid.py
+++ b/test/integration/targets/group/files/get_free_gid.py
@@ -1,6 +1,5 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import grp
diff --git a/test/integration/targets/group/files/get_gid_for_group.py b/test/integration/targets/group/files/get_gid_for_group.py
index 5a8cc41..ce35739 100644
--- a/test/integration/targets/group/files/get_gid_for_group.py
+++ b/test/integration/targets/group/files/get_gid_for_group.py
@@ -1,6 +1,5 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import grp
import sys
diff --git a/test/integration/targets/handlers/collections/ansible_collections/ns/col/roles/test_handlers_listen/handlers/main.yml b/test/integration/targets/handlers/collections/ansible_collections/ns/col/roles/test_handlers_listen/handlers/main.yml
new file mode 100644
index 0000000..0658f7e
--- /dev/null
+++ b/test/integration/targets/handlers/collections/ansible_collections/ns/col/roles/test_handlers_listen/handlers/main.yml
@@ -0,0 +1,4 @@
+- name: test notifying listen namespaced by collection + role
+ set_fact:
+ notify_listen_in_specific_collection_role: True
+ listen: notify_specific_collection_role_listen
diff --git a/test/integration/targets/handlers/force_handlers_blocks_81533-1.yml b/test/integration/targets/handlers/force_handlers_blocks_81533-1.yml
new file mode 100644
index 0000000..20605e4
--- /dev/null
+++ b/test/integration/targets/handlers/force_handlers_blocks_81533-1.yml
@@ -0,0 +1,16 @@
+- hosts: A,B
+ gather_facts: false
+ force_handlers: true
+ tasks:
+ - fail:
+ when: inventory_hostname == "A"
+
+ - run_once: true
+ block:
+ - debug:
+ msg: task1
+ - debug:
+ msg: task2
+
+ - debug:
+ msg: hosts_left
diff --git a/test/integration/targets/handlers/force_handlers_blocks_81533-2.yml b/test/integration/targets/handlers/force_handlers_blocks_81533-2.yml
new file mode 100644
index 0000000..4284a37
--- /dev/null
+++ b/test/integration/targets/handlers/force_handlers_blocks_81533-2.yml
@@ -0,0 +1,12 @@
+- hosts: A,B
+ gather_facts: false
+ force_handlers: true
+ tasks:
+ - fail:
+ when: inventory_hostname == "A"
+
+ - meta: clear_host_errors
+ when: false
+
+ - debug:
+ msg: hosts_left
diff --git a/test/integration/targets/handlers/handlers_lockstep_82307.yml b/test/integration/targets/handlers/handlers_lockstep_82307.yml
new file mode 100644
index 0000000..f7cf757
--- /dev/null
+++ b/test/integration/targets/handlers/handlers_lockstep_82307.yml
@@ -0,0 +1,25 @@
+- hosts: A,B
+ gather_facts: false
+ tasks:
+ - block:
+ - command: echo
+ notify:
+ - handler1
+ - handler2
+
+ - fail:
+ when: inventory_hostname == "B"
+
+ - meta: flush_handlers
+ always:
+ - name: always
+ debug:
+ msg: always
+ handlers:
+ - name: handler1
+ debug:
+ msg: handler1
+
+ - name: handler2
+ debug:
+ msg: handler2
diff --git a/test/integration/targets/handlers/roles/test_handlers_listen/handlers/main.yml b/test/integration/targets/handlers/roles/test_handlers_listen/handlers/main.yml
index 3bfd82a..d5cdbac 100644
--- a/test/integration/targets/handlers/roles/test_handlers_listen/handlers/main.yml
+++ b/test/integration/targets/handlers/roles/test_handlers_listen/handlers/main.yml
@@ -8,3 +8,8 @@
set_fact:
notify_listen_in_role_4: True
listen: notify_listen_in_role
+
+- name: test notifying listen namespaced by the role
+ set_fact:
+ notify_listen_in_specific_role: True
+ listen: notify_specific_role_listen
diff --git a/test/integration/targets/handlers/runme.sh b/test/integration/targets/handlers/runme.sh
index 368ca44..9250fc8 100755
--- a/test/integration/targets/handlers/runme.sh
+++ b/test/integration/targets/handlers/runme.sh
@@ -202,9 +202,20 @@ ansible-playbook test_include_tasks_in_include_role.yml "$@" 2>&1 | tee out.txt
ansible-playbook test_run_once.yml -i inventory.handlers "$@" 2>&1 | tee out.txt
[ "$(grep out.txt -ce 'handler ran once')" = "1" ]
-ansible-playbook 82241.yml -i inventory.handlers "$@" 2>&1 | tee out.txt
-[ "$(grep out.txt -ce 'included_task_from_tasks_dir')" = "1" ]
+ansible-playbook force_handlers_blocks_81533-1.yml -i inventory.handlers "$@" 2>&1 | tee out.txt
+[ "$(grep out.txt -ce 'task1')" = "1" ]
+[ "$(grep out.txt -ce 'task2')" = "1" ]
+[ "$(grep out.txt -ce 'hosts_left')" = "1" ]
+
+ansible-playbook force_handlers_blocks_81533-2.yml -i inventory.handlers "$@" 2>&1 | tee out.txt
+[ "$(grep out.txt -ce 'hosts_left')" = "1" ]
ansible-playbook nested_flush_handlers_failure_force.yml -i inventory.handlers "$@" 2>&1 | tee out.txt
[ "$(grep out.txt -ce 'flush_handlers_rescued')" = "1" ]
[ "$(grep out.txt -ce 'flush_handlers_always')" = "2" ]
+
+ansible-playbook 82241.yml -i inventory.handlers "$@" 2>&1 | tee out.txt
+[ "$(grep out.txt -ce 'included_task_from_tasks_dir')" = "1" ]
+
+ansible-playbook handlers_lockstep_82307.yml -i inventory.handlers "$@" 2>&1 | tee out.txt
+[ "$(grep out.txt -ce 'TASK \[handler2\]')" = "0" ]
diff --git a/test/integration/targets/handlers/test_handlers_listen.yml b/test/integration/targets/handlers/test_handlers_listen.yml
index dd2cd87..16167a3 100644
--- a/test/integration/targets/handlers/test_handlers_listen.yml
+++ b/test/integration/targets/handlers/test_handlers_listen.yml
@@ -99,6 +99,7 @@
gather_facts: false
roles:
- role: test_handlers_listen
+ - role: ns.col.test_handlers_listen
tasks:
- name: test notify handlers listen in roles
command: uptime
@@ -113,6 +114,20 @@
- "notify_listen_ran_4_3 is defined"
- "notify_listen_in_role_4 is defined"
- "notify_listen_from_role_4 is defined"
+ - name: test notifying handlers using the role name prefix
+ command: uptime
+ notify:
+ - 'test_handlers_listen : notify_specific_role_listen'
+ - 'test_handlers_listen : notify_specific_collection_role_listen'
+ - meta: flush_handlers
+ - assert:
+ that:
+ - notify_listen_in_specific_collection_role is defined
+ - notify_listen_in_specific_role is defined
+ - name: test notifying the collection listener by the role's FQCN also works
+ command: uptime
+ notify:
+ - 'ns.col.test_handlers_listen : notify_specific_collection_role_listen'
handlers:
- name: notify_listen_ran_4_1
set_fact:
diff --git a/test/integration/targets/ignore_unreachable/fake_connectors/bad_exec.py b/test/integration/targets/ignore_unreachable/fake_connectors/bad_exec.py
index 0d8c385..0f350db 100644
--- a/test/integration/targets/ignore_unreachable/fake_connectors/bad_exec.py
+++ b/test/integration/targets/ignore_unreachable/fake_connectors/bad_exec.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import ansible.plugins.connection.local as ansible_local
from ansible.errors import AnsibleConnectionFailure
diff --git a/test/integration/targets/ignore_unreachable/fake_connectors/bad_put_file.py b/test/integration/targets/ignore_unreachable/fake_connectors/bad_put_file.py
index d4131f4..99a1c1b 100644
--- a/test/integration/targets/ignore_unreachable/fake_connectors/bad_put_file.py
+++ b/test/integration/targets/ignore_unreachable/fake_connectors/bad_put_file.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import ansible.plugins.connection.local as ansible_local
from ansible.errors import AnsibleConnectionFailure
diff --git a/test/integration/targets/include_import/playbook/sub_playbook/library/helloworld.py b/test/integration/targets/include_import/playbook/sub_playbook/library/helloworld.py
index 0ebe690..7fc1da9 100644
--- a/test/integration/targets/include_import/playbook/sub_playbook/library/helloworld.py
+++ b/test/integration/targets/include_import/playbook/sub_playbook/library/helloworld.py
@@ -14,8 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/include_import/runme.sh b/test/integration/targets/include_import/runme.sh
index d85b22d..12ee15b 100755
--- a/test/integration/targets/include_import/runme.sh
+++ b/test/integration/targets/include_import/runme.sh
@@ -127,7 +127,7 @@ test "$(ansible-playbook tasks/test_dynamic_allow_dup.yml --tags import | grep -
# test templating public, allow_duplicates, and rolespec_validate
ansible-playbook tasks/test_templating_IncludeRole_FA.yml 2>&1 | tee IncludeRole_FA_template.out
-test "$(grep -c 'ok=4' IncludeRole_FA_template.out)" = 1
+test "$(grep -c 'ok=6' IncludeRole_FA_template.out)" = 1
test "$(grep -c 'failed=0' IncludeRole_FA_template.out)" = 1
# https://github.com/ansible/ansible/issues/66764
diff --git a/test/integration/targets/include_import/tasks/task_ansible_loop_index_var.yml b/test/integration/targets/include_import/tasks/task_ansible_loop_index_var.yml
new file mode 100644
index 0000000..121227e
--- /dev/null
+++ b/test/integration/targets/include_import/tasks/task_ansible_loop_index_var.yml
@@ -0,0 +1,5 @@
+- name: Assert ansible_loop_var and ansible_index_var are defined with correct values
+ assert:
+ that:
+ - ansible_loop_var is defined and ansible_index_var is defined
+ - ansible_loop_var == "should_show_up_loop" and ansible_index_var == "should_show_up_index"
diff --git a/test/integration/targets/include_import/tasks/test_include_tasks.yml b/test/integration/targets/include_import/tasks/test_include_tasks.yml
index ebe2273..e3ed4c0 100644
--- a/test/integration/targets/include_import/tasks/test_include_tasks.yml
+++ b/test/integration/targets/include_import/tasks/test_include_tasks.yml
@@ -42,3 +42,10 @@
- name: include_tasks + action
action: include_tasks tasks1.yml
+
+ - name: Test ansible_loop_var and ansible_index_var within included_tasks
+ include_tasks: task_ansible_loop_index_var.yml
+ loop: ['does not matter', 'dont care']
+ loop_control:
+ loop_var: should_show_up_loop
+ index_var: should_show_up_index
diff --git a/test/integration/targets/include_vars/tasks/main.yml b/test/integration/targets/include_vars/tasks/main.yml
index 97636d9..edee91f 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
@@ -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,7 +88,7 @@
that:
- "testing == 789"
- "base_dir == 'environments/development'"
- - "include_without_webapp.ansible_included_var_files | length == 4"
+ - "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(' ')"
@@ -104,7 +104,7 @@
- "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(' ')"
diff --git a/test/integration/targets/infra/library/test.py b/test/integration/targets/infra/library/test.py
index dbc4b61..ad8929b 100644
--- a/test/integration/targets/infra/library/test.py
+++ b/test/integration/targets/infra/library/test.py
@@ -1,8 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/interpreter_discovery_python/library/test_echo_module.py b/test/integration/targets/interpreter_discovery_python/library/test_echo_module.py
index 7317921..b394f9d 100644
--- a/test/integration/targets/interpreter_discovery_python/library/test_echo_module.py
+++ b/test/integration/targets/interpreter_discovery_python/library/test_echo_module.py
@@ -5,8 +5,7 @@
# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import sys
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/interpreter_discovery_python/tasks/main.yml b/test/integration/targets/interpreter_discovery_python/tasks/main.yml
index 7e9b2e8..13c11d9 100644
--- a/test/integration/targets/interpreter_discovery_python/tasks/main.yml
+++ b/test/integration/targets/interpreter_discovery_python/tasks/main.yml
@@ -141,8 +141,6 @@
- name: debian assertions
assert:
that:
- # Debian 8 and older
- - auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python' and distro_version is version('8', '<=') or distro_version is version('8', '>')
# Debian 10 and newer
- auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python3' and distro_version is version('10', '>=') or distro_version is version('10', '<')
when: distro == 'debian'
@@ -150,27 +148,21 @@
- name: fedora assertions
assert:
that:
- - auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python3'
+ - "'/bin/python3' in auto_out.ansible_facts.discovered_interpreter_python"
when: distro == 'fedora' and distro_version is version('23', '>=')
- name: rhel assertions
assert:
that:
- # rhel 6/7
- - (auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python' and distro_major_version is version('8','<')) or distro_major_version is version('8','>=')
- # rhel 8
- - (auto_out.ansible_facts.discovered_interpreter_python == '/usr/libexec/platform-python' and distro_major_version is version('8','==')) or distro_major_version is version('8','!=')
# rhel 9
- - (auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python3' and distro_major_version is version('9','==')) or distro_major_version is version('9','!=')
+ - ('/bin/python3' in auto_out.ansible_facts.discovered_interpreter_python and distro_major_version is version('9','==')) or distro_major_version is version('9','!=')
when: distro == 'redhat'
- name: ubuntu assertions
assert:
that:
- # ubuntu < 16
- - (auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python' and distro_version is version('16.04','<')) or distro_version is version('16.04','>=')
# ubuntu >= 16
- - (auto_out.ansible_facts.discovered_interpreter_python == '/usr/bin/python3' and distro_version is version('16.04','>=')) or distro_version is version('16.04','<')
+ - ('/bin/python3' in auto_out.ansible_facts.discovered_interpreter_python and distro_version is version('16.04','>=')) or distro_version is version('16.04','<')
when: distro == 'ubuntu'
- name: mac assertions
diff --git a/test/integration/targets/inventory/inventory_plugins/contructed_with_hostvars.py b/test/integration/targets/inventory/inventory_plugins/contructed_with_hostvars.py
index 43cad4f..8e179eb 100644
--- a/test/integration/targets/inventory/inventory_plugins/contructed_with_hostvars.py
+++ b/test/integration/targets/inventory/inventory_plugins/contructed_with_hostvars.py
@@ -1,8 +1,7 @@
# Copyright (c) 2022 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
name: constructed_with_hostvars
diff --git a/test/integration/targets/inventory_cache/plugins/inventory/cache_host.py b/test/integration/targets/inventory_cache/plugins/inventory/cache_host.py
index 628aba1..6c93f03 100644
--- a/test/integration/targets/inventory_cache/plugins/inventory/cache_host.py
+++ b/test/integration/targets/inventory_cache/plugins/inventory/cache_host.py
@@ -1,8 +1,7 @@
# Copyright (c) 2021 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
inventory: cache_host
diff --git a/test/integration/targets/inventory_cache/plugins/inventory/exercise_cache.py b/test/integration/targets/inventory_cache/plugins/inventory/exercise_cache.py
index cca2aa0..04afd0e 100644
--- a/test/integration/targets/inventory_cache/plugins/inventory/exercise_cache.py
+++ b/test/integration/targets/inventory_cache/plugins/inventory/exercise_cache.py
@@ -1,8 +1,7 @@
# Copyright (c) 2022 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
inventory: exercise_cache
diff --git a/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/bad_collection_filter.py b/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/bad_collection_filter.py
index 3666953..26af84b 100644
--- a/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/bad_collection_filter.py
+++ b/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/bad_collection_filter.py
@@ -1,9 +1,7 @@
# Copyright (c) 2021 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class FilterModule:
diff --git a/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/bad_collection_filter2.py b/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/bad_collection_filter2.py
index 96e726a..e039c8c 100644
--- a/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/bad_collection_filter2.py
+++ b/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/bad_collection_filter2.py
@@ -1,9 +1,7 @@
# Copyright (c) 2021 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class FilterModule:
diff --git a/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/good_collection_filter.py b/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/good_collection_filter.py
index e2e7ffc..e43c984 100644
--- a/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/good_collection_filter.py
+++ b/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/filter/good_collection_filter.py
@@ -1,9 +1,7 @@
# Copyright (c) 2021 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class FilterModule:
diff --git a/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/test/bad_collection_test.py b/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/test/bad_collection_test.py
index 9fce558..3c854ba 100644
--- a/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/test/bad_collection_test.py
+++ b/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/test/bad_collection_test.py
@@ -1,9 +1,7 @@
# Copyright (c) 2021 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class TestModule:
diff --git a/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/test/good_collection_test.py b/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/test/good_collection_test.py
index a4ca2ff..d13daca 100644
--- a/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/test/good_collection_test.py
+++ b/test/integration/targets/jinja_plugins/collections/ansible_collections/foo/bar/plugins/test/good_collection_test.py
@@ -1,9 +1,7 @@
# Copyright (c) 2021 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class TestModule:
diff --git a/test/integration/targets/jinja_plugins/filter_plugins/bad_filter.py b/test/integration/targets/jinja_plugins/filter_plugins/bad_filter.py
index eebf39c..5dd653f 100644
--- a/test/integration/targets/jinja_plugins/filter_plugins/bad_filter.py
+++ b/test/integration/targets/jinja_plugins/filter_plugins/bad_filter.py
@@ -1,9 +1,7 @@
# Copyright (c) 2021 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class FilterModule:
diff --git a/test/integration/targets/jinja_plugins/filter_plugins/good_filter.py b/test/integration/targets/jinja_plugins/filter_plugins/good_filter.py
index e2e7ffc..e43c984 100644
--- a/test/integration/targets/jinja_plugins/filter_plugins/good_filter.py
+++ b/test/integration/targets/jinja_plugins/filter_plugins/good_filter.py
@@ -1,9 +1,7 @@
# Copyright (c) 2021 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class FilterModule:
diff --git a/test/integration/targets/jinja_plugins/test_plugins/bad_test.py b/test/integration/targets/jinja_plugins/test_plugins/bad_test.py
index 0cc7a5a..251d5ef 100644
--- a/test/integration/targets/jinja_plugins/test_plugins/bad_test.py
+++ b/test/integration/targets/jinja_plugins/test_plugins/bad_test.py
@@ -1,9 +1,7 @@
# Copyright (c) 2021 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class TestModule:
diff --git a/test/integration/targets/jinja_plugins/test_plugins/good_test.py b/test/integration/targets/jinja_plugins/test_plugins/good_test.py
index a4ca2ff..d13daca 100644
--- a/test/integration/targets/jinja_plugins/test_plugins/good_test.py
+++ b/test/integration/targets/jinja_plugins/test_plugins/good_test.py
@@ -1,9 +1,7 @@
# Copyright (c) 2021 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class TestModule:
diff --git a/test/integration/targets/keyword_inheritance/aliases b/test/integration/targets/keyword_inheritance/aliases
index a6a3341..01741b9 100644
--- a/test/integration/targets/keyword_inheritance/aliases
+++ b/test/integration/targets/keyword_inheritance/aliases
@@ -1,3 +1,4 @@
shippable/posix/group4
context/controller
needs/target/setup_test_user
+setup/always/setup_passlib_controller # required for setup_test_user
diff --git a/test/integration/targets/known_hosts/defaults/main.yml b/test/integration/targets/known_hosts/defaults/main.yml
index cd43843..849fb4b 100644
--- a/test/integration/targets/known_hosts/defaults/main.yml
+++ b/test/integration/targets/known_hosts/defaults/main.yml
@@ -1,6 +1,11 @@
---
example_org_rsa_key: >
example.org ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAglyZmHHWskQ9wkh8LYbIqzvg99/oloneH7BaZ02ripJUy/2Zynv4tgUfm9fdXvAb1XXCEuTRnts9FBer87+voU0FPRgx3CfY9Sgr0FspUjnm4lqs53FIab1psddAaS7/F7lrnjl6VqBtPwMRQZG7qlml5uogGJwYJHxX0PGtsdoTJsM=
-
example_org_ed25519_key: >
example.org ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIzlnSq5ESxLgW0avvPk3j7zLV59hcAPkxrMNdnZMKP2
+host_example_com_ed25519_key: >
+ host.example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFp8VtD59XAcxkj1qbfCtB1in9nm5WiipORjtVJUBA6I
+example_com_ed25519_ca: >
+ @cert-authority *.example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPx6KAHnQhaWdYQoaclJMWfneZckvYOkZ32gUJO1zzJK
+host_example_com_ed25519_signedhost: >
+ host.example.com ssh-ed25519-cert-v01@openssh.com AAAAIHNzaC1lZDI1NTE5LWNlcnQtdjAxQG9wZW5zc2guY29tAAAAIHgrfzePvYcPiRDh/3yKt2sJBk6mftlLGPpAlgveY8amAAAAIE/humEfyhaw5kawq/RC8tOoVJFgu6v+AYV2koz4bULNAAAAAAAAAAAAAAACAAAAFGhvc3QuZXhhbXBsZS5jb20ucHViAAAAFAAAABBob3N0LmV4YW1wbGUuY29tAAAAAAAAAAD//////////wAAAAAAAAAAAAAAAAAAADMAAAALc3NoLWVkMjU1MTkAAAAg/HooAedCFpZ1hChpyUkxZ+d5lyS9g6RnfaBQk7XPMkoAAABTAAAAC3NzaC1lZDI1NTE5AAAAQPrSxFZ57dZvHy+ZqhudHBj5C1xU/aiAcMjbpyg3PwR/T/ym8B299uyhRj4g6wbby389xuTFkIYYgGlzh1vAkA0=
diff --git a/test/integration/targets/known_hosts/files/existing_known_hosts b/test/integration/targets/known_hosts/files/existing_known_hosts
index 2564f40..7aac98f 100644
--- a/test/integration/targets/known_hosts/files/existing_known_hosts
+++ b/test/integration/targets/known_hosts/files/existing_known_hosts
@@ -2,4 +2,5 @@ example.com ssh-dss AAAAB3NzaC1kc3MAAACBALT8YHxZ59d8yX4oQNPbpdK9AMPRQGKFY9X13S2f
|1|d71/U7CbOH3Su+d2zxlbmiNfXtI=|g2YSPAVoK7bmg16FCOOPKTZe2BM= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
|1|L0TqxOhAVh6mLZ2lbHdTv3owun0=|vn0La5pbHNxin3XzQQdvaOulvVU= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCNLCAA/SjVF3jkmlAlkgh+GtZdgxtusHaK66fcA7XSgCpQOdri1dGmND6pQDGwsxiKMy4Ou1GB2DR4N0G9T5E8=
|1|WPo7yAOdlQKLSuRatNJCmDoga0k=|D/QybGglKokWuEQUe9Okpy5uSh0= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCNLCAA/SjVF3jkmlAlkgh+GtZdgxtusHaK66fcA7XSgCpQOdri1dGmND6pQDGwsxiKMy4Ou1GB2DR4N0G9T5E8=
+@cert-authority *.example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDXh1gk2xgS2MekPvo7ZEKiOT7HoyvOAzai2GqoLXGHO
# example.net ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIM6OSqweGdPdQ/metQaf738AdN3P+itYp1AypOTgXkyj root@localhost
diff --git a/test/integration/targets/known_hosts/tasks/main.yml b/test/integration/targets/known_hosts/tasks/main.yml
index d5ffec4..2e5ecc7 100644
--- a/test/integration/targets/known_hosts/tasks/main.yml
+++ b/test/integration/targets/known_hosts/tasks/main.yml
@@ -57,7 +57,8 @@
that:
- 'result is changed'
- 'known_hosts.stdout_lines[0].startswith("example.com")'
- - 'known_hosts.stdout_lines[4].startswith("# example.net")'
+ - 'known_hosts.stdout_lines[4].startswith("@cert-authority")'
+ - 'known_hosts.stdout_lines[5].startswith("# example.net")'
- 'known_hosts.stdout_lines[-1].strip() == example_org_rsa_key.strip()'
# test idempotence of addition
@@ -222,7 +223,7 @@
that:
- 'result is changed'
- 'known_hosts_v5.stdout_lines[0].startswith("example.com")'
- - 'known_hosts_v5.stdout_lines[4].startswith("# example.net")'
+ - 'known_hosts_v5.stdout_lines[5].startswith("# example.net")'
- 'known_hosts_v5.stdout_lines[-1].strip().startswith("|1|")'
- 'known_hosts_v5.stdout_lines[-1].strip().endswith(example_org_rsa_key.strip().split()[-1])'
@@ -342,7 +343,7 @@
- name: assert the plaintext host is there
assert:
that:
- - 'known_hosts_v10.stdout_lines[5].strip() == example_org_rsa_key.strip()'
+ - 'known_hosts_v10.stdout_lines[6].strip() == example_org_rsa_key.strip()'
# ... and remove the host again for the next test
@@ -378,6 +379,105 @@
that:
- 'known_hosts_v11.stdout_lines[-1].strip().endswith("RANDOM=")'
+- name: add the ed25519 host key
+ known_hosts:
+ name: host.example.com
+ key: "{{ host_example_com_ed25519_key }}"
+ state: present
+ path: "{{remote_tmp_dir}}/known_hosts"
+ register: result
+
+- name: get the file content
+ command: "cat {{remote_tmp_dir}}/known_hosts"
+ register: known_hosts_v12
+
+- name: assert that the key was added and ordering preserved
+ assert:
+ that:
+ - 'result is changed'
+ - 'known_hosts_v12.stdout_lines[0].startswith("example.com")'
+ - 'known_hosts_v12.stdout_lines[4].startswith("@cert-authority")'
+ - 'known_hosts_v12.stdout_lines[5].startswith("# example.net")'
+ - 'known_hosts_v12.stdout_lines[-1].strip() == host_example_com_ed25519_key.strip()'
+
+- name: add the ed25519 ca key
+ known_hosts:
+ name: '*.example.com'
+ key: "{{ example_com_ed25519_ca }}"
+ state: present
+ path: "{{remote_tmp_dir}}/known_hosts"
+ register: result
+
+- name: get the file content
+ command: "cat {{remote_tmp_dir}}/known_hosts"
+ register: known_hosts_v13
+
+- name: assert that the key was added and ordering preserved
+ assert:
+ that:
+ - 'result is changed'
+ - 'known_hosts_v13.stdout_lines[0].startswith("example.com")'
+ - 'known_hosts_v13.stdout_lines[4].startswith("@cert-authority")'
+ - 'known_hosts_v13.stdout_lines[5].startswith("# example.net")'
+ - 'known_hosts_v13.stdout_lines[-1].strip() == example_com_ed25519_ca.strip()'
+
+- name: Remove the ed25519 ca key
+ known_hosts:
+ name: '*.example.com'
+ key: "{{ example_com_ed25519_ca }}"
+ state: absent
+ path: "{{remote_tmp_dir}}/known_hosts"
+ register: result
+
+- name: get the file content
+ command: "cat {{remote_tmp_dir}}/known_hosts"
+ register: known_hosts_v14
+
+- name: assert that the key was removed and ordering preserved
+ assert:
+ that:
+ - 'result is changed'
+ - 'known_hosts_v12.stdout == known_hosts_v14.stdout'
+
+- name: add the revoked ed25519 host key
+ known_hosts:
+ name: 'host.example.com'
+ key: "@revoked {{ host_example_com_ed25519_signedhost }}"
+ state: present
+ path: "{{remote_tmp_dir}}/known_hosts"
+ register: result
+
+- name: get the file content
+ command: "cat {{remote_tmp_dir}}/known_hosts"
+ register: known_hosts_v15
+
+- name: assert that the key was added and ordering preserved
+ assert:
+ that:
+ - 'result is changed'
+ - 'known_hosts_v15.stdout_lines[0].startswith("example.com")'
+ - 'known_hosts_v15.stdout_lines[4].startswith("@cert-authority")'
+ - 'known_hosts_v15.stdout_lines[5].startswith("# example.net")'
+ - 'known_hosts_v15.stdout_lines[-1].strip() == "@revoked " ~ host_example_com_ed25519_signedhost.strip()'
+
+- name: remove the revoked ed25519 host key
+ known_hosts:
+ name: 'host.example.com'
+ key: "@revoked {{ host_example_com_ed25519_signedhost }}"
+ state: absent
+ path: "{{remote_tmp_dir}}/known_hosts"
+ register: result
+
+- name: get the file content
+ command: "cat {{remote_tmp_dir}}/known_hosts"
+ register: known_hosts_v16
+
+- name: assert that the key was removed and ordering preserved
+ assert:
+ that:
+ - 'result is changed'
+ - 'known_hosts_v12.stdout == known_hosts_v16.stdout'
+
# test errors
- name: Try using a comma separated list of hosts
diff --git a/test/integration/targets/lineinfile/aliases b/test/integration/targets/lineinfile/aliases
index 765b70d..ca7c912 100644
--- a/test/integration/targets/lineinfile/aliases
+++ b/test/integration/targets/lineinfile/aliases
@@ -1 +1,2 @@
shippable/posix/group2
+destructive
diff --git a/test/integration/targets/lineinfile/tasks/acls.yml b/test/integration/targets/lineinfile/tasks/acls.yml
new file mode 100644
index 0000000..1be6ecb
--- /dev/null
+++ b/test/integration/targets/lineinfile/tasks/acls.yml
@@ -0,0 +1,54 @@
+- block:
+ - name: Install the acl package on Ubuntu
+ apt:
+ name: acl
+ when: ansible_distribution in ('Ubuntu')
+ register: setup_acl
+
+ - name: Create file
+ copy:
+ content: "TEST"
+ mode: 0644
+ dest: "~/test.txt"
+
+ - shell: setfacl -m nobody:rwx ~/test.txt
+
+ - shell: getfacl ~/test.txt
+ register: acls
+
+ - name: Check that permissions match with the copy mode and setfacl command
+ assert:
+ that:
+ - "'user::rw-' in acls.stdout_lines"
+ - "'user:nobody:rwx' in acls.stdout_lines"
+ - "'group::r--' in acls.stdout_lines"
+ - "'other::r--' in acls.stdout_lines"
+
+ - name: test atomic_move via lineinfile doesn't delete extended acls
+ lineinfile:
+ path: "~/test.txt"
+ regexp: "TEST"
+ line: "UPDATE"
+
+ - shell: getfacl ~/test.txt
+ register: acls
+
+ - name: Validate the acls are unmodified
+ assert:
+ that:
+ - "'user::rw-' in acls.stdout_lines"
+ - "'user:nobody:rwx' in acls.stdout_lines"
+ - "'group::r--' in acls.stdout_lines"
+ - "'other::r--' in acls.stdout_lines"
+
+ always:
+ - name: Remove the acl package on Ubuntu
+ apt:
+ name: acl
+ state: absent
+ when: setup_acl is changed
+
+ - name: Clean up
+ file:
+ path: "~/test.txt"
+ state: absent
diff --git a/test/integration/targets/lineinfile/tasks/main.yml b/test/integration/targets/lineinfile/tasks/main.yml
index 3d4678c..1914920 100644
--- a/test/integration/targets/lineinfile/tasks/main.yml
+++ b/test/integration/targets/lineinfile/tasks/main.yml
@@ -258,6 +258,27 @@
that:
- "result.stat.checksum == 'd4eeb07bdebab2d1cdb3ec4a3635afa2618ad4ea'"
+- name: try to remove the middle line again
+ lineinfile:
+ dest: "{{ remote_tmp_dir }}/test.txt"
+ state: absent
+ regexp: "^This is line 3$"
+ register: result
+
+- name: assert no change was made
+ assert:
+ that: result is not changed
+
+- name: use stat to verify no change was made
+ stat:
+ path: "{{ remote_tmp_dir }}/test.txt"
+ register: result
+
+- name: assert test checksum matches after the middle line was removed
+ assert:
+ that:
+ - "result.stat.checksum == 'd4eeb07bdebab2d1cdb3ec4a3635afa2618ad4ea'"
+
- name: run a validation script that succeeds
lineinfile:
dest: "{{ remote_tmp_dir }}/test.txt"
@@ -944,9 +965,6 @@
The search string is an empty string, which will match every line in the file.
This may have unintended consequences, such as replacing the last line in the file rather than appending.
-- name: meta
- meta: end_play
-
###################################################################
## Issue #58923
## Using firstmatch with insertafter and ensure multiple lines are not inserted
@@ -1397,3 +1415,34 @@
- testend1 is changed
- testend2 is changed
- testend_file.stat.checksum == 'ef36116966836ce04f6b249fd1837706acae4e19'
+
+- name: Integration test for issue 76727
+ block:
+ - name: Create a symbolic link for the test file
+ file:
+ src: "{{ remote_tmp_dir }}/test.txt"
+ dest: "{{ remote_tmp_dir }}/test-76727.txt"
+ state: link
+
+ - name: Insert a line and back it up
+ lineinfile:
+ dest: "{{ remote_tmp_dir }}/test-76727.txt"
+ state: present
+ line: "#Line for issue 76727"
+ backup: yes
+ register: result1
+
+ - name: Stat the backup file
+ stat:
+ path: "{{ result1.backup }}"
+ register: result2
+
+ - name: Assert that the line was inserted and backup is created
+ assert:
+ that:
+ - result1 is changed
+ - result2.stat.exists
+
+- name: Integration test for issue 72929
+ import_tasks: acls.yml
+ when: ansible_system == 'Linux'
diff --git a/test/integration/targets/lookup_csvfile/tasks/main.yml b/test/integration/targets/lookup_csvfile/tasks/main.yml
index 758da71..370dc05 100644
--- a/test/integration/targets/lookup_csvfile/tasks/main.yml
+++ b/test/integration/targets/lookup_csvfile/tasks/main.yml
@@ -41,6 +41,7 @@
assert:
that:
- lookup('csvfile', 'Smith', file='people.csv', delimiter=',', col=1) == "Jane"
+ - lookup('csvfile', 'Jane', file='people.csv', delimiter=',', col=0, keycol=1) == "Smith"
- lookup('csvfile', 'German von Lastname file=people.csv delimiter=, col=1') == "Demo"
- name: Check tab-separated file
diff --git a/test/integration/targets/lookup_first_found/tasks/main.yml b/test/integration/targets/lookup_first_found/tasks/main.yml
index ba248bd..cae4f84 100644
--- a/test/integration/targets/lookup_first_found/tasks/main.yml
+++ b/test/integration/targets/lookup_first_found/tasks/main.yml
@@ -147,3 +147,8 @@
- ishouldnotbefound.yml
paths:
- "{{role_path}}/vars"
+
+- name: Make sure skip works in 'mixed' argument passing
+ assert:
+ that:
+ - q('first_found', ['/nonexistant'], skip=True) == []
diff --git a/test/integration/targets/lookup_password/aliases b/test/integration/targets/lookup_password/aliases
index b598321..cf6140f 100644
--- a/test/integration/targets/lookup_password/aliases
+++ b/test/integration/targets/lookup_password/aliases
@@ -1 +1,2 @@
shippable/posix/group3
+setup/always/setup_passlib_controller # required for setup_test_user
diff --git a/test/integration/targets/lookup_password/runme.sh b/test/integration/targets/lookup_password/runme.sh
index a3637a7..d1a1293 100755
--- a/test/integration/targets/lookup_password/runme.sh
+++ b/test/integration/targets/lookup_password/runme.sh
@@ -4,8 +4,4 @@ set -eux
source virtualenv.sh
-# Requirements have to be installed prior to running ansible-playbook
-# because plugins and requirements are loaded before the task runs
-pip install passlib
-
ANSIBLE_ROLES_PATH=../ ansible-playbook runme.yml -e "output_dir=${OUTPUT_DIR}" "$@"
diff --git a/test/integration/targets/lookup_sequence/tasks/main.yml b/test/integration/targets/lookup_sequence/tasks/main.yml
index e64801d..3d74339 100644
--- a/test/integration/targets/lookup_sequence/tasks/main.yml
+++ b/test/integration/targets/lookup_sequence/tasks/main.yml
@@ -89,7 +89,7 @@
- assert:
that:
- ansible_failed_task.name == "EXPECTED FAILURE - test bad kv value"
- - ansible_failed_result.msg == "can't parse start=A as integer"
+ - ansible_failed_result.msg.startswith("Invalid type for")
- block:
- name: EXPECTED FAILURE - test bad simple form start value
@@ -102,7 +102,7 @@
- assert:
that:
- ansible_failed_task.name == "EXPECTED FAILURE - test bad simple form start value"
- - ansible_failed_result.msg == "can't parse start=A as integer"
+ - ansible_failed_result.msg.startswith("Invalid type for")
- block:
- name: EXPECTED FAILURE - test bad simple form end value
@@ -115,7 +115,7 @@
- assert:
that:
- ansible_failed_task.name == "EXPECTED FAILURE - test bad simple form end value"
- - ansible_failed_result.msg == "can't parse end=B as integer"
+ - ansible_failed_result.msg.startswith("Invalid type for")
- block:
- name: EXPECTED FAILURE - test bad simple form stride value
@@ -128,7 +128,7 @@
- assert:
that:
- ansible_failed_task.name == "EXPECTED FAILURE - test bad simple form stride value"
- - ansible_failed_result.msg == "can't parse stride=C as integer"
+ - ansible_failed_result.msg.startswith("Invalid type for")
- block:
- name: EXPECTED FAILURE - test no count or end
diff --git a/test/integration/targets/loop-connection/collections/ansible_collections/ns/name/plugins/connection/dummy.py b/test/integration/targets/loop-connection/collections/ansible_collections/ns/name/plugins/connection/dummy.py
index cb14991..ca2ac25 100644
--- a/test/integration/targets/loop-connection/collections/ansible_collections/ns/name/plugins/connection/dummy.py
+++ b/test/integration/targets/loop-connection/collections/ansible_collections/ns/name/plugins/connection/dummy.py
@@ -1,4 +1,5 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+from __future__ import annotations
DOCUMENTATION = '''
name: dummy
diff --git a/test/integration/targets/missing_required_lib/library/missing_required_lib.py b/test/integration/targets/missing_required_lib/library/missing_required_lib.py
index 8c7ba88..a5ba7c5 100644
--- a/test/integration/targets/missing_required_lib/library/missing_required_lib.py
+++ b/test/integration/targets/missing_required_lib/library/missing_required_lib.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2020, Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
diff --git a/test/integration/targets/module_defaults/action_plugins/debug.py b/test/integration/targets/module_defaults/action_plugins/debug.py
index 0c43201..63c0779 100644
--- a/test/integration/targets/module_defaults/action_plugins/debug.py
+++ b/test/integration/targets/module_defaults/action_plugins/debug.py
@@ -15,8 +15,7 @@
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.errors import AnsibleUndefinedVariable
from ansible.module_utils.six import string_types
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/othercoll/plugins/action/other_echoaction.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/othercoll/plugins/action/other_echoaction.py
index f7777b8..dcbe089 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/othercoll/plugins/action/other_echoaction.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/othercoll/plugins/action/other_echoaction.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible_collections.testns.testcoll.plugins.action.echoaction import ActionModule as BaseAM
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/othercoll/plugins/modules/other_echo1.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/othercoll/plugins/modules/other_echo1.py
index 771395f..6ca7b63 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/othercoll/plugins/modules/other_echo1.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/othercoll/plugins/modules/other_echo1.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible_collections.testns.testcoll.plugins.module_utils.echo_impl import do_echo
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/meta/runtime.yml b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/meta/runtime.yml
index a8c2c8c..145941c 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/meta/runtime.yml
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/meta/runtime.yml
@@ -2,7 +2,7 @@ plugin_routing:
action:
# Backwards compat for modules-redirected-as-actions:
# By default, each module_defaults entry is resolved as an action plugin,
- # and if it does not exist, it is resolved a a module.
+ # and if it does not exist, it is resolved a module.
# All modules that redirect to the same action will resolve to the same action.
module_uses_action_defaults:
redirect: testns.testcoll.eos
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/echoaction.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/echoaction.py
index 2fa097b..88ec765 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/echoaction.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/echoaction.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/eos.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/eos.py
index 174f372..627cbdd 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/eos.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/eos.py
@@ -1,8 +1,7 @@
# Copyright: (c) 2022, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action.normal import ActionModule as ActionBase
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/ios.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/ios.py
index 7ba2434..1647816 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/ios.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/ios.py
@@ -1,8 +1,7 @@
# Copyright: (c) 2022, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action.normal import ActionModule as ActionBase
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/vyos.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/vyos.py
index 67050fb..34732aa 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/vyos.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/action/vyos.py
@@ -1,8 +1,7 @@
# Copyright: (c) 2022, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action.normal import ActionModule as ActionBase
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/module_utils/echo_impl.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/module_utils/echo_impl.py
index f5c5d73..2a880e2 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/module_utils/echo_impl.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/module_utils/echo_impl.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
from ansible.module_utils import basic
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/echo1.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/echo1.py
index 771395f..6ca7b63 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/echo1.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/echo1.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible_collections.testns.testcoll.plugins.module_utils.echo_impl import do_echo
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/echo2.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/echo2.py
index 771395f..6ca7b63 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/echo2.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/echo2.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible_collections.testns.testcoll.plugins.module_utils.echo_impl import do_echo
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/eosfacts.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/eosfacts.py
index 8c73fe1..546205b 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/eosfacts.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/eosfacts.py
@@ -3,8 +3,7 @@
# Copyright: (c) 2022, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = r'''
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/ios_facts.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/ios_facts.py
index e2ed598..2e230ec 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/ios_facts.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/ios_facts.py
@@ -3,8 +3,7 @@
# Copyright: (c) 2022, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = r'''
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/metadata.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/metadata.py
index 6a818fd..439b415 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/metadata.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/metadata.py
@@ -3,8 +3,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/module.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/module.py
index b98a5f9..f7a1932 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/module.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/module.py
@@ -3,8 +3,7 @@
# Copyright: (c) 2022, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = r'''
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/ping.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/ping.py
index 2cb1fb2..b54b701 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/ping.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/ping.py
@@ -5,8 +5,7 @@
# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/vyosfacts.py b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/vyosfacts.py
index 3a9abbc..7af1c6b 100644
--- a/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/vyosfacts.py
+++ b/test/integration/targets/module_defaults/collections/ansible_collections/testns/testcoll/plugins/modules/vyosfacts.py
@@ -3,8 +3,7 @@
# Copyright: (c) 2022, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = r'''
diff --git a/test/integration/targets/module_defaults/library/legacy_ping.py b/test/integration/targets/module_defaults/library/legacy_ping.py
index 2cb1fb2..b54b701 100644
--- a/test/integration/targets/module_defaults/library/legacy_ping.py
+++ b/test/integration/targets/module_defaults/library/legacy_ping.py
@@ -5,8 +5,7 @@
# (c) 2016, Toshio Kuratomi <tkuratomi@ansible.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
diff --git a/test/integration/targets/module_defaults/library/test_module_defaults.py b/test/integration/targets/module_defaults/library/test_module_defaults.py
index ede8c99..3d7718d 100644
--- a/test/integration/targets/module_defaults/library/test_module_defaults.py
+++ b/test/integration/targets/module_defaults/library/test_module_defaults.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/module_no_log/library/module_that_has_secret.py b/test/integration/targets/module_no_log/library/module_that_has_secret.py
index 035228c..5bdfc85 100644
--- a/test/integration/targets/module_no_log/library/module_that_has_secret.py
+++ b/test/integration/targets/module_no_log/library/module_that_has_secret.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/module_no_log/library/module_that_logs.py b/test/integration/targets/module_no_log/library/module_that_logs.py
index 44b36ee..cb517f7 100644
--- a/test/integration/targets/module_no_log/library/module_that_logs.py
+++ b/test/integration/targets/module_no_log/library/module_that_logs.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/module_precedence/lib_no_extension/ping b/test/integration/targets/module_precedence/lib_no_extension/ping
index a28f469..ab4a989 100644
--- a/test/integration/targets/module_precedence/lib_no_extension/ping
+++ b/test/integration/targets/module_precedence/lib_no_extension/ping
@@ -19,8 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
diff --git a/test/integration/targets/module_precedence/lib_with_extension/a.ini b/test/integration/targets/module_precedence/lib_with_extension/a.ini
index 80278c9..4d0fe7b 100644
--- a/test/integration/targets/module_precedence/lib_with_extension/a.ini
+++ b/test/integration/targets/module_precedence/lib_with_extension/a.ini
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/module_precedence/lib_with_extension/a.py b/test/integration/targets/module_precedence/lib_with_extension/a.py
index 8eda141..dc537f0 100644
--- a/test/integration/targets/module_precedence/lib_with_extension/a.py
+++ b/test/integration/targets/module_precedence/lib_with_extension/a.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/module_precedence/lib_with_extension/ping.ini b/test/integration/targets/module_precedence/lib_with_extension/ping.ini
index 6f4b6a1..b8c9c94 100644
--- a/test/integration/targets/module_precedence/lib_with_extension/ping.ini
+++ b/test/integration/targets/module_precedence/lib_with_extension/ping.ini
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/module_precedence/lib_with_extension/ping.py b/test/integration/targets/module_precedence/lib_with_extension/ping.py
index a28f469..ab4a989 100644
--- a/test/integration/targets/module_precedence/lib_with_extension/ping.py
+++ b/test/integration/targets/module_precedence/lib_with_extension/ping.py
@@ -19,8 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
diff --git a/test/integration/targets/module_precedence/multiple_roles/bar/library/ping.py b/test/integration/targets/module_precedence/multiple_roles/bar/library/ping.py
index 98ef7b4..88fc595 100644
--- a/test/integration/targets/module_precedence/multiple_roles/bar/library/ping.py
+++ b/test/integration/targets/module_precedence/multiple_roles/bar/library/ping.py
@@ -19,8 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
diff --git a/test/integration/targets/module_precedence/multiple_roles/foo/library/ping.py b/test/integration/targets/module_precedence/multiple_roles/foo/library/ping.py
index 8860b7a..72c3cb8 100644
--- a/test/integration/targets/module_precedence/multiple_roles/foo/library/ping.py
+++ b/test/integration/targets/module_precedence/multiple_roles/foo/library/ping.py
@@ -19,8 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
diff --git a/test/integration/targets/module_precedence/roles_no_extension/foo/library/ping b/test/integration/targets/module_precedence/roles_no_extension/foo/library/ping
index 8860b7a..72c3cb8 100644
--- a/test/integration/targets/module_precedence/roles_no_extension/foo/library/ping
+++ b/test/integration/targets/module_precedence/roles_no_extension/foo/library/ping
@@ -19,8 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
diff --git a/test/integration/targets/module_precedence/roles_with_extension/foo/library/a.ini b/test/integration/targets/module_precedence/roles_with_extension/foo/library/a.ini
index 8b17029..8e3ae41 100644
--- a/test/integration/targets/module_precedence/roles_with_extension/foo/library/a.ini
+++ b/test/integration/targets/module_precedence/roles_with_extension/foo/library/a.ini
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/module_precedence/roles_with_extension/foo/library/a.py b/test/integration/targets/module_precedence/roles_with_extension/foo/library/a.py
index 4bc5906..cc66035 100644
--- a/test/integration/targets/module_precedence/roles_with_extension/foo/library/a.py
+++ b/test/integration/targets/module_precedence/roles_with_extension/foo/library/a.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/module_precedence/roles_with_extension/foo/library/ping.ini b/test/integration/targets/module_precedence/roles_with_extension/foo/library/ping.ini
index f9c04f5..445ed9d 100644
--- a/test/integration/targets/module_precedence/roles_with_extension/foo/library/ping.ini
+++ b/test/integration/targets/module_precedence/roles_with_extension/foo/library/ping.ini
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/module_precedence/roles_with_extension/foo/library/ping.py b/test/integration/targets/module_precedence/roles_with_extension/foo/library/ping.py
index 8860b7a..72c3cb8 100644
--- a/test/integration/targets/module_precedence/roles_with_extension/foo/library/ping.py
+++ b/test/integration/targets/module_precedence/roles_with_extension/foo/library/ping.py
@@ -19,8 +19,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['stableinterface'],
diff --git a/test/integration/targets/module_utils/aliases b/test/integration/targets/module_utils/aliases
index a1fba96..8474c8a 100644
--- a/test/integration/targets/module_utils/aliases
+++ b/test/integration/targets/module_utils/aliases
@@ -4,3 +4,4 @@ needs/target/setup_test_user
needs/target/setup_remote_tmp_dir
context/target
destructive
+setup/always/setup_passlib_controller # required for setup_test_user
diff --git a/test/integration/targets/module_utils/callback/pure_json.py b/test/integration/targets/module_utils/callback/pure_json.py
index 1723d7b..7a9b800 100644
--- a/test/integration/targets/module_utils/callback/pure_json.py
+++ b/test/integration/targets/module_utils/callback/pure_json.py
@@ -1,8 +1,7 @@
# (c) 2021 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
name: pure_json
diff --git a/test/integration/targets/module_utils/collections/ansible_collections/testns/testcoll/plugins/module_utils/legit.py b/test/integration/targets/module_utils/collections/ansible_collections/testns/testcoll/plugins/module_utils/legit.py
index b9d6348..e12624d 100644
--- a/test/integration/targets/module_utils/collections/ansible_collections/testns/testcoll/plugins/module_utils/legit.py
+++ b/test/integration/targets/module_utils/collections/ansible_collections/testns/testcoll/plugins/module_utils/legit.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
def importme():
diff --git a/test/integration/targets/module_utils/library/test.py b/test/integration/targets/module_utils/library/test.py
index 857d3d8..71f9292 100644
--- a/test/integration/targets/module_utils/library/test.py
+++ b/test/integration/targets/module_utils/library/test.py
@@ -2,7 +2,7 @@
# Most of these names are only available via PluginLoader so pylint doesn't
# know they exist
# pylint: disable=no-name-in-module
-__metaclass__ = type
+from __future__ import annotations
results = {}
diff --git a/test/integration/targets/module_utils/library/test_alias_deprecation.py b/test/integration/targets/module_utils/library/test_alias_deprecation.py
index dc36aba..7d7cfa3 100644
--- a/test/integration/targets/module_utils/library/test_alias_deprecation.py
+++ b/test/integration/targets/module_utils/library/test_alias_deprecation.py
@@ -1,7 +1,6 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
# overridden
diff --git a/test/integration/targets/module_utils/library/test_cwd_missing.py b/test/integration/targets/module_utils/library/test_cwd_missing.py
index cd1f9c7..489b0cc 100644
--- a/test/integration/targets/module_utils/library/test_cwd_missing.py
+++ b/test/integration/targets/module_utils/library/test_cwd_missing.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import os
diff --git a/test/integration/targets/module_utils/library/test_cwd_unreadable.py b/test/integration/targets/module_utils/library/test_cwd_unreadable.py
index d65f31a..9f973e5 100644
--- a/test/integration/targets/module_utils/library/test_cwd_unreadable.py
+++ b/test/integration/targets/module_utils/library/test_cwd_unreadable.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import os
diff --git a/test/integration/targets/module_utils/library/test_datetime.py b/test/integration/targets/module_utils/library/test_datetime.py
index 493a186..39eba25 100644
--- a/test/integration/targets/module_utils/library/test_datetime.py
+++ b/test/integration/targets/module_utils/library/test_datetime.py
@@ -2,8 +2,7 @@
# Most of these names are only available via PluginLoader so pylint doesn't
# know they exist
# pylint: disable=no-name-in-module
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
import datetime
diff --git a/test/integration/targets/module_utils/library/test_env_override.py b/test/integration/targets/module_utils/library/test_env_override.py
index ebfb5dd..041559b 100644
--- a/test/integration/targets/module_utils/library/test_env_override.py
+++ b/test/integration/targets/module_utils/library/test_env_override.py
@@ -2,8 +2,7 @@
# Most of these names are only available via PluginLoader so pylint doesn't
# know they exist
# pylint: disable=no-name-in-module
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.json_utils import data
diff --git a/test/integration/targets/module_utils/library/test_failure.py b/test/integration/targets/module_utils/library/test_failure.py
index ab80cea..ff8b477 100644
--- a/test/integration/targets/module_utils/library/test_failure.py
+++ b/test/integration/targets/module_utils/library/test_failure.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
results = {}
# Test that we are rooted correctly
diff --git a/test/integration/targets/module_utils/library/test_heuristic_log_sanitize.py b/test/integration/targets/module_utils/library/test_heuristic_log_sanitize.py
new file mode 100644
index 0000000..a30a622
--- /dev/null
+++ b/test/integration/targets/module_utils/library/test_heuristic_log_sanitize.py
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+
+from __future__ import annotations
+
+from ansible.module_utils import basic
+from ansible.module_utils.basic import AnsibleModule
+
+heuristic_log_sanitize = basic.heuristic_log_sanitize
+
+
+def heuristic_log_sanitize_spy(*args, **kwargs):
+ heuristic_log_sanitize_spy.return_value = heuristic_log_sanitize(*args, **kwargs)
+ return heuristic_log_sanitize_spy.return_value
+
+
+basic.heuristic_log_sanitize = heuristic_log_sanitize_spy
+
+
+def main():
+
+ module = AnsibleModule(
+ argument_spec={
+ 'data': {
+ 'type': 'str',
+ 'required': True,
+ }
+ },
+ )
+
+ # This test module is testing that the data that will be used for logging
+ # to syslog is properly sanitized when it includes URLs that contain a password.
+ #
+ # As such, we build an expected sanitized string from the input, to
+ # compare it with the output from heuristic_log_sanitize.
+ #
+ # To test this in the same way that modules ultimately operate this test
+ # monkeypatches ansible.module_utils.basic to store the sanitized data
+ # for later inspection.
+ data = module.params['data']
+ left = data.rindex(':') + 1
+ right = data.rindex('@')
+ expected = data[:left] + '********' + data[right:]
+
+ sanitized = heuristic_log_sanitize_spy.return_value
+ if sanitized != expected:
+ module.fail_json(msg='Invalid match', expected=expected, sanitized=sanitized)
+ module.exit_json(match=True)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/test/integration/targets/module_utils/library/test_network.py b/test/integration/targets/module_utils/library/test_network.py
index c6a5390..c1abd94 100644
--- a/test/integration/targets/module_utils/library/test_network.py
+++ b/test/integration/targets/module_utils/library/test_network.py
@@ -3,8 +3,7 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.network import to_subnet
diff --git a/test/integration/targets/module_utils/library/test_no_log.py b/test/integration/targets/module_utils/library/test_no_log.py
index 770e0b3..6a8cd58 100644
--- a/test/integration/targets/module_utils/library/test_no_log.py
+++ b/test/integration/targets/module_utils/library/test_no_log.py
@@ -2,8 +2,7 @@
# (c) 2021 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule, env_fallback
diff --git a/test/integration/targets/module_utils/library/test_optional.py b/test/integration/targets/module_utils/library/test_optional.py
index 4d0225d..019b25b 100644
--- a/test/integration/targets/module_utils/library/test_optional.py
+++ b/test/integration/targets/module_utils/library/test_optional.py
@@ -2,8 +2,7 @@
# Most of these names are only available via PluginLoader so pylint doesn't
# know they exist
# pylint: disable=no-name-in-module
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/module_utils/library/test_override.py b/test/integration/targets/module_utils/library/test_override.py
index 7f6e7a5..4eef499 100644
--- a/test/integration/targets/module_utils/library/test_override.py
+++ b/test/integration/targets/module_utils/library/test_override.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
# overridden
diff --git a/test/integration/targets/module_utils/library/test_recursive_diff.py b/test/integration/targets/module_utils/library/test_recursive_diff.py
index 0cf39d9..bb618ac 100644
--- a/test/integration/targets/module_utils/library/test_recursive_diff.py
+++ b/test/integration/targets/module_utils/library/test_recursive_diff.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2020, Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.dict_transformations import recursive_diff
diff --git a/test/integration/targets/module_utils/module_utils_test.yml b/test/integration/targets/module_utils/module_utils_test.yml
index 352bc58..f2da776 100644
--- a/test/integration/targets/module_utils/module_utils_test.yml
+++ b/test/integration/targets/module_utils/module_utils_test.yml
@@ -119,3 +119,7 @@
that:
- optionaltest is success
- optionaltest.msg == 'all missing optional imports behaved as expected'
+
+ - name: Test heuristic_log_sanitize
+ test_heuristic_log_sanitize:
+ data: https://user:pass@example.org/
diff --git a/test/integration/targets/module_utils_Ansible.Basic/library/ansible_basic_tests.ps1 b/test/integration/targets/module_utils_Ansible.Basic/library/ansible_basic_tests.ps1
index 9644df9..625cb21 100644
--- a/test/integration/targets/module_utils_Ansible.Basic/library/ansible_basic_tests.ps1
+++ b/test/integration/targets/module_utils_Ansible.Basic/library/ansible_basic_tests.ps1
@@ -155,6 +155,7 @@ $tests = @{
"_ansible_shell_executable": "ignored",
"_ansible_socket": "ignored",
"_ansible_syslog_facility": "ignored",
+ "_ansible_target_log_info": "ignored",
"_ansible_tmpdir": "$($m_tmpdir -replace "\\", "\\")",
"_ansible_verbosity": 3,
"_ansible_version": "2.8.0"
@@ -2253,6 +2254,34 @@ test_no_log - Invoked with:
$actual.invocation | Assert-DictionaryEqual -Expected @{module_args = $complex_args }
}
+ "Unsupported options with ignore" = {
+ $spec = @{
+ options = @{
+ option_key = @{
+ type = "str"
+ }
+ }
+ }
+ Set-Variable -Name complex_args -Scope Global -Value @{
+ option_key = "abc"
+ invalid_key = "def"
+ another_key = "ghi"
+ _ansible_ignore_unknown_opts = $true
+ }
+
+ $m = [Ansible.Basic.AnsibleModule]::Create(@(), $spec)
+ $m.Params | Assert-DictionaryEqual -Expected @{ option_key = "abc"; invalid_key = "def"; another_key = "ghi" }
+ try {
+ $m.ExitJson()
+ }
+ catch [System.Management.Automation.RuntimeException] {
+ $output = [Ansible.Basic.AnsibleModule]::FromJson($_.Exception.InnerException.Output)
+ }
+ $output.Keys.Count | Assert-Equal -Expected 2
+ $output.changed | Assert-Equal -Expected $false
+ $output.invocation | Assert-DictionaryEqual -Expected @{module_args = @{option_key = "abc"; invalid_key = "def"; another_key = "ghi" } }
+ }
+
"Check mode and module doesn't support check mode" = {
$spec = @{
options = @{
diff --git a/test/integration/targets/module_utils_ansible_release/library/ansible_release.py b/test/integration/targets/module_utils_ansible_release/library/ansible_release.py
index 528465d..8e15b85 100644
--- a/test/integration/targets/module_utils_ansible_release/library/ansible_release.py
+++ b/test/integration/targets/module_utils_ansible_release/library/ansible_release.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = r'''
---
diff --git a/test/integration/targets/module_utils_common.respawn/library/respawnme.py b/test/integration/targets/module_utils_common.respawn/library/respawnme.py
index 6471dba..1dd1739 100644
--- a/test/integration/targets/module_utils_common.respawn/library/respawnme.py
+++ b/test/integration/targets/module_utils_common.respawn/library/respawnme.py
@@ -3,8 +3,7 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import sys
diff --git a/test/integration/targets/module_utils_urls/library/test_peercert.py b/test/integration/targets/module_utils_urls/library/test_peercert.py
index ecb7d20..7bac222 100644
--- a/test/integration/targets/module_utils_urls/library/test_peercert.py
+++ b/test/integration/targets/module_utils_urls/library/test_peercert.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2020, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = r'''
---
diff --git a/test/integration/targets/no_log/library/module.py b/test/integration/targets/no_log/library/module.py
index d4f3c56..61c2908 100644
--- a/test/integration/targets/no_log/library/module.py
+++ b/test/integration/targets/no_log/library/module.py
@@ -3,8 +3,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/old_style_cache_plugins/plugins/cache/configurable_redis.py b/test/integration/targets/old_style_cache_plugins/plugins/cache/configurable_redis.py
index 23c7789..805cdba 100644
--- a/test/integration/targets/old_style_cache_plugins/plugins/cache/configurable_redis.py
+++ b/test/integration/targets/old_style_cache_plugins/plugins/cache/configurable_redis.py
@@ -1,8 +1,7 @@
# (c) 2014, Brian Coca, Josh Drake, et al
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
cache: configurable_redis
diff --git a/test/integration/targets/old_style_cache_plugins/plugins/cache/legacy_redis.py b/test/integration/targets/old_style_cache_plugins/plugins/cache/legacy_redis.py
index 9879dec..98bd188 100644
--- a/test/integration/targets/old_style_cache_plugins/plugins/cache/legacy_redis.py
+++ b/test/integration/targets/old_style_cache_plugins/plugins/cache/legacy_redis.py
@@ -1,8 +1,7 @@
# (c) 2014, Brian Coca, Josh Drake, et al
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
cache: redis
diff --git a/test/integration/targets/old_style_cache_plugins/plugins/inventory/test.py b/test/integration/targets/old_style_cache_plugins/plugins/inventory/test.py
index 7e59195..6dd450f 100644
--- a/test/integration/targets/old_style_cache_plugins/plugins/inventory/test.py
+++ b/test/integration/targets/old_style_cache_plugins/plugins/inventory/test.py
@@ -1,8 +1,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
name: test
diff --git a/test/integration/targets/old_style_vars_plugins/deprecation_warning/v2_vars_plugin.py b/test/integration/targets/old_style_vars_plugins/deprecation_warning/v2_vars_plugin.py
index f342b69..723e0a4 100644
--- a/test/integration/targets/old_style_vars_plugins/deprecation_warning/v2_vars_plugin.py
+++ b/test/integration/targets/old_style_vars_plugins/deprecation_warning/v2_vars_plugin.py
@@ -1,3 +1,6 @@
+from __future__ import annotations
+
+
class VarsModule:
def get_host_vars(self, entity):
return {}
diff --git a/test/integration/targets/old_style_vars_plugins/deprecation_warning/vars.py b/test/integration/targets/old_style_vars_plugins/deprecation_warning/vars.py
index f554be0..22fb451 100644
--- a/test/integration/targets/old_style_vars_plugins/deprecation_warning/vars.py
+++ b/test/integration/targets/old_style_vars_plugins/deprecation_warning/vars.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
from ansible.plugins.vars import BaseVarsPlugin
diff --git a/test/integration/targets/old_style_vars_plugins/vars_plugins/auto_enabled.py b/test/integration/targets/old_style_vars_plugins/vars_plugins/auto_enabled.py
index a91d94d..c933f56 100644
--- a/test/integration/targets/old_style_vars_plugins/vars_plugins/auto_enabled.py
+++ b/test/integration/targets/old_style_vars_plugins/vars_plugins/auto_enabled.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
from ansible.plugins.vars import BaseVarsPlugin
diff --git a/test/integration/targets/old_style_vars_plugins/vars_plugins/implicitly_auto_enabled.py b/test/integration/targets/old_style_vars_plugins/vars_plugins/implicitly_auto_enabled.py
index 4f407b4..5dff8ad 100644
--- a/test/integration/targets/old_style_vars_plugins/vars_plugins/implicitly_auto_enabled.py
+++ b/test/integration/targets/old_style_vars_plugins/vars_plugins/implicitly_auto_enabled.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
from ansible.plugins.vars import BaseVarsPlugin
diff --git a/test/integration/targets/old_style_vars_plugins/vars_plugins/require_enabled.py b/test/integration/targets/old_style_vars_plugins/vars_plugins/require_enabled.py
index a251447..302b6cc 100644
--- a/test/integration/targets/old_style_vars_plugins/vars_plugins/require_enabled.py
+++ b/test/integration/targets/old_style_vars_plugins/vars_plugins/require_enabled.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
from ansible.plugins.vars import BaseVarsPlugin
diff --git a/test/integration/targets/omit/aliases b/test/integration/targets/omit/aliases
index 1bff31c..fea0458 100644
--- a/test/integration/targets/omit/aliases
+++ b/test/integration/targets/omit/aliases
@@ -1,3 +1,4 @@
shippable/posix/group5
needs/target/setup_test_user
context/controller
+setup/always/setup_passlib_controller # required for setup_test_user
diff --git a/test/integration/targets/package/tasks/main.yml b/test/integration/targets/package/tasks/main.yml
index 37267aa..119474a 100644
--- a/test/integration/targets/package/tasks/main.yml
+++ b/test/integration/targets/package/tasks/main.yml
@@ -149,17 +149,17 @@
when: ansible_distribution in package_distros
##
-## yum
+## dnf
##
-#Validation for new parameter 'use' in yum action plugin which aliases to 'use_backend'
+#Validation for new parameter 'use' in dnf action plugin which aliases to 'use_backend'
#Issue: https://github.com/ansible/ansible/issues/70774
- block:
- name: verify if using both the parameters 'use' and 'use_backend' throw error
- yum:
+ dnf:
name: at
state: present
- use_backend: yum
- use: yum
+ use_backend: dnf
+ use: dnf
ignore_errors: yes
register: result
@@ -170,7 +170,7 @@
- "not result is changed"
- name: verify if package installation is successful using 'use' parameter
- yum:
+ dnf:
name: at
state: present
use: dnf
@@ -182,7 +182,7 @@
- "result is changed"
- name: remove at package
- yum:
+ dnf:
name: at
state: absent
use: dnf
@@ -194,7 +194,7 @@
- "result is changed"
- name: verify if package installation is successful using 'use_backend' parameter
- yum:
+ dnf:
name: at
state: present
use_backend: dnf
@@ -206,7 +206,7 @@
- "result is changed"
- name: remove at package
- yum:
+ dnf:
name: at
state: absent
use_backend: dnf
@@ -218,7 +218,7 @@
- "result is changed"
- name: verify if package installation is successful without using 'use_backend' and 'use' parameters
- yum:
+ dnf:
name: at
state: present
register: result
@@ -229,7 +229,7 @@
- "result is changed"
- name: remove at package
- yum:
+ dnf:
name: at
state: absent
register: result
@@ -240,3 +240,19 @@
- "result is changed"
when: ansible_distribution == "Fedora"
+
+
+- name: test ansible_package_use
+ block:
+ - name: test with var
+ package:
+ name: doesnotmatter
+ vars:
+ ansible_package_use: lola
+ ignore_errors: true
+ register: use_to_use
+
+ - assert:
+ that:
+ - use_to_use is failed
+ - "'Could not find a matching action' in use_to_use['msg']"
diff --git a/test/integration/targets/packaging_cli-doc/verify.py b/test/integration/targets/packaging_cli-doc/verify.py
index 7793fa8..7fe9d1d 100755
--- a/test/integration/targets/packaging_cli-doc/verify.py
+++ b/test/integration/targets/packaging_cli-doc/verify.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import annotations
import os
import pathlib
diff --git a/test/integration/targets/pause/test-pause.py b/test/integration/targets/pause/test-pause.py
index ab771fa..1aebfbb 100755
--- a/test/integration/targets/pause/test-pause.py
+++ b/test/integration/targets/pause/test-pause.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import pexpect
diff --git a/test/integration/targets/pip/aliases b/test/integration/targets/pip/aliases
index aa159d9..9ad637e 100644
--- a/test/integration/targets/pip/aliases
+++ b/test/integration/targets/pip/aliases
@@ -1,2 +1,3 @@
destructive
shippable/posix/group2
+needs/root
diff --git a/test/integration/targets/pip/files/ansible_test_pip_chdir/__init__.py b/test/integration/targets/pip/files/ansible_test_pip_chdir/__init__.py
index 5d1f9ae..a039849 100644
--- a/test/integration/targets/pip/files/ansible_test_pip_chdir/__init__.py
+++ b/test/integration/targets/pip/files/ansible_test_pip_chdir/__init__.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def main():
diff --git a/test/integration/targets/pip/files/sample-project/pyproject.toml b/test/integration/targets/pip/files/sample-project/pyproject.toml
new file mode 100644
index 0000000..d1ea3b1
--- /dev/null
+++ b/test/integration/targets/pip/files/sample-project/pyproject.toml
@@ -0,0 +1,7 @@
+[project]
+name = "sample-project"
+version = "1.0.0"
+
+[build-system]
+requires = ["setuptools"]
+build-backend = "setuptools.build_meta"
diff --git a/test/integration/targets/pip/files/sample-project/src/sample_project/__init__.py b/test/integration/targets/pip/files/sample-project/src/sample_project/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/integration/targets/pip/files/sample-project/src/sample_project/__init__.py
diff --git a/test/integration/targets/pip/files/setup.py b/test/integration/targets/pip/files/setup.py
index aaf2187..7d7240f 100755
--- a/test/integration/targets/pip/files/setup.py
+++ b/test/integration/targets/pip/files/setup.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from setuptools import setup, find_packages
diff --git a/test/integration/targets/pip/tasks/break_system_packages.yml b/test/integration/targets/pip/tasks/break_system_packages.yml
new file mode 100644
index 0000000..3683720
--- /dev/null
+++ b/test/integration/targets/pip/tasks/break_system_packages.yml
@@ -0,0 +1,59 @@
+- name: Get the pip version
+ command: "{{ ansible_python_interpreter }} -c 'import pip; print(pip.__version__)'"
+ register: pip_version
+
+- when: pip_version.stdout is version("23.0.1", ">=")
+ block:
+ - name: Locate the Python externally-managed marker file
+ command: |
+ {{ ansible_python_interpreter }} -c 'import sys, sysconfig; print(f"""{sysconfig.get_path("stdlib", sysconfig.get_default_scheme()
+ if sys.version_info >= (3, 10) else sysconfig._get_default_scheme())}/EXTERNALLY-MANAGED""")'
+ register: externally_managed_marker
+
+ - name: Detect if Python is externally-managed
+ stat:
+ path: "{{ externally_managed_marker.stdout }}"
+ register: externally_managed
+
+ - name: Mark Python as externally managed
+ file:
+ path: "{{ externally_managed_marker.stdout }}"
+ state: touch
+ when: not externally_managed.stat.exists
+
+ - block:
+ - name: Copy the sample project to the target
+ copy:
+ src: sample-project/
+ dest: "{{ remote_sample_project }}"
+
+ - name: Attempt to pip install the sample project without a venv
+ pip:
+ name: "{{ remote_sample_project }}"
+ register: pip_install
+ failed_when: pip_install is success
+
+ - name: Attempt to pip install the sample project without a venv using break_system_packages
+ pip:
+ name: "{{ remote_sample_project }}"
+ break_system_packages: true
+
+ - name: Remove the sample project without using break_system_packages
+ pip:
+ name: sample-project
+ state: absent
+ register: pip_uninstall
+ failed_when: pip_uninstall is success
+
+ - name: Remove the sample project using break_system_packages
+ pip:
+ name: sample-project
+ state: absent
+ break_system_packages: true
+
+ always:
+ - name: Unmark Python as externally managed
+ file:
+ path: "{{ externally_managed_marker.stdout }}"
+ state: absent
+ when: not externally_managed.stat.exists
diff --git a/test/integration/targets/pip/tasks/main.yml b/test/integration/targets/pip/tasks/main.yml
index a377070..b05b04f 100644
--- a/test/integration/targets/pip/tasks/main.yml
+++ b/test/integration/targets/pip/tasks/main.yml
@@ -1,6 +1,9 @@
# Current pip unconditionally uses md5.
# We can re-enable if pip switches to a different hash or allows us to not check md5.
+- include_tasks:
+ file: break_system_packages.yml
+
- name: Python 2
when: ansible_python.version.major == 2
block:
diff --git a/test/integration/targets/pip/vars/main.yml b/test/integration/targets/pip/vars/main.yml
index 2e87abc..34d481b 100644
--- a/test/integration/targets/pip/vars/main.yml
+++ b/test/integration/targets/pip/vars/main.yml
@@ -11,3 +11,4 @@ pip_test_pkg_ver_unsatisfied:
pip_test_modules:
- sample
- jiphy
+remote_sample_project: "{{ remote_tmp_dir }}/sample-project"
diff --git a/test/integration/targets/pkg_resources/lookup_plugins/check_pkg_resources.py b/test/integration/targets/pkg_resources/lookup_plugins/check_pkg_resources.py
index 44412f2..8f0b4b2 100644
--- a/test/integration/targets/pkg_resources/lookup_plugins/check_pkg_resources.py
+++ b/test/integration/targets/pkg_resources/lookup_plugins/check_pkg_resources.py
@@ -6,8 +6,7 @@ If pkg_resources is installed but is unable to function, this test will fail.
One known failure case this test can detect is when ansible declares a __requires__ and then tests are run without an egg-info directory.
"""
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
# noinspection PyUnresolvedReferences
try:
diff --git a/test/integration/targets/plugin_config_for_inventory/cache_plugins/none.py b/test/integration/targets/plugin_config_for_inventory/cache_plugins/none.py
index 62a91c8..771b418 100644
--- a/test/integration/targets/plugin_config_for_inventory/cache_plugins/none.py
+++ b/test/integration/targets/plugin_config_for_inventory/cache_plugins/none.py
@@ -3,8 +3,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.cache import BaseCacheModule
diff --git a/test/integration/targets/plugin_config_for_inventory/test_inventory.py b/test/integration/targets/plugin_config_for_inventory/test_inventory.py
index f937c03..ad39efc 100644
--- a/test/integration/targets/plugin_config_for_inventory/test_inventory.py
+++ b/test/integration/targets/plugin_config_for_inventory/test_inventory.py
@@ -1,6 +1,5 @@
-from __future__ import (absolute_import, division, print_function)
+from __future__ import annotations
-__metaclass__ = type
DOCUMENTATION = '''
name: test_inventory
diff --git a/test/integration/targets/plugin_loader/collections/ansible_collections/n/c/plugins/action/a.py b/test/integration/targets/plugin_loader/collections/ansible_collections/n/c/plugins/action/a.py
index 685b159..19cf56d 100644
--- a/test/integration/targets/plugin_loader/collections/ansible_collections/n/c/plugins/action/a.py
+++ b/test/integration/targets/plugin_loader/collections/ansible_collections/n/c/plugins/action/a.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
from ansible.plugins.action import ActionBase
diff --git a/test/integration/targets/plugin_loader/normal/action_plugins/self_referential.py b/test/integration/targets/plugin_loader/normal/action_plugins/self_referential.py
index b4c8957..33905f8 100644
--- a/test/integration/targets/plugin_loader/normal/action_plugins/self_referential.py
+++ b/test/integration/targets/plugin_loader/normal/action_plugins/self_referential.py
@@ -1,7 +1,6 @@
# Copyright: Contributors to the Ansible project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
diff --git a/test/integration/targets/plugin_loader/normal/library/_underscore.py b/test/integration/targets/plugin_loader/normal/library/_underscore.py
index 7a416a6..d770577 100644
--- a/test/integration/targets/plugin_loader/normal/library/_underscore.py
+++ b/test/integration/targets/plugin_loader/normal/library/_underscore.py
@@ -1,6 +1,5 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/integration/targets/plugin_loader/override/filter_plugins/core.py b/test/integration/targets/plugin_loader/override/filter_plugins/core.py
index f283dc3..8924637 100644
--- a/test/integration/targets/plugin_loader/override/filter_plugins/core.py
+++ b/test/integration/targets/plugin_loader/override/filter_plugins/core.py
@@ -1,6 +1,4 @@
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def do_flag(myval):
diff --git a/test/integration/targets/plugin_loader/runme.sh b/test/integration/targets/plugin_loader/runme.sh
index e68f06a..a313778 100755
--- a/test/integration/targets/plugin_loader/runme.sh
+++ b/test/integration/targets/plugin_loader/runme.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-set -ux
+set -eux
cleanup() {
unlink normal/library/_symlink.py
diff --git a/test/integration/targets/plugin_namespace/filter_plugins/test_filter.py b/test/integration/targets/plugin_namespace/filter_plugins/test_filter.py
index dca094b..aea1bba 100644
--- a/test/integration/targets/plugin_namespace/filter_plugins/test_filter.py
+++ b/test/integration/targets/plugin_namespace/filter_plugins/test_filter.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def filter_name(a):
diff --git a/test/integration/targets/plugin_namespace/lookup_plugins/lookup_name.py b/test/integration/targets/plugin_namespace/lookup_plugins/lookup_name.py
index d0af703..4a8d042 100644
--- a/test/integration/targets/plugin_namespace/lookup_plugins/lookup_name.py
+++ b/test/integration/targets/plugin_namespace/lookup_plugins/lookup_name.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.lookup import LookupBase
diff --git a/test/integration/targets/plugin_namespace/test_plugins/test_test.py b/test/integration/targets/plugin_namespace/test_plugins/test_test.py
index 2a9d6ee..fd949e4 100644
--- a/test/integration/targets/plugin_namespace/test_plugins/test_test.py
+++ b/test/integration/targets/plugin_namespace/test_plugins/test_test.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import re
diff --git a/test/integration/targets/prepare_http_tests/files/openssl_legacy.cnf b/test/integration/targets/prepare_http_tests/files/openssl_legacy.cnf
new file mode 100644
index 0000000..adfa225
--- /dev/null
+++ b/test/integration/targets/prepare_http_tests/files/openssl_legacy.cnf
@@ -0,0 +1,14 @@
+openssl_conf = openssl_init
+
+[openssl_init]
+providers = provider_sect
+
+[provider_sect]
+default = default_sect
+legacy = legacy_sect
+
+[default_sect]
+activate = 1
+
+[legacy_sect]
+activate = 1
diff --git a/test/integration/targets/prepare_http_tests/library/httptester_kinit.py b/test/integration/targets/prepare_http_tests/library/httptester_kinit.py
index 4f7b7ad..a84e3fb 100644
--- a/test/integration/targets/prepare_http_tests/library/httptester_kinit.py
+++ b/test/integration/targets/prepare_http_tests/library/httptester_kinit.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2020, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = r'''
---
diff --git a/test/integration/targets/prepare_http_tests/tasks/kerberos.yml b/test/integration/targets/prepare_http_tests/tasks/kerberos.yml
index 2678b46..4b3d488 100644
--- a/test/integration/targets/prepare_http_tests/tasks/kerberos.yml
+++ b/test/integration/targets/prepare_http_tests/tasks/kerberos.yml
@@ -2,6 +2,17 @@
krb5_config: '{{ remote_tmp_dir }}/krb5.conf'
krb5_realm: '{{ httpbin_host.split(".")[1:] | join(".") | upper }}'
krb5_provider: '{{ (ansible_facts.os_family == "FreeBSD" or ansible_facts.distribution == "MacOSX") | ternary("Heimdal", "MIT") }}'
+ # FreeBSD needs to enable the OpenSSL legacy providers for RC4 support.
+ # While RC4 isn't used Heimdal is currently requiring it as part of a
+ # runtime test, until that is removed we need this hack.
+ # https://github.com/heimdal/heimdal/issues/1224
+ krb5_openssl_conf: >-
+ {{
+ (ansible_facts.os_family == "FreeBSD" and ansible_facts.distribution_major_version == "14") | ternary(
+ remote_tmp_dir ~ "/openssl_legacy.cnf",
+ ""
+ )
+ }}
- set_fact:
krb5_username: admin@{{ krb5_realm }}
@@ -11,6 +22,12 @@
src: krb5.conf.j2
dest: '{{ krb5_config }}'
+- name: Create openssl.cnf to enable Legacy providers
+ copy:
+ src: openssl_legacy.cnf
+ dest: '{{ krb5_openssl_conf }}'
+ when: krb5_openssl_conf | default(False, True)
+
- name: Include distribution specific variables
include_vars: '{{ lookup("first_found", params) }}'
vars:
@@ -37,11 +54,7 @@
- name: Install python gssapi
pip:
- name:
- - decorator < 5.0.0 ; python_version < '3.5' # decorator 5.0.5 and later require python 3.5 or later
- - gssapi < 1.6.0 ; python_version <= '2.7' # gssapi 1.6.0 and later require python 3 or later
- - gssapi ; python_version > '2.7'
- - importlib ; python_version < '2.7'
+ name: gssapi
state: present
extra_args: '-c {{ remote_constraints }}'
environment:
@@ -58,6 +71,7 @@
environment:
KRB5_CONFIG: '{{ krb5_config }}'
KRB5CCNAME: FILE:{{ remote_tmp_dir }}/krb5.cc
+ OPENSSL_CONF: '{{ krb5_openssl_conf }}'
- name: remove test credential cache
file:
diff --git a/test/integration/targets/rel_plugin_loading/subdir/inventory_plugins/notyaml.py b/test/integration/targets/rel_plugin_loading/subdir/inventory_plugins/notyaml.py
index 41a76d9..4242e2e 100644
--- a/test/integration/targets/rel_plugin_loading/subdir/inventory_plugins/notyaml.py
+++ b/test/integration/targets/rel_plugin_loading/subdir/inventory_plugins/notyaml.py
@@ -1,8 +1,7 @@
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
inventory: yaml
@@ -16,7 +15,7 @@ DOCUMENTATION = '''
- File MUST have a valid extension, defined in configuration.
notes:
- If you want to set vars for the C(all) group inside the inventory file, the C(all) group must be the first entry in the file.
- - Whitelisted in configuration by default.
+ - Enabled in configuration by default.
options:
yaml_extensions:
description: list of 'valid' extensions for files containing YAML
@@ -94,7 +93,7 @@ class InventoryModule(BaseFileInventoryPlugin):
self.set_options()
try:
- data = self.loader.load_from_file(path, cache=False)
+ data = self.loader.load_from_file(path, cache='none')
except Exception as e:
raise AnsibleParserError(e)
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 e8d712a..c55cfc3 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
@@ -2,8 +2,7 @@
# Copyright: Contributors to the Ansible project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
from jinja2 import Undefined
diff --git a/test/integration/targets/roles/no_outside_import.yml b/test/integration/targets/roles/no_outside_import.yml
new file mode 100644
index 0000000..c9e0d13
--- /dev/null
+++ b/test/integration/targets/roles/no_outside_import.yml
@@ -0,0 +1,6 @@
+- hosts: testhost
+ gather_facts: false
+ tasks:
+ - import_role:
+ name: a
+ tasks_from: subdir/../../../../no_outside.yml
diff --git a/test/integration/targets/roles/privacy.yml b/test/integration/targets/roles/privacy.yml
index 2f671c0..60d5198 100644
--- a/test/integration/targets/roles/privacy.yml
+++ b/test/integration/targets/roles/privacy.yml
@@ -27,6 +27,28 @@
- not is_default or is_default and privacy is defined
- hosts: localhost
+ name: test public no always overrides global on import_role
+ gather_facts: false
+ tasks:
+ - import_role: name=a public=no
+
+ - name: role is private, var should be undefined
+ assert:
+ that:
+ - privacy is undefined
+
+- hosts: localhost
+ name: test public yes always overrides global on import_role
+ gather_facts: false
+ tasks:
+ - import_role: name=a public=yes
+
+ - name: role is private, var should be undefined
+ assert:
+ that:
+ - privacy is defined
+
+- hosts: localhost
name: test global privacy setting on includes
gather_facts: false
tasks:
diff --git a/test/integration/targets/roles/roles/a/tasks/subdir/entrypoint.yml b/test/integration/targets/roles/roles/a/tasks/subdir/entrypoint.yml
new file mode 100644
index 0000000..331ec94
--- /dev/null
+++ b/test/integration/targets/roles/roles/a/tasks/subdir/entrypoint.yml
@@ -0,0 +1 @@
+- debug: msg=subdir
diff --git a/test/integration/targets/roles/runme.sh b/test/integration/targets/roles/runme.sh
index bf3aaf5..5227e42 100755
--- a/test/integration/targets/roles/runme.sh
+++ b/test/integration/targets/roles/runme.sh
@@ -26,13 +26,19 @@ ansible-playbook role_complete.yml -i ../../inventory -i fake, --tags unreachabl
ansible-playbook data_integrity.yml -i ../../inventory "$@"
# ensure role fails when trying to load 'non role' in _from
-ansible-playbook no_outside.yml -i ../../inventory > role_outside_output.log 2>&1 || true
-if grep "as it is not inside the expected role path" role_outside_output.log >/dev/null; then
- echo "Test passed (playbook failed with expected output, output not shown)."
-else
- echo "Test failed, expected output from playbook failure is missing, output not shown)."
- exit 1
-fi
+test_no_outside=("no_outside.yml" "no_outside_import.yml")
+for file in "${test_no_outside[@]}"; do
+ ansible-playbook "$file" -i ../../inventory > "${file}_output.log" 2>&1 || true
+ if grep "as it is not inside the expected role path" "${file}_output.log" >/dev/null; then
+ echo "Test passed for $file (playbook failed with expected output, output not shown)."
+ else
+ echo "Test failed for $file, expected output from playbook failure is missing, output not shown)."
+ exit 1
+ fi
+done
+
+# ensure subdir contained to role in tasks_from is valid
+ansible-playbook test_subdirs.yml -i ../../inventory "$@"
# ensure vars scope is correct
ansible-playbook vars_scope.yml -i ../../inventory "$@"
diff --git a/test/integration/targets/roles/test_subdirs.yml b/test/integration/targets/roles/test_subdirs.yml
new file mode 100644
index 0000000..503239d
--- /dev/null
+++ b/test/integration/targets/roles/test_subdirs.yml
@@ -0,0 +1,10 @@
+---
+- hosts: testhost
+ gather_facts: false
+ tasks:
+ - import_role:
+ name: a
+ tasks_from: subdir/entrypoint.yml
+ - include_role:
+ name: a
+ tasks_from: subdir/entrypoint.yml
diff --git a/test/integration/targets/run_modules/library/test.py b/test/integration/targets/run_modules/library/test.py
index 15a92e9..fed83ec 100644
--- a/test/integration/targets/run_modules/library/test.py
+++ b/test/integration/targets/run_modules/library/test.py
@@ -1,7 +1,6 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/script/files/no_shebang.py b/test/integration/targets/script/files/no_shebang.py
index f2d386a..7a2e3e6 100644
--- a/test/integration/targets/script/files/no_shebang.py
+++ b/test/integration/targets/script/files/no_shebang.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import sys
diff --git a/test/integration/targets/script/tasks/main.yml b/test/integration/targets/script/tasks/main.yml
index 668ec48..d6f77fd 100644
--- a/test/integration/targets/script/tasks/main.yml
+++ b/test/integration/targets/script/tasks/main.yml
@@ -162,7 +162,7 @@
assert:
that:
- script_result3 is failed
- - script_result3.msg == "async is not supported for this task."
+ - script_result3.msg == "This action (script) does not support async."
# check mode
diff --git a/test/integration/targets/service/files/ansible_test_service.py b/test/integration/targets/service/files/ansible_test_service.py
index 6292272..6bf404c 100644
--- a/test/integration/targets/service/files/ansible_test_service.py
+++ b/test/integration/targets/service/files/ansible_test_service.py
@@ -3,8 +3,7 @@
# this is mostly based off of the code found here:
# http://code.activestate.com/recipes/278731-creating-a-daemon-the-python-way/
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import resource
diff --git a/test/integration/targets/service/tasks/main.yml b/test/integration/targets/service/tasks/main.yml
index 4fc2ddf..7a4ecda 100644
--- a/test/integration/targets/service/tasks/main.yml
+++ b/test/integration/targets/service/tasks/main.yml
@@ -46,7 +46,7 @@
msg: 'ansible_service_mgr: {{ ansible_service_mgr }}'
- name: setup test service script
- include_tasks: '{{ service_type }}_setup.yml'
+ include_tasks: '{{ service_type }}_setup.yml'
- name: execute tests
import_tasks: tests.yml
diff --git a/test/integration/targets/service/tasks/upstart_cleanup.yml b/test/integration/targets/service/tasks/upstart_cleanup.yml
index 683fb10..fa418fe 100644
--- a/test/integration/targets/service/tasks/upstart_cleanup.yml
+++ b/test/integration/targets/service/tasks/upstart_cleanup.yml
@@ -11,7 +11,7 @@
loop: '{{ upstart_files }}'
- name: assert that upstart init files were removed
- raw: 'test -e {{ item }}'
+ raw: 'test -e {{ item }}'
loop: '{{ upstart_files }}'
register: file_exists
failed_when: file_exists is not failed
diff --git a/test/integration/targets/service_facts/files/ansible_test_service.py b/test/integration/targets/service_facts/files/ansible_test_service.py
index 19f1e29..6bf404c 100644
--- a/test/integration/targets/service_facts/files/ansible_test_service.py
+++ b/test/integration/targets/service_facts/files/ansible_test_service.py
@@ -3,8 +3,7 @@
# this is mostly based off of the code found here:
# http://code.activestate.com/recipes/278731-creating-a-daemon-the-python-way/
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import os
import resource
diff --git a/test/integration/targets/set_fact/runme.sh b/test/integration/targets/set_fact/runme.sh
index 9309359..7fd548c 100755
--- a/test/integration/targets/set_fact/runme.sh
+++ b/test/integration/targets/set_fact/runme.sh
@@ -34,3 +34,6 @@ ansible-playbook -i inventory set_fact_empty_str_key.yml
# https://github.com/ansible/ansible/issues/21088
ansible-playbook -i inventory "$@" set_fact_auto_unsafe.yml
+
+ansible-playbook -i inventory "$@" set_fact_ansible_vars.yml 2>&1 | tee test_set_fact_ansible_vars.out
+test "$(grep -E -c 'is reserved for internal use only.' test_set_fact_ansible_vars.out)" = 1
diff --git a/test/integration/targets/set_fact/set_fact_ansible_vars.yml b/test/integration/targets/set_fact/set_fact_ansible_vars.yml
new file mode 100644
index 0000000..53ed535
--- /dev/null
+++ b/test/integration/targets/set_fact/set_fact_ansible_vars.yml
@@ -0,0 +1,9 @@
+- name: Test set_fact with key starting with reserved keyword '_ansible_'
+ hosts: testhost
+ gather_facts: no
+ tasks:
+ - name: Define fact with key starting with reserved keyword '_ansible_'
+ set_fact:
+ _ansible_foo: bar
+ ignore_errors: yes
+ register: r
diff --git a/test/integration/targets/setup_deb_repo/files/package_specs/stable/baz-1.0.0 b/test/integration/targets/setup_deb_repo/files/package_specs/stable/baz-1.0.0
new file mode 100644
index 0000000..1e5d0a4
--- /dev/null
+++ b/test/integration/targets/setup_deb_repo/files/package_specs/stable/baz-1.0.0
@@ -0,0 +1,11 @@
+Section: misc
+Priority: optional
+Standards-Version: 2.3.3
+
+Package: baz
+Version: 1.0.0
+Section: system
+Maintainer: John Doe <john@doe.com>
+Architecture: all
+Description: Dummy package
+Recommends: rolldice
diff --git a/test/integration/targets/setup_epel/tasks/main.yml b/test/integration/targets/setup_epel/tasks/main.yml
deleted file mode 100644
index a8593bb..0000000
--- a/test/integration/targets/setup_epel/tasks/main.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-- name: Enable RHEL7 extras
- # EPEL 7 depends on RHEL 7 extras, which is not enabled by default on RHEL.
- # See: https://docs.fedoraproject.org/en-US/epel/epel-policy/#_policy
- command: yum-config-manager --enable rhel-7-server-rhui-extras-rpms
- when: ansible_facts.distribution == 'RedHat' and ansible_facts.distribution_major_version == '7'
-- name: Install EPEL
- yum:
- name: https://ci-files.testing.ansible.com/test/integration/targets/setup_epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm
- disable_gpg_check: true
- when: ansible_facts.distribution in ['RedHat', 'CentOS']
diff --git a/test/integration/targets/setup_paramiko/constraints.txt b/test/integration/targets/setup_paramiko/constraints.txt
index c502ba0..e69de29 100644
--- a/test/integration/targets/setup_paramiko/constraints.txt
+++ b/test/integration/targets/setup_paramiko/constraints.txt
@@ -1 +0,0 @@
-cryptography >= 2.5, < 3.4
diff --git a/test/integration/targets/setup_paramiko/library/detect_paramiko.py b/test/integration/targets/setup_paramiko/library/detect_paramiko.py
index e3a8158..15905b8 100644
--- a/test/integration/targets/setup_paramiko/library/detect_paramiko.py
+++ b/test/integration/targets/setup_paramiko/library/detect_paramiko.py
@@ -1,9 +1,8 @@
#!/usr/bin/python
"""Ansible module to detect the presence of both the normal and Ansible-specific versions of Paramiko."""
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/integration/targets/setup_passlib_controller/runme.sh b/test/integration/targets/setup_passlib_controller/runme.sh
new file mode 100755
index 0000000..c9f13e7
--- /dev/null
+++ b/test/integration/targets/setup_passlib_controller/runme.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+set -eux
+
+# Temporary hack for PEP 668 on newer systems.
+# Remove once ansible-test can provide targets their own virtual environment.
+# Tests which can manage their own virtual environment should not use this approach.
+export PIP_BREAK_SYSTEM_PACKAGES=1
+
+# Requirements have to be installed prior to running ansible-playbook
+# because plugins and requirements are loaded before the task runs
+python -m pip install passlib
diff --git a/test/integration/targets/setup_pexpect/files/constraints.txt b/test/integration/targets/setup_pexpect/files/constraints.txt
index c78ecda..930ee5c 100644
--- a/test/integration/targets/setup_pexpect/files/constraints.txt
+++ b/test/integration/targets/setup_pexpect/files/constraints.txt
@@ -1,2 +1 @@
pexpect == 4.8.0
-ptyprocess < 0.7.0 ; python_version < '2.7' # ptyprocess >= 0.7.0 not compatible with Python 2.6
diff --git a/test/integration/targets/setup_rpm_repo/aliases b/test/integration/targets/setup_rpm_repo/aliases
deleted file mode 100644
index 65e8315..0000000
--- a/test/integration/targets/setup_rpm_repo/aliases
+++ /dev/null
@@ -1 +0,0 @@
-needs/target/setup_epel
diff --git a/test/integration/targets/setup_rpm_repo/library/create_repo.py b/test/integration/targets/setup_rpm_repo/library/create_repo.py
index e6a61ba..7424ea5 100644
--- a/test/integration/targets/setup_rpm_repo/library/create_repo.py
+++ b/test/integration/targets/setup_rpm_repo/library/create_repo.py
@@ -1,10 +1,7 @@
#!/usr/bin/python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-import subprocess
-import sys
import tempfile
from collections import namedtuple
@@ -15,10 +12,12 @@ from ansible.module_utils.common.respawn import has_respawned, probe_interpreter
HAS_RPMFLUFF = True
can_use_rpm_weak_deps = None
try:
- from rpmfluff import SimpleRpmBuild
+ from rpmfluff import SimpleRpmBuild, GeneratedSourceFile, make_gif
from rpmfluff import YumRepoBuild
except ImportError:
try:
+ from rpmfluff.make import make_gif
+ from rpmfluff.sourcefile import GeneratedSourceFile
from rpmfluff.rpmbuild import SimpleRpmBuild
from rpmfluff.yumrepobuild import YumRepoBuild
except ImportError:
@@ -35,20 +34,25 @@ if HAS_RPMFLUFF:
pass
-RPM = namedtuple('RPM', ['name', 'version', 'release', 'epoch', 'recommends', 'arch'])
-
+RPM = namedtuple('RPM', ['name', 'version', 'release', 'epoch', 'recommends', 'file', 'arch'])
SPECS = [
- RPM('dinginessentail', '1.0', '1', None, None, None),
- RPM('dinginessentail', '1.0', '2', '1', None, None),
- RPM('dinginessentail', '1.1', '1', '1', None, None),
- RPM('dinginessentail-olive', '1.0', '1', None, None, None),
- RPM('dinginessentail-olive', '1.1', '1', None, None, None),
- RPM('landsidescalping', '1.0', '1', None, None, None),
- RPM('landsidescalping', '1.1', '1', None, None, None),
- RPM('dinginessentail-with-weak-dep', '1.0', '1', None, ['dinginessentail-weak-dep'], None),
- RPM('dinginessentail-weak-dep', '1.0', '1', None, None, None),
- RPM('noarchfake', '1.0', '1', None, None, 'noarch'),
+ RPM('dinginessentail', '1.0', '1', None, None, None, None),
+ RPM('dinginessentail', '1.0', '2', '1', None, None, None),
+ RPM('dinginessentail', '1.1', '1', '1', None, None, None),
+ RPM('dinginessentail-olive', '1.0', '1', None, None, None, None),
+ RPM('dinginessentail-olive', '1.1', '1', None, None, None, None),
+ RPM('landsidescalping', '1.0', '1', None, None, None, None),
+ RPM('landsidescalping', '1.1', '1', None, None, None, None),
+ RPM('dinginessentail-with-weak-dep', '1.0', '1', None, ['dinginessentail-weak-dep'], None, None),
+ RPM('dinginessentail-weak-dep', '1.0', '1', None, None, None, None),
+ RPM('noarchfake', '1.0', '1', None, None, None, 'noarch'),
+ RPM('provides_foo_a', '1.0', '1', None, None, 'foo.gif', 'noarch'),
+ RPM('provides_foo_b', '1.0', '1', None, None, 'foo.gif', 'noarch'),
+ RPM('number-11-name', '11.0', '1', None, None, None, None),
+ RPM('number-11-name', '11.1', '1', None, None, None, None),
+ RPM('epochone', '1.0', '1', '1', None, None, "noarch"),
+ RPM('epochone', '1.1', '1', '1', None, None, "noarch"),
]
@@ -66,21 +70,18 @@ def create_repo(arch='x86_64'):
for recommend in spec.recommends:
pkg.add_recommends(recommend)
- pkgs.append(pkg)
-
- # HACK: EPEL6 version of rpmfluff can't do multi-arch packaging, so we'll just build separately and copy
- # the noarch stuff in, since we don't currently care about the repodata for noarch
- if sys.version_info[0:2] == (2, 6):
- noarch_repo = YumRepoBuild([p for p in pkgs if 'noarch' in p.get_build_archs()])
- noarch_repo.make('noarch')
+ if spec.file:
+ pkg.add_installed_file(
+ "/" + spec.file,
+ GeneratedSourceFile(
+ spec.file, make_gif()
+ )
+ )
- repo = YumRepoBuild([p for p in pkgs if arch in p.get_build_archs()])
- repo.make(arch)
+ pkgs.append(pkg)
- subprocess.call("cp {0}/*.rpm {1}".format(noarch_repo.repoDir, repo.repoDir), shell=True)
- else:
- repo = YumRepoBuild(pkgs)
- repo.make(arch, 'noarch')
+ repo = YumRepoBuild(pkgs)
+ repo.make(arch, 'noarch')
for pkg in pkgs:
pkg.clean()
diff --git a/test/integration/targets/setup_rpm_repo/tasks/main.yml b/test/integration/targets/setup_rpm_repo/tasks/main.yml
index bf5af10..8104190 100644
--- a/test/integration/targets/setup_rpm_repo/tasks/main.yml
+++ b/test/integration/targets/setup_rpm_repo/tasks/main.yml
@@ -1,11 +1,4 @@
- block:
- - name: Install epel repo which is missing on rhel-7 and is needed for rpmfluff
- include_role:
- name: setup_epel
- when:
- - ansible_distribution in ['RedHat', 'CentOS']
- - ansible_distribution_major_version is version('7', '==')
-
- name: Include distribution specific variables
include_vars: "{{ lookup('first_found', params) }}"
vars:
diff --git a/test/integration/targets/shell/action_plugins/test_shell.py b/test/integration/targets/shell/action_plugins/test_shell.py
index 6e66ed0..17fa4d9 100644
--- a/test/integration/targets/shell/action_plugins/test_shell.py
+++ b/test/integration/targets/shell/action_plugins/test_shell.py
@@ -3,9 +3,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
diff --git a/test/integration/targets/shell/connection_plugins/test_connection_default.py b/test/integration/targets/shell/connection_plugins/test_connection_default.py
index 60feedd..6f13102 100644
--- a/test/integration/targets/shell/connection_plugins/test_connection_default.py
+++ b/test/integration/targets/shell/connection_plugins/test_connection_default.py
@@ -1,8 +1,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
connection: test_connection_default
diff --git a/test/integration/targets/shell/connection_plugins/test_connection_override.py b/test/integration/targets/shell/connection_plugins/test_connection_override.py
index d26d2b5..b962dfa 100644
--- a/test/integration/targets/shell/connection_plugins/test_connection_override.py
+++ b/test/integration/targets/shell/connection_plugins/test_connection_override.py
@@ -1,8 +1,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = '''
connection: test_connection_override
diff --git a/test/integration/targets/slurp/aliases b/test/integration/targets/slurp/aliases
index 6eae8bd..069c660 100644
--- a/test/integration/targets/slurp/aliases
+++ b/test/integration/targets/slurp/aliases
@@ -1,2 +1,3 @@
shippable/posix/group1
destructive
+setup/always/setup_passlib_controller # required for setup_test_user
diff --git a/test/integration/targets/subversion/roles/subversion/defaults/main.yml b/test/integration/targets/subversion/roles/subversion/defaults/main.yml
index 02ecd1e..5feda8c 100644
--- a/test/integration/targets/subversion/roles/subversion/defaults/main.yml
+++ b/test/integration/targets/subversion/roles/subversion/defaults/main.yml
@@ -3,7 +3,9 @@ apache_port: 11386 # cannot use 80 as httptester overrides this
subversion_test_dir: /tmp/ansible-svn-test-dir
subversion_server_dir: /tmp/ansible-svn # cannot use a path in the home dir without userdir or granting exec permission to the apache user
subversion_repo_name: ansible-test-repo
-subversion_repo_url: https://localhost:{{ apache_port }}/svn/{{ subversion_repo_name }} # svn can't verify TLS certificates against IP addresses
-subversion_repo_auth_url: https://localhost:{{ apache_port }}/svnauth/{{ subversion_repo_name }}
+# default to explicit IPv4; svn doesn't handle IPv4 fallback if eg "localhost" -> [::1, 127.0.0.1] and ::1 doesn't answer
+subversion_repo_ip: 127.0.0.1
+subversion_repo_url: https://{{ subversion_repo_ip }}:{{ apache_port }}/svn/{{ subversion_repo_name }}
+subversion_repo_auth_url: https://{{ subversion_repo_ip }}:{{ apache_port }}/svnauth/{{ subversion_repo_name }}
subversion_username: subsvn_user'''
subversion_password: Password123!
diff --git a/test/integration/targets/subversion/roles/subversion/tasks/setup.yml b/test/integration/targets/subversion/roles/subversion/tasks/setup.yml
index 880c295..52729d5 100644
--- a/test/integration/targets/subversion/roles/subversion/tasks/setup.yml
+++ b/test/integration/targets/subversion/roles/subversion/tasks/setup.yml
@@ -29,10 +29,6 @@
path: '{{ subversion_server_dir }}'
state: directory
-- name: setup selinux when enabled
- include_tasks: setup_selinux.yml
- when: ansible_selinux.status == "enabled"
-
- name: Generate CA and TLS certificates via trustme
vars:
venv_path: >-
@@ -42,21 +38,8 @@
block:
- name: trustme -- provision a venv
command: >-
- {{ ansible_python_interpreter }}
- -{% if ansible_python.version.major != 2 %}I{% endif %}m
- {% if ansible_python.version.major != 2 %}venv{%
- else %}virtualenv{% endif %}
-
+ {{ ansible_python_interpreter }} -Im venv
{{ venv_path }}
- - name: trustme -- upgrade pip in venv | RHEL 7.9 & 8.8+py36
- when: >- # these don't know how to notice `cryptography` wheels
- ansible_distribution == 'RedHat'
- and ansible_distribution_major_version | int < 9
- pip:
- name: pip
- state: latest
- virtualenv: >-
- {{ venv_path }}
- name: trustme -- install tool
pip:
name: trustme
@@ -67,18 +50,18 @@
argv:
- >-
{{ venv_python }}
- - -{%- if ansible_python.version.major != 2 -%}I{%- endif -%}m
+ - -Im
- trustme
- --dir={{ subversion_server_dir }}
+ - --identities={{ subversion_repo_ip }}
+ - --common-name={{ subversion_repo_ip }}
- name: symlink trustme certificates into apache config dir - Red Hat
when: ansible_os_family in ['RedHat']
- # when: ansible_distribution in ['Fedora', 'RedHat']
file:
src: /tmp/ansible-svn/server.{{ item.trustme_filetype }}
dest: /etc/pki/tls/{{ item.apache_target_path }}
state: link
- force: yes # Othewise Apache on CentOS 7 uses its own fake certificate
loop:
- apache_target_path: certs/localhost.crt
trustme_filetype: pem
diff --git a/test/integration/targets/subversion/roles/subversion/tasks/setup_selinux.yml b/test/integration/targets/subversion/roles/subversion/tasks/setup_selinux.yml
deleted file mode 100644
index a9ffa71..0000000
--- a/test/integration/targets/subversion/roles/subversion/tasks/setup_selinux.yml
+++ /dev/null
@@ -1,11 +0,0 @@
-- name: set SELinux security context for SVN folder
- sefcontext:
- target: '{{ subversion_server_dir }}(/.*)?'
- setype: '{{ item }}'
- state: present
- with_items:
- - httpd_sys_content_t
- - httpd_sys_rw_content_t
-
-- name: apply new SELinux context to filesystem
- command: restorecon -irv {{ subversion_server_dir | quote }}
diff --git a/test/integration/targets/subversion/roles/subversion/templates/subversion.conf.j2 b/test/integration/targets/subversion/roles/subversion/templates/subversion.conf.j2
index 133c70c..74d7cc1 100644
--- a/test/integration/targets/subversion/roles/subversion/templates/subversion.conf.j2
+++ b/test/integration/targets/subversion/roles/subversion/templates/subversion.conf.j2
@@ -39,6 +39,7 @@ LoadModule dav_svn_module libexec/apache24/mod_dav_svn.so
LoadModule authz_svn_module libexec/apache24/mod_authz_svn.so
{% elif ansible_os_family == "Suse" %}
Include /etc/apache2/httpd.conf
+Include mods-available/ssl.load
LoadModule dav_module /usr/lib64/apache2/mod_dav.so
LoadModule dav_svn_module /usr/lib64/apache2/mod_dav_svn.so
{% elif ansible_os_family == "Alpine" %}
@@ -50,10 +51,7 @@ Include /etc/httpd/conf/httpd.conf
{% endif %}
PidFile {{ subversion_server_dir }}/apache.pid
-Listen 127.0.0.1:{{ apache_port }} https
-{% if ansible_distribution not in ["Alpine", "CentOS", "Fedora", "openSUSE Leap", "Ubuntu"] %}
-Listen [::1]:{{ apache_port }} https
-{% endif %}
+Listen {{ subversion_repo_ip }}:{{ apache_port }} https
SSLEngine on
SSLCertificateFile {{ subversion_server_dir }}/server.pem
SSLCertificateKeyFile {{ subversion_server_dir }}/server.key
diff --git a/test/integration/targets/support-callback_plugins/callback_plugins/callback_debug.py b/test/integration/targets/support-callback_plugins/callback_plugins/callback_debug.py
index 2462c1f..7d7df62 100644
--- a/test/integration/targets/support-callback_plugins/callback_plugins/callback_debug.py
+++ b/test/integration/targets/support-callback_plugins/callback_plugins/callback_debug.py
@@ -1,8 +1,9 @@
# (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
+
+import functools
from ansible.plugins.callback import CallbackBase
@@ -16,9 +17,8 @@ class CallbackModule(CallbackBase):
super(CallbackModule, self).__init__(*args, **kwargs)
self._display.display('__init__')
- for cb in [x for x in dir(CallbackBase) if x.startswith('v2_')]:
- delattr(CallbackBase, cb)
+ for name in (cb for cb in dir(self) if cb.startswith('v2_')):
+ setattr(self, name, functools.partial(self.handle_v2, name))
- def __getattr__(self, name):
- if name.startswith('v2_'):
- return lambda *args, **kwargs: self._display.display(name)
+ def handle_v2(self, name, *args, **kwargs):
+ self._display.display(name)
diff --git a/test/integration/targets/template/ansible_managed.yml b/test/integration/targets/template/ansible_managed.yml
index 2bd7c2c..a94e57e 100644
--- a/test/integration/targets/template/ansible_managed.yml
+++ b/test/integration/targets/template/ansible_managed.yml
@@ -2,13 +2,51 @@
- hosts: testhost
gather_facts: False
tasks:
- - set_fact:
+ - name: set output_dir
+ set_fact:
output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}"
- - file:
- path: '{{ output_dir }}/café.txt'
- state: 'absent'
- # Smoketest that ansible_managed with non-ascii chars works:
- # https://github.com/ansible/ansible/issues/27262
- - template:
- src: 'templates/café.j2'
- dest: '{{ output_dir }}/café.txt'
+ tags: ['always']
+
+ - name: Smoketest that ansible_managed with non-ascii chars works, https://github.com/ansible/ansible/issues/27262
+ tags: ['27262']
+ block:
+ - name: ensure output file does not exist
+ file:
+ path: '{{ output_dir }}/café.txt'
+ state: 'absent'
+
+ - name: test templating with unicode in template name
+ template:
+ src: 'templates/café.j2'
+ dest: '{{ output_dir }}/café.txt'
+
+ always:
+ - name: clean up!
+ file:
+ path: '{{ output_dir }}/café.txt'
+ state: 'absent'
+
+ - name: check strftime resolution in ansible_managed, https://github.com/ansible/ansible/pull/79129
+ tags: ['79129']
+ block:
+ - template:
+ src: "templates/%necho Onii-chan help Im stuck;exit 1%n.j2"
+ dest: "{{ output_dir }}/strftime.sh"
+ mode: '0755'
+
+ - shell: "exec {{ output_dir | quote }}/strftime.sh"
+
+ - name: Avoid templating 'injections' via file names
+ template:
+ src: !unsafe "templates/completely{{ 1 % 0 }} safe template.j2"
+ dest: "{{ output_dir }}/jinja.sh"
+ mode: '0755'
+
+ - shell: "exec {{ output_dir | quote }}/jinja.sh"
+ register: result
+
+ - assert:
+ that:
+ - "'Hello' in result.stdout"
+ - "'uname' not in lookup('file', output_dir ~ '/strftime.sh')"
+ - "'uname' not in lookup('file', output_dir ~ '/jinja.sh')"
diff --git a/test/integration/targets/template/ansible_managed_79129.yml b/test/integration/targets/template/ansible_managed_79129.yml
deleted file mode 100644
index e00ada8..0000000
--- a/test/integration/targets/template/ansible_managed_79129.yml
+++ /dev/null
@@ -1,29 +0,0 @@
----
-- hosts: testhost
- gather_facts: false
- tasks:
- - set_fact:
- output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}"
-
- - name: check strftime
- block:
- - template:
- src: "templates/%necho Onii-chan help Im stuck;exit 1%n.j2"
- dest: "{{ output_dir }}/79129-strftime.sh"
- mode: '0755'
-
- - shell: "exec {{ output_dir | quote }}/79129-strftime.sh"
-
- - name: check jinja template
- block:
- - template:
- src: !unsafe "templates/completely{{ 1 % 0 }} safe template.j2"
- dest: "{{ output_dir }}/79129-jinja.sh"
- mode: '0755'
-
- - shell: "exec {{ output_dir | quote }}/79129-jinja.sh"
- register: result
-
- - assert:
- that:
- - "'Hello' in result.stdout"
diff --git a/test/integration/targets/template/ansible_managed_templated.cfg b/test/integration/targets/template/ansible_managed_templated.cfg
new file mode 100644
index 0000000..4840045
--- /dev/null
+++ b/test/integration/targets/template/ansible_managed_templated.cfg
@@ -0,0 +1,2 @@
+[defaults]
+ansible_managed=ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}({{{{q('pipe', 'uname -a')}}}})
diff --git a/test/integration/targets/template/role_filter/filter_plugins/myplugin.py b/test/integration/targets/template/role_filter/filter_plugins/myplugin.py
index b0a8889..6043fdf 100644
--- a/test/integration/targets/template/role_filter/filter_plugins/myplugin.py
+++ b/test/integration/targets/template/role_filter/filter_plugins/myplugin.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class FilterModule(object):
diff --git a/test/integration/targets/template/runme.sh b/test/integration/targets/template/runme.sh
index d3913d9..e814110 100755
--- a/test/integration/targets/template/runme.sh
+++ b/test/integration/targets/template/runme.sh
@@ -7,11 +7,11 @@ ANSIBLE_ROLES_PATH=../ ansible-playbook template.yml -i ../../inventory -v "$@"
# Test for https://github.com/ansible/ansible/pull/35571
ansible testhost -i testhost, -m debug -a 'msg={{ hostvars["localhost"] }}' -e "vars1={{ undef() }}" -e "vars2={{ vars1 }}"
-# Test for https://github.com/ansible/ansible/issues/27262
+# ansible_managed tests
ANSIBLE_CONFIG=ansible_managed.cfg ansible-playbook ansible_managed.yml -i ../../inventory -v "$@"
-# Test for https://github.com/ansible/ansible/pull/79129
-ANSIBLE_CONFIG=ansible_managed.cfg ansible-playbook ansible_managed_79129.yml -i ../../inventory -v "$@"
+# same as above but with ansible_managed j2 template
+ANSIBLE_CONFIG=ansible_managed_templated.cfg ansible-playbook ansible_managed.yml -i ../../inventory -v "$@"
# Test for #42585
ANSIBLE_ROLES_PATH=../ ansible-playbook custom_template.yml -i ../../inventory -v "$@"
diff --git a/test/integration/targets/template/tasks/main.yml b/test/integration/targets/template/tasks/main.yml
index 34e8828..d96941f 100644
--- a/test/integration/targets/template/tasks/main.yml
+++ b/test/integration/targets/template/tasks/main.yml
@@ -714,7 +714,7 @@
- name: check that proper error message is emitted when in operator is used
assert:
- that: "\"'y' is undefined\" in error.msg"
+ that: "\"The error was: 'y' is undefined\n\n\" in error.msg"
- template:
src: template_import_macro_globals.j2
diff --git a/test/integration/targets/templating_lookups/template_lookups/mock_lookup_plugins/77788.py b/test/integration/targets/templating_lookups/template_lookups/mock_lookup_plugins/77788.py
index 436ceaf..99a44ad 100644
--- a/test/integration/targets/templating_lookups/template_lookups/mock_lookup_plugins/77788.py
+++ b/test/integration/targets/templating_lookups/template_lookups/mock_lookup_plugins/77788.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
from ansible.plugins.lookup import LookupBase
diff --git a/test/integration/targets/test_utils/scripts/timeout.py b/test/integration/targets/test_utils/scripts/timeout.py
index f88f3e4..9960712 100755
--- a/test/integration/targets/test_utils/scripts/timeout.py
+++ b/test/integration/targets/test_utils/scripts/timeout.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import annotations
import argparse
import subprocess
diff --git a/test/integration/targets/throttle/test_throttle.py b/test/integration/targets/throttle/test_throttle.py
index 1a5bdd3..95bb217 100755
--- a/test/integration/targets/throttle/test_throttle.py
+++ b/test/integration/targets/throttle/test_throttle.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import sys
diff --git a/test/integration/targets/unarchive/aliases b/test/integration/targets/unarchive/aliases
index 961b205..62ef2f7 100644
--- a/test/integration/targets/unarchive/aliases
+++ b/test/integration/targets/unarchive/aliases
@@ -1,3 +1,4 @@
needs/root
shippable/posix/group2
destructive
+setup/always/setup_passlib_controller # required for setup_test_user
diff --git a/test/integration/targets/unarchive/tasks/prepare_tests.yml b/test/integration/targets/unarchive/tasks/prepare_tests.yml
index 98a8ba1..fa8de52 100644
--- a/test/integration/targets/unarchive/tasks/prepare_tests.yml
+++ b/test/integration/targets/unarchive/tasks/prepare_tests.yml
@@ -5,7 +5,7 @@
- name: Ensure required binaries are present
package:
name: "{{ unarchive_packages }}"
- when: ansible_pkg_mgr in ('yum', 'dnf', 'apt', 'pkgng')
+ when: ansible_pkg_mgr in ('dnf', 'apt', 'pkgng')
- name: prep our file
copy:
diff --git a/test/integration/targets/unarchive/tasks/test_download.yml b/test/integration/targets/unarchive/tasks/test_download.yml
index 241f11b..a133bf5 100644
--- a/test/integration/targets/unarchive/tasks/test_download.yml
+++ b/test/integration/targets/unarchive/tasks/test_download.yml
@@ -6,19 +6,9 @@
- name: Test TLS download
block:
- - name: Install packages to make TLS connections work on CentOS 6
- pip:
- name:
- - urllib3==1.10.2
- - ndg_httpsclient==0.4.4
- - pyOpenSSL==16.2.0
- state: present
- when:
- - ansible_facts.distribution == 'CentOS'
- - not ansible_facts.python.has_sslcontext
- name: unarchive a tar from an URL
unarchive:
- src: "https://releases.ansible.com/ansible/ansible-latest.tar.gz"
+ src: "https://ci-files.testing.ansible.com/test/integration/targets/apt/echo-hello-source.tar.gz"
dest: "{{ remote_tmp_dir }}/test-unarchive-tar-gz"
mode: "0700"
remote_src: yes
@@ -28,16 +18,6 @@
that:
- "unarchive13.changed == true"
always:
- - name: Uninstall CentOS 6 TLS connections packages
- pip:
- name:
- - urllib3
- - ndg_httpsclient
- - pyOpenSSL
- state: absent
- when:
- - ansible_facts.distribution == 'CentOS'
- - not ansible_facts.python.has_sslcontext
- name: remove our tar.gz unarchive destination
file:
path: '{{ remote_tmp_dir }}/test-unarchive-tar-gz'
diff --git a/test/integration/targets/unarchive/tasks/test_missing_binaries.yml b/test/integration/targets/unarchive/tasks/test_missing_binaries.yml
index 49f862b..6d6a80f 100644
--- a/test/integration/targets/unarchive/tasks/test_missing_binaries.yml
+++ b/test/integration/targets/unarchive/tasks/test_missing_binaries.yml
@@ -1,5 +1,5 @@
- name: Test missing binaries
- when: ansible_pkg_mgr in ('yum', 'dnf', 'apt', 'pkgng')
+ when: ansible_pkg_mgr in ('dnf', 'apt', 'pkgng')
block:
- name: Remove zip binaries
package:
@@ -39,7 +39,7 @@
environment:
PATH: "{{ ENV_PATH }}"
vars:
- ENV_PATH: "{{ lookup('env', 'PATH') | regex_replace(re, '') }}"
+ ENV_PATH: "{{ ansible_env['PATH']| regex_replace(re, '') }}"
re: "[^A-Za-z](\/usr\/bin:?)"
- name: Ensure tasks worked as expected
diff --git a/test/integration/targets/unarchive/tasks/test_symlink.yml b/test/integration/targets/unarchive/tasks/test_symlink.yml
index fcb7282..a511ddd 100644
--- a/test/integration/targets/unarchive/tasks/test_symlink.yml
+++ b/test/integration/targets/unarchive/tasks/test_symlink.yml
@@ -62,3 +62,65 @@
file:
path: '{{ remote_tmp_dir }}/test-unarchive-tar-gz'
state: absent
+
+- name: Create a destination dir
+ file:
+ path: "{{ remote_tmp_dir }}/test-symlink"
+ state: directory
+
+- name: Create files
+ file:
+ path: "{{ remote_tmp_dir }}/test-symlink/{{ item }}"
+ state: touch
+ loop:
+ - file1
+ - file2
+
+- name: Create a symlink to the file
+ file:
+ path: "{{ remote_tmp_dir }}/test-symlink/link1"
+ src: "{{ remote_tmp_dir }}/test-symlink/file1"
+ state: link
+
+- name: Create archive of symlink
+ shell: tar czvf {{ remote_tmp_dir }}/link1.tar.gz link1 chdir={{ remote_tmp_dir }}/test-symlink
+
+- name: Change target of symlink
+ file:
+ path: "{{ remote_tmp_dir }}/test-symlink/link1"
+ src: "{{ remote_tmp_dir }}/test-symlink/file2"
+ state: link
+
+- name: Unarchive when symlink differs
+ unarchive:
+ src: "{{ remote_tmp_dir }}/link1.tar.gz"
+ dest: "{{ remote_tmp_dir }}/test-symlink"
+ remote_src: yes
+ register: unarchive_13
+
+- name: Assert that unarchive was performed
+ assert:
+ that:
+ - unarchive_13.changed == true
+
+- name: Unarchive when symlink is the same
+ unarchive:
+ src: "{{ remote_tmp_dir }}/link1.tar.gz"
+ dest: "{{ remote_tmp_dir }}/test-symlink"
+ remote_src: yes
+ register: unarchive_13
+
+- name: Assert that unarchive was not performed
+ assert:
+ that:
+ - "unarchive_13.changed == false"
+
+- name: Remove files
+ file:
+ path: "{{ remote_tmp_dir }}/test-symlink/{{ item }}"
+ state: absent
+ with_items:
+ - file1
+ - file2
+ - link1
+ - link1.tar.gz
diff --git a/test/integration/targets/unexpected_executor_exception/action_plugins/unexpected.py b/test/integration/targets/unexpected_executor_exception/action_plugins/unexpected.py
index 77fe58f..358ff34 100644
--- a/test/integration/targets/unexpected_executor_exception/action_plugins/unexpected.py
+++ b/test/integration/targets/unexpected_executor_exception/action_plugins/unexpected.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
from ansible.plugins.action import ActionBase
diff --git a/test/integration/targets/until/action_plugins/shell_no_failed.py b/test/integration/targets/until/action_plugins/shell_no_failed.py
index 594c014..5072b47 100644
--- a/test/integration/targets/until/action_plugins/shell_no_failed.py
+++ b/test/integration/targets/until/action_plugins/shell_no_failed.py
@@ -1,8 +1,7 @@
# Copyright: (c) 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
diff --git a/test/integration/targets/uri/files/testserver.py b/test/integration/targets/uri/files/testserver.py
index 24967d4..3a83724 100644
--- a/test/integration/targets/uri/files/testserver.py
+++ b/test/integration/targets/uri/files/testserver.py
@@ -1,23 +1,15 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
+import http.server
+import socketserver
import sys
if __name__ == '__main__':
- if sys.version_info[0] >= 3:
- import http.server
- import socketserver
- PORT = int(sys.argv[1])
+ PORT = int(sys.argv[1])
- class Handler(http.server.SimpleHTTPRequestHandler):
- pass
+ class Handler(http.server.SimpleHTTPRequestHandler):
+ pass
- Handler.extensions_map['.json'] = 'application/json'
- httpd = socketserver.TCPServer(("", PORT), Handler)
- httpd.serve_forever()
- else:
- import mimetypes
- mimetypes.init()
- mimetypes.add_type('application/json', '.json')
- import SimpleHTTPServer
- SimpleHTTPServer.test()
+ Handler.extensions_map['.json'] = 'application/json'
+ httpd = socketserver.TCPServer(("", PORT), Handler)
+ httpd.serve_forever()
diff --git a/test/integration/targets/uri/tasks/install-socat-and-test-unix-socket.yml b/test/integration/targets/uri/tasks/install-socat-and-test-unix-socket.yml
new file mode 100644
index 0000000..92c0a90
--- /dev/null
+++ b/test/integration/targets/uri/tasks/install-socat-and-test-unix-socket.yml
@@ -0,0 +1,25 @@
+- when: ansible_facts.distribution not in ['MacOSX']
+ block:
+ - name: install socat
+ package:
+ name: socat
+ state: present
+ register: socat_install_package
+ when: ansible_facts.distribution not in ['Alpine']
+
+ - name: install socat for alpine
+ command: apk add --virtual .socat socat
+ register: socat_install_alpine
+ when: ansible_facts.distribution == 'Alpine'
+
+ - include_tasks: unix-socket.yml
+ always:
+ - name: uninstall socat
+ package:
+ name: socat
+ state: absent
+ when: socat_install_package|default({}) is changed
+
+ - name: uninstall socat for alpine
+ command: apk del .socat
+ when: socat_install_alpine|default({}) is changed and 'Installing socat' in socat_install_alpine.stdout
diff --git a/test/integration/targets/uri/tasks/main.yml b/test/integration/targets/uri/tasks/main.yml
index ddae83a..a818107 100644
--- a/test/integration/targets/uri/tasks/main.yml
+++ b/test/integration/targets/uri/tasks/main.yml
@@ -54,6 +54,18 @@
register: pass_checksum
with_sequence: start=0 end=4 format=pass%d
+
+- name: test basic auth with urlencoded
+ register: result
+ uri:
+ url: 'https://foo%40example.com:test%40@{{ httpbin_host }}/basic-auth/foo%40example.com/test%40'
+
+- name: Ensure basic auth credentials where URL-decoded
+ assert:
+ that:
+ - result.json.authenticated
+ - result.json.user == 'foo@example.com'
+
- name: fetch pass_json
uri: return_content=yes url=http://localhost:{{ http_port }}/{{ item }}.json
register: fetch_pass_json
@@ -321,12 +333,6 @@
url: 'https://{{ httpbin_host }}/get'
use_proxy: no
-# Ubuntu12.04 doesn't have python-urllib3, this makes handling required dependencies a pain across all variations
-# We'll use this to just skip 12.04 on those tests. We should be sufficiently covered with other OSes and versions
-- name: Set fact if running on Ubuntu 12.04
- set_fact:
- is_ubuntu_precise: "{{ ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'precise' }}"
-
- name: Test that SNI succeeds on python versions that have SNI
uri:
url: 'https://{{ sni_host }}/'
@@ -341,128 +347,6 @@
- 'sni_host in result.content'
when: ansible_python.has_sslcontext
-- name: Verify SNI verification fails on old python without urllib3 contrib
- uri:
- url: 'https://{{ sni_host }}'
- ignore_errors: true
- when: not ansible_python.has_sslcontext
- register: result
-
-- name: Assert SNI verification fails on old python
- assert:
- that:
- - result is failed
- when: result is not skipped
-
-- name: check if urllib3 is installed as an OS package
- package:
- name: "{{ uri_os_packages[ansible_os_family].urllib3 }}"
- check_mode: yes
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool and uri_os_packages[ansible_os_family].urllib3|default
- register: urllib3
-
-- name: uninstall conflicting urllib3 pip package
- pip:
- name: urllib3
- state: absent
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool and uri_os_packages[ansible_os_family].urllib3|default and urllib3.changed
-
-- name: install OS packages that are needed for SNI on old python
- package:
- name: "{{ item }}"
- with_items: "{{ uri_os_packages[ansible_os_family].step1 | default([]) }}"
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool
-
-- name: install python modules for Older Python SNI verification
- pip:
- name: "{{ item }}"
- with_items:
- - ndg-httpsclient
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool
-
-- name: Verify SNI verification succeeds on old python with urllib3 contrib
- uri:
- url: 'https://{{ sni_host }}'
- return_content: true
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool
- register: result
-
-- name: Assert SNI verification succeeds on old python
- assert:
- that:
- - result is successful
- - 'sni_host in result.content'
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool
-
-- name: Uninstall ndg-httpsclient
- pip:
- name: "{{ item }}"
- state: absent
- with_items:
- - ndg-httpsclient
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool
-
-- name: uninstall OS packages that are needed for SNI on old python
- package:
- name: "{{ item }}"
- state: absent
- with_items: "{{ uri_os_packages[ansible_os_family].step1 | default([]) }}"
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool
-
-- name: install OS packages that are needed for building cryptography
- package:
- name: "{{ item }}"
- with_items: "{{ uri_os_packages[ansible_os_family].step2 | default([]) }}"
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool
-
-- name: create constraints path
- set_fact:
- remote_constraints: "{{ remote_tmp_dir }}/constraints.txt"
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool
-
-- name: create constraints file
- copy:
- content: |
- cryptography == 2.1.4
- idna == 2.5
- pyopenssl == 17.5.0
- six == 1.13.0
- urllib3 == 1.23
- dest: "{{ remote_constraints }}"
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool
-
-- name: install urllib3 and pyopenssl via pip
- pip:
- name: "{{ item }}"
- extra_args: "-c {{ remote_constraints }}"
- with_items:
- - urllib3
- - PyOpenSSL
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool
-
-- name: Verify SNI verification succeeds on old python with pip urllib3 contrib
- uri:
- url: 'https://{{ sni_host }}'
- return_content: true
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool
- register: result
-
-- name: Assert SNI verification succeeds on old python with pip urllib3 contrib
- assert:
- that:
- - result is successful
- - 'sni_host in result.content'
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool
-
-- name: Uninstall urllib3 and PyOpenSSL
- pip:
- name: "{{ item }}"
- state: absent
- with_items:
- - urllib3
- - PyOpenSSL
- when: not ansible_python.has_sslcontext and not is_ubuntu_precise|bool
-
- name: validate the status_codes are correct
uri:
url: "https://{{ httpbin_host }}/status/202"
@@ -761,6 +645,22 @@
that:
- "'content' in file_out.stdout"
+- name: Test downloading cached file
+ uri:
+ url: "https://{{ httpbin_host }}/cache"
+
+- name: Test downloading cached file to existing file results in "304 Not Modified"
+ uri:
+ url: "https://{{ httpbin_host }}/cache"
+ dest: "{{ remote_tmp_dir }}/output"
+ status_code: [304]
+
+- name: Test downloading cached file to existing file with "force"
+ uri:
+ url: "https://{{ httpbin_host }}/cache"
+ dest: "{{ remote_tmp_dir }}/output"
+ force: true
+
- name: Clean up
file:
dest: "{{ remote_tmp_dir }}/output"
@@ -815,6 +715,7 @@
environment:
KRB5_CONFIG: '{{ krb5_config }}'
KRB5CCNAME: FILE:{{ remote_tmp_dir }}/krb5.cc
+ OPENSSL_CONF: '{{ krb5_openssl_conf }}'
when: krb5_config is defined
- name: Test ciphers
@@ -822,3 +723,17 @@
- name: Test use_netrc.yml
import_tasks: use_netrc.yml
+
+- name: Test unix socket
+ import_tasks: install-socat-and-test-unix-socket.yml
+
+- name: ensure skip action
+ uri:
+ url: http://example.com
+ check_mode: True
+ register: uri_check
+
+- name: check that we skipped at action
+ assert:
+ that:
+ - uri_check.msg == "This action (uri) does not support check mode."
diff --git a/test/integration/targets/uri/tasks/unix-socket.yml b/test/integration/targets/uri/tasks/unix-socket.yml
new file mode 100644
index 0000000..6e6cf83
--- /dev/null
+++ b/test/integration/targets/uri/tasks/unix-socket.yml
@@ -0,0 +1,36 @@
+- name: Bind socat to socket
+ command: socat UNIX-LISTEN:{{ remote_tmp_dir }}/{{ item.name }}.sock,fork,reuseaddr TCP4:{{ httpbin_host }}:{{ item.port }}
+ loop:
+ - port: 80
+ name: http
+ - port: 443
+ name: https
+ async: 10
+ poll: 0
+
+- name: Test http connection to unix socket
+ uri:
+ url: http://localhost/get
+ unix_socket: '{{ remote_tmp_dir }}/http.sock'
+ register: unix_socket_http
+
+- name: Test https connection to unix socket with valdiate_certs=false
+ uri:
+ url: https://localhost/get
+ unix_socket: '{{ remote_tmp_dir }}/https.sock'
+ # Ignore ssl verification since we list the host as localhost
+ # to ensure we really are connecting over the socket
+ validate_certs: false
+ register: unix_socket_https_no_validate
+
+- name: Test https connection to unix socket
+ uri:
+ url: https://{{ httpbin_host }}/get
+ unix_socket: '{{ remote_tmp_dir }}/https.sock'
+ register: unix_socket_https
+
+- assert:
+ that:
+ - unix_socket_http.json is defined
+ - unix_socket_https_no_validate.json is defined
+ - unix_socket_https.json is defined
diff --git a/test/integration/targets/uri/tasks/use_netrc.yml b/test/integration/targets/uri/tasks/use_netrc.yml
index 521f8eb..1559f36 100644
--- a/test/integration/targets/uri/tasks/use_netrc.yml
+++ b/test/integration/targets/uri/tasks/use_netrc.yml
@@ -25,7 +25,7 @@
fail_msg: "Was expecting 'foo:bar' in base64, but received: {{ response_failed }}"
success_msg: "Expected to fail because netrc is using Basic authentication by default"
-- name: Test Bearer authorization is successfull with use_netrc=False
+- name: Test Bearer authorization is successful with use_netrc=False
uri:
url: https://{{ httpbin_host }}/bearer
use_netrc: false
@@ -36,14 +36,14 @@
NETRC: "{{ remote_tmp_dir }}/netrc"
register: response
-- name: assert Test Bearer authorization is successfull with use_netrc=False
+- name: assert Test Bearer authorization is successful with use_netrc=False
assert:
that:
- response.status == 200
- response.json.token == 'foobar'
- response.url == 'https://{{ httpbin_host }}/bearer'
fail_msg: "Was expecting successful Bearer authentication, but received: {{ response }}"
- success_msg: "Bearer authentication successfull when netrc is ignored."
+ success_msg: "Bearer authentication successful when netrc is ignored."
- name: Clean up
file:
diff --git a/test/integration/targets/uri/vars/main.yml b/test/integration/targets/uri/vars/main.yml
deleted file mode 100644
index 83a740b..0000000
--- a/test/integration/targets/uri/vars/main.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-uri_os_packages:
- RedHat:
- urllib3: python-urllib3
- step1:
- - python-pyasn1
- - pyOpenSSL
- - python-urllib3
- step2:
- - libffi-devel
- - openssl-devel
- - python-devel
- Debian:
- step1:
- - python-pyasn1
- - python-openssl
- - python-urllib3
- step2:
- - libffi-dev
- - libssl-dev
- - python-dev
diff --git a/test/integration/targets/user/tasks/test_create_user_password.yml b/test/integration/targets/user/tasks/test_create_user_password.yml
index 02aae00..f22ef6b 100644
--- a/test/integration/targets/user/tasks/test_create_user_password.yml
+++ b/test/integration/targets/user/tasks/test_create_user_password.yml
@@ -1,5 +1,5 @@
# test user add with password
-- name: add an encrypted password for user
+- name: add an sha512 password for user
user:
name: ansibulluser
password: "$6$rounds=656000$TT4O7jz2M57npccl$33LF6FcUMSW11qrESXL1HX0BS.bsiT6aenFLLiVpsQh6hDtI9pJh5iY7x8J7ePkN4fP8hmElidHXaeD51pbGS."
@@ -88,3 +88,15 @@
- "'warnings' not in test_user_encrypt3"
- "'warnings' not in test_user_encrypt4"
- "'warnings' not in test_user_encrypt5"
+
+- name: add an yescrypt password for user
+ user:
+ name: ansibulluser
+ password: "$y$jCT$ZiF3ZV39/maUl9Lzt2Hk80$Ih6bI4OXU52OnWWqt3T1BAmVn8eH.4qlcP.8/NOjGN5" #gitleaks:allow
+ state: present
+ update_password: always
+ register: test_user_encrypt6
+
+- name: there should not be warnings
+ assert:
+ that: "'warnings' not in test_user_encrypt6"
diff --git a/test/integration/targets/user/tasks/test_local.yml b/test/integration/targets/user/tasks/test_local.yml
index 217d476..c49ab0c 100644
--- a/test/integration/targets/user/tasks/test_local.yml
+++ b/test/integration/targets/user/tasks/test_local.yml
@@ -224,8 +224,6 @@
- name: Ensure warnings were displayed properly
assert:
that:
- - local_user_test_1['warnings'] | length > 0
- - local_user_test_1['warnings'] | first is search('The local user account may already exist')
- local_user_test_5['warnings'] is search("'append' is set, but no 'groups' are specified. Use 'groups'")
- local_existing['warnings'] is not defined
when: ansible_facts.system in ['Linux']
diff --git a/test/integration/targets/var_precedence/ansible-var-precedence-check.py b/test/integration/targets/var_precedence/ansible-var-precedence-check.py
index b03c87b..6511169 100755
--- a/test/integration/targets/var_precedence/ansible-var-precedence-check.py
+++ b/test/integration/targets/var_precedence/ansible-var-precedence-check.py
@@ -3,8 +3,7 @@
# A tool to check the order of precedence for ansible variables
# https://github.com/ansible/ansible/blob/devel/test/integration/test_var_precedence.yml
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import os
diff --git a/test/integration/targets/wait_for/files/testserver.py b/test/integration/targets/wait_for/files/testserver.py
index 2b728b6..452a045 100644
--- a/test/integration/targets/wait_for/files/testserver.py
+++ b/test/integration/targets/wait_for/files/testserver.py
@@ -1,19 +1,11 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
+import http.server
+import socketserver
import sys
if __name__ == '__main__':
- if sys.version_info[0] >= 3:
- import http.server
- import socketserver
- PORT = int(sys.argv[1])
- Handler = http.server.SimpleHTTPRequestHandler
- httpd = socketserver.TCPServer(("", PORT), Handler)
- httpd.serve_forever()
- else:
- import mimetypes
- mimetypes.init()
- mimetypes.add_type('application/json', '.json')
- import SimpleHTTPServer
- SimpleHTTPServer.test()
+ PORT = int(sys.argv[1])
+ Handler = http.server.SimpleHTTPRequestHandler
+ httpd = socketserver.TCPServer(("", PORT), Handler)
+ httpd.serve_forever()
diff --git a/test/integration/targets/wait_for/files/write_utf16.py b/test/integration/targets/wait_for/files/write_utf16.py
index 6079ed3..fca04ca 100644
--- a/test/integration/targets/wait_for/files/write_utf16.py
+++ b/test/integration/targets/wait_for/files/write_utf16.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import sys
diff --git a/test/integration/targets/wait_for/files/zombie.py b/test/integration/targets/wait_for/files/zombie.py
index 913074e..19437ea 100644
--- a/test/integration/targets/wait_for/files/zombie.py
+++ b/test/integration/targets/wait_for/files/zombie.py
@@ -1,5 +1,4 @@
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import os
import sys
diff --git a/test/integration/targets/wait_for/tasks/main.yml b/test/integration/targets/wait_for/tasks/main.yml
index 74b8e9a..fd63c34 100644
--- a/test/integration/targets/wait_for/tasks/main.yml
+++ b/test/integration/targets/wait_for/tasks/main.yml
@@ -114,14 +114,12 @@
path: "{{remote_tmp_dir}}/utf16.txt"
search_regex: completed
-- name: test non mmapable file
+- name: test non mmapable file, skip OSs w/o /sys
wait_for:
path: "/sys/class/net/lo/carrier"
search_regex: "1"
timeout: 30
- when:
- - ansible_facts['os_family'] not in ['FreeBSD', 'Darwin']
- - not (ansible_facts['os_family'] in ['RedHat', 'CentOS'] and ansible_facts['distribution_major_version'] is version('7', '<='))
+ when: ansible_os_family not in ['FreeBSD', 'Darwin']
- name: test wait for port timeout
wait_for:
@@ -167,9 +165,9 @@
- waitfor is not changed
- "waitfor.port == http_port"
-- name: install psutil using pip (non-Linux only)
+- name: install psutil using pip (non-Linux)
pip:
- name: psutil==5.8.0
+ name: psutil==5.9.8
when: ansible_system != 'Linux'
- name: Copy zombie.py
diff --git a/test/integration/targets/want_json_modules_posix/library/helloworld.py b/test/integration/targets/want_json_modules_posix/library/helloworld.py
index 80f8761..e32a203 100644
--- a/test/integration/targets/want_json_modules_posix/library/helloworld.py
+++ b/test/integration/targets/want_json_modules_posix/library/helloworld.py
@@ -16,8 +16,7 @@
# WANT_JSON
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import sys
diff --git a/test/integration/targets/win_exec_wrapper/action_plugins/test_rc_1.py b/test/integration/targets/win_exec_wrapper/action_plugins/test_rc_1.py
index 60cffde..1cc92b8 100644
--- a/test/integration/targets/win_exec_wrapper/action_plugins/test_rc_1.py
+++ b/test/integration/targets/win_exec_wrapper/action_plugins/test_rc_1.py
@@ -1,5 +1,6 @@
# Copyright: (c) 2023, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+from __future__ import annotations
import json
diff --git a/test/integration/targets/yum/aliases b/test/integration/targets/yum/aliases
deleted file mode 100644
index b12f354..0000000
--- a/test/integration/targets/yum/aliases
+++ /dev/null
@@ -1,4 +0,0 @@
-destructive
-shippable/posix/group1
-skip/freebsd
-skip/macos
diff --git a/test/integration/targets/yum/files/yum.conf b/test/integration/targets/yum/files/yum.conf
deleted file mode 100644
index 5a5fca6..0000000
--- a/test/integration/targets/yum/files/yum.conf
+++ /dev/null
@@ -1,5 +0,0 @@
-[main]
-gpgcheck=1
-installonly_limit=3
-clean_requirements_on_remove=True
-tsflags=nodocs
diff --git a/test/integration/targets/yum/filter_plugins/filter_list_of_tuples_by_first_param.py b/test/integration/targets/yum/filter_plugins/filter_list_of_tuples_by_first_param.py
deleted file mode 100644
index 306ccd9..0000000
--- a/test/integration/targets/yum/filter_plugins/filter_list_of_tuples_by_first_param.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-
-def filter_list_of_tuples_by_first_param(lst, search, startswith=False):
- out = []
- for element in lst:
- if startswith:
- if element[0].startswith(search):
- out.append(element)
- else:
- if search in element[0]:
- out.append(element)
- return out
-
-
-class FilterModule(object):
- ''' filter '''
-
- def filters(self):
- return {
- 'filter_list_of_tuples_by_first_param': filter_list_of_tuples_by_first_param,
- }
diff --git a/test/integration/targets/yum/meta/main.yml b/test/integration/targets/yum/meta/main.yml
deleted file mode 100644
index 34d8126..0000000
--- a/test/integration/targets/yum/meta/main.yml
+++ /dev/null
@@ -1,4 +0,0 @@
-dependencies:
- - prepare_tests
- - setup_rpm_repo
- - setup_remote_tmp_dir
diff --git a/test/integration/targets/yum/tasks/cacheonly.yml b/test/integration/targets/yum/tasks/cacheonly.yml
deleted file mode 100644
index 03cbd0e..0000000
--- a/test/integration/targets/yum/tasks/cacheonly.yml
+++ /dev/null
@@ -1,16 +0,0 @@
----
-- name: Test cacheonly (clean before testing)
- command: yum clean all
-
-- name: Try installing from cache where it has been cleaned
- yum:
- name: sos
- state: latest
- cacheonly: true
- register: yum_result
- ignore_errors: true
-
-- name: Verify yum failure
- assert:
- that:
- - "yum_result is failed"
diff --git a/test/integration/targets/yum/tasks/check_mode_consistency.yml b/test/integration/targets/yum/tasks/check_mode_consistency.yml
deleted file mode 100644
index e2a99d9..0000000
--- a/test/integration/targets/yum/tasks/check_mode_consistency.yml
+++ /dev/null
@@ -1,61 +0,0 @@
-- name: install htop in check mode to verify changes dict returned
- yum:
- name: htop
- state: present
- check_mode: yes
- register: yum_changes_check_mode_result
-
-- name: install verify changes dict returned in check mode
- assert:
- that:
- - "yum_changes_check_mode_result is success"
- - "yum_changes_check_mode_result is changed"
- - "'changes' in yum_changes_check_mode_result"
- - "'installed' in yum_changes_check_mode_result['changes']"
- - "'htop' in yum_changes_check_mode_result['changes']['installed']"
-
-- name: install htop to verify changes dict returned
- yum:
- name: htop
- state: present
- register: yum_changes_result
-
-- name: install verify changes dict returned
- assert:
- that:
- - "yum_changes_result is success"
- - "yum_changes_result is changed"
- - "'changes' in yum_changes_result"
- - "'installed' in yum_changes_result['changes']"
- - "'htop' in yum_changes_result['changes']['installed']"
-
-- name: remove htop in check mode to verify changes dict returned
- yum:
- name: htop
- state: absent
- check_mode: yes
- register: yum_changes_check_mode_result
-
-- name: remove verify changes dict returned in check mode
- assert:
- that:
- - "yum_changes_check_mode_result is success"
- - "yum_changes_check_mode_result is changed"
- - "'changes' in yum_changes_check_mode_result"
- - "'removed' in yum_changes_check_mode_result['changes']"
- - "'htop' in yum_changes_check_mode_result['changes']['removed']"
-
-- name: remove htop to verify changes dict returned
- yum:
- name: htop
- state: absent
- register: yum_changes_result
-
-- name: remove verify changes dict returned
- assert:
- that:
- - "yum_changes_result is success"
- - "yum_changes_result is changed"
- - "'changes' in yum_changes_result"
- - "'removed' in yum_changes_result['changes']"
- - "'htop' in yum_changes_result['changes']['removed']"
diff --git a/test/integration/targets/yum/tasks/lock.yml b/test/integration/targets/yum/tasks/lock.yml
deleted file mode 100644
index 3f585c1..0000000
--- a/test/integration/targets/yum/tasks/lock.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-- block:
- - name: Make sure testing package is not installed
- yum:
- name: sos
- state: absent
-
- - name: Create bogus lock file
- copy:
- content: bogus content for this lock file
- dest: /var/run/yum.pid
-
- - name: Install a package, lock file should be deleted by the module
- yum:
- name: sos
- state: present
- register: yum_result
-
- - assert:
- that:
- - yum_result is success
-
- always:
- - name: Clean up
- yum:
- name: sos
- state: absent
-
- when: ansible_pkg_mgr == 'yum'
diff --git a/test/integration/targets/yum/tasks/main.yml b/test/integration/targets/yum/tasks/main.yml
deleted file mode 100644
index 157124a..0000000
--- a/test/integration/targets/yum/tasks/main.yml
+++ /dev/null
@@ -1,82 +0,0 @@
-# (c) 2014, James Tanner <tanner.jc@gmail.com>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-# Note: We install the yum package onto Fedora so that this will work on dnf systems
-# We want to test that for people who don't want to upgrade their systems.
-
-- block:
- - name: ensure test packages are removed before starting
- yum:
- name:
- - sos
- state: absent
-
- - import_tasks: yum.yml
- always:
- - name: remove installed packages
- yum:
- name:
- - sos
- state: absent
-
- - name: remove installed group
- yum:
- name: "@Custom Group"
- state: absent
-
- - name: On Fedora 28 the above won't remove the group which results in a failure in repo.yml below
- yum:
- name: dinginessentail
- state: absent
- when:
- - ansible_distribution in ['Fedora']
-
- when:
- - ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora']
-
-
-- block:
- - import_tasks: repo.yml
- - import_tasks: yum_group_remove.yml
- when:
- - ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux']
- always:
- - yum_repository:
- name: "{{ item }}"
- state: absent
- loop: "{{ repos }}"
-
- - command: yum clean metadata
- when:
- - ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora']
-
-
-- import_tasks: yuminstallroot.yml
- when:
- - ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora']
-
-
-- import_tasks: proxy.yml
- when:
- - ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora']
-
-
-- import_tasks: check_mode_consistency.yml
- when:
- - (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and ansible_distribution_major_version|int == 7)
-
-
-- import_tasks: lock.yml
- when:
- - ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux']
-
-- import_tasks: multiarch.yml
- when:
- - ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux']
- - ansible_architecture == 'x86_64'
- # Our output parsing expects us to be on yum, not dnf
- - ansible_distribution_major_version is version('7', '<=')
-
-- import_tasks: cacheonly.yml
- when:
- - ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux', 'Fedora']
diff --git a/test/integration/targets/yum/tasks/multiarch.yml b/test/integration/targets/yum/tasks/multiarch.yml
deleted file mode 100644
index bced634..0000000
--- a/test/integration/targets/yum/tasks/multiarch.yml
+++ /dev/null
@@ -1,154 +0,0 @@
-- block:
- - name: Set up test yum repo
- yum_repository:
- name: multiarch-test-repo
- description: ansible-test multiarch test repo
- baseurl: "{{ multiarch_repo_baseurl }}"
- gpgcheck: no
- repo_gpgcheck: no
-
- - name: Install two out of date packages from the repo
- yum:
- name:
- - multiarch-a-1.0
- - multiarch-b-1.0
- register: outdated
-
- - name: See what we installed
- command: rpm -q multiarch-a multiarch-b
- register: rpm_q
-
- # Here we assume we're running on x86_64 (and limit to this in main.yml)
- # (avoid comparing ansible_architecture because we only have test RPMs
- # for i686 and x86_64 and ansible_architecture could be other things.)
- - name: Assert that we got the right architecture
- assert:
- that:
- - outdated is changed
- - outdated.changes.installed | length == 2
- - rpm_q.stdout_lines | length == 2
- - rpm_q.stdout_lines[0].endswith('x86_64')
- - rpm_q.stdout_lines[1].endswith('x86_64')
-
- - name: Install the same versions, but i686 instead
- yum:
- name:
- - multiarch-a-1.0*.i686
- - multiarch-b-1.0*.i686
- register: outdated_i686
-
- - name: See what we installed
- command: rpm -q multiarch-a multiarch-b
- register: rpm_q
-
- - name: Assert that all four are installed
- assert:
- that:
- - outdated_i686 is changed
- - outdated.changes.installed | length == 2
- - rpm_q.stdout_lines | length == 4
-
- - name: Update them all to 2.0
- yum:
- name: multiarch-*
- state: latest
- update_only: true
- register: yum_latest
-
- - name: Assert that all were updated and shown in results
- assert:
- that:
- - yum_latest is changed
- # This is just testing UI stability. The behavior is arguably not
- # correct, because multiple packages are being updated. But the
- # "because of (at least)..." wording kinda locks us in to only
- # showing one update in this case. :(
- - yum_latest.changes.updated | length == 1
-
- - name: Downgrade them so we can upgrade them a different way
- yum:
- name:
- - multiarch-a-1.0*
- - multiarch-b-1.0*
- allow_downgrade: true
- register: downgrade
-
- - name: See what we installed
- command: rpm -q multiarch-a multiarch-b --queryformat '%{name}-%{version}.%{arch}\n'
- register: rpm_q
-
- - name: Ensure downgrade worked
- assert:
- that:
- - downgrade is changed
- - rpm_q.stdout_lines | sort == ['multiarch-a-1.0.i686', 'multiarch-a-1.0.x86_64', 'multiarch-b-1.0.i686', 'multiarch-b-1.0.x86_64']
-
- # This triggers a different branch of logic that the partial wildcard
- # above, but we're limited to check_mode here since it's '*'.
- - name: Upgrade with full wildcard
- yum:
- name: '*'
- state: latest
- update_only: true
- update_cache: true
- check_mode: true
- register: full_wildcard
-
- # https://github.com/ansible/ansible/issues/73284
- - name: Ensure we report things correctly (both arches)
- assert:
- that:
- - full_wildcard is changed
- - full_wildcard.changes.updated | filter_list_of_tuples_by_first_param('multiarch', startswith=True) | length == 4
-
- - name: Downgrade them so we can upgrade them a different way
- yum:
- name:
- - multiarch-a-1.0*
- - multiarch-b-1.0*
- allow_downgrade: true
- register: downgrade
-
- - name: Try to install again via virtual provides, should be unchanged
- yum:
- name:
- - virtual-provides-multiarch-a
- - virtual-provides-multiarch-b
- state: present
- register: install_vp
-
- - name: Ensure the above did not change
- assert:
- that:
- - install_vp is not changed
-
- - name: Try to upgrade via virtual provides
- yum:
- name:
- - virtual-provides-multiarch-a
- - virtual-provides-multiarch-b
- state: latest
- update_only: true
- register: upgrade_vp
-
- - name: Ensure we report things correctly (both arches)
- assert:
- that:
- - upgrade_vp is changed
- # This is just testing UI stability, like above.
- # We'll only have one package in "updated" per spec, even though
- # (in this case) two are getting updated per spec.
- - upgrade_vp.changes.updated | length == 2
-
- always:
- - name: Remove test yum repo
- yum_repository:
- name: multiarch-test-repo
- state: absent
-
- - name: Remove all test packages installed
- yum:
- name:
- - multiarch-*
- - virtual-provides-multiarch-*
- state: absent
diff --git a/test/integration/targets/yum/tasks/proxy.yml b/test/integration/targets/yum/tasks/proxy.yml
deleted file mode 100644
index b011d11..0000000
--- a/test/integration/targets/yum/tasks/proxy.yml
+++ /dev/null
@@ -1,186 +0,0 @@
-- name: test yum proxy settings
- block:
- - name: install tinyproxy
- yum:
- name: 'https://ci-files.testing.ansible.com/test/integration/targets/yum/tinyproxy-1.10.0-3.el7.x86_64.rpm'
- state: installed
-
- # systemd doesn't play nice with this in a container for some reason
- - name: start tinyproxy (systemd with tiny proxy does not work in container)
- shell: tinyproxy
- changed_when: false
-
- # test proxy without auth
- - name: set unauthenticated proxy in yum.conf
- lineinfile:
- path: /etc/yum.conf
- line: "proxy=http://127.0.0.1:8888"
- state: present
-
- - name: clear proxy logs
- shell: ': > /var/log/tinyproxy/tinyproxy.log'
- changed_when: false
- args:
- executable: /usr/bin/bash
-
- - name: install ninvaders with unauthenticated proxy
- yum:
- name: 'https://ci-files.testing.ansible.com/test/integration/targets/yum/ninvaders-0.1.1-18.el7.x86_64.rpm'
- state: installed
- register: yum_proxy_result
-
- - assert:
- that:
- - "yum_proxy_result.changed"
- - "'msg' in yum_proxy_result"
- - "'rc' in yum_proxy_result"
-
- - name: check that it install via unauthenticated proxy
- command: grep -q Request /var/log/tinyproxy/tinyproxy.log
-
- - name: uninstall ninvaders with unauthenticated proxy
- yum:
- name: ninvaders
- state: absent
- register: yum_proxy_result
-
- - assert:
- that:
- - "yum_proxy_result.changed"
- - "'msg' in yum_proxy_result"
- - "'rc' in yum_proxy_result"
-
- - name: unset unauthenticated proxy in yum.conf
- lineinfile:
- path: /etc/yum.conf
- line: "proxy=http://127.0.0.1:8888"
- state: absent
-
- # test proxy with auth
- - name: set authenticated proxy config in tinyproxy.conf
- lineinfile:
- path: /etc/tinyproxy/tinyproxy.conf
- line: "BasicAuth 1testuser 1testpassword"
- state: present
-
- # systemd doesn't play nice with this in a container for some reason
- - name: SIGHUP tinyproxy to reload config (workaround because of systemd+tinyproxy in container)
- shell: kill -HUP $(ps -ef | grep tinyproxy | grep -v grep | awk '{print $2}')
- changed_when: false
- args:
- executable: /usr/bin/bash
-
- - name: set authenticated proxy config in yum.conf
- lineinfile:
- path: /etc/yum.conf
- line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
- state: present
-
- - name: clear proxy logs
- shell: ': > /var/log/tinyproxy/tinyproxy.log'
- changed_when: false
- args:
- executable: /usr/bin/bash
-
- - name: install ninvaders with authenticated proxy
- yum:
- name: 'https://ci-files.testing.ansible.com/test/integration/targets/yum/ninvaders-0.1.1-18.el7.x86_64.rpm'
- state: installed
- register: yum_proxy_result
-
- - assert:
- that:
- - "yum_proxy_result.changed"
- - "'msg' in yum_proxy_result"
- - "'rc' in yum_proxy_result"
-
- - name: check that it install via authenticated proxy
- command: grep -q Request /var/log/tinyproxy/tinyproxy.log
-
- - name: uninstall ninvaders with authenticated proxy
- yum:
- name: ninvaders
- state: absent
-
- - name: unset authenticated proxy config in yum.conf
- lineinfile:
- path: /etc/yum.conf
- line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
- state: absent
-
- - name: set proxy config in yum.conf
- lineinfile:
- path: /etc/yum.conf
- line: "proxy=http://127.0.0.1:8888"
- state: present
-
- - name: set proxy_username config in yum.conf
- lineinfile:
- path: /etc/yum.conf
- line: "proxy_username=1testuser"
- state: present
-
- - name: set proxy_password config in yum.conf
- lineinfile:
- path: /etc/yum.conf
- line: "proxy_password=1testpassword"
- state: present
-
- - name: clear proxy logs
- shell: ': > /var/log/tinyproxy/tinyproxy.log'
- changed_when: false
- args:
- executable: /usr/bin/bash
-
- - name: install ninvaders with proxy, proxy_username, and proxy_password config in yum.conf
- yum:
- name: 'https://ci-files.testing.ansible.com/test/integration/targets/yum/ninvaders-0.1.1-18.el7.x86_64.rpm'
- state: installed
- register: yum_proxy_result
-
- - assert:
- that:
- - "yum_proxy_result.changed"
- - "'msg' in yum_proxy_result"
- - "'rc' in yum_proxy_result"
-
- - name: check that it install via proxy with proxy_username, proxy_password config in yum.conf
- command: grep -q Request /var/log/tinyproxy/tinyproxy.log
-
- always:
- #cleanup
- - name: uninstall tinyproxy
- yum:
- name: tinyproxy
- state: absent
-
- - name: uninstall ninvaders
- yum:
- name: ninvaders
- state: absent
-
- - name: ensure unset authenticated proxy
- lineinfile:
- path: /etc/yum.conf
- line: "proxy=http://1testuser:1testpassword@127.0.0.1:8888"
- state: absent
-
- - name: ensure unset proxy
- lineinfile:
- path: /etc/yum.conf
- line: "proxy=http://127.0.0.1:8888"
- state: absent
-
- - name: ensure unset proxy_username
- lineinfile:
- path: /etc/yum.conf
- line: "proxy_username=1testuser"
- state: absent
-
- - name: ensure unset proxy_password
- lineinfile:
- path: /etc/yum.conf
- line: "proxy_password=1testpassword"
- state: absent
- when:
- - (ansible_distribution in ['RedHat', 'CentOS', 'ScientificLinux'] and ansible_distribution_major_version|int == 7 and ansible_architecture in ['x86_64'])
diff --git a/test/integration/targets/yum/tasks/repo.yml b/test/integration/targets/yum/tasks/repo.yml
deleted file mode 100644
index f312b1c..0000000
--- a/test/integration/targets/yum/tasks/repo.yml
+++ /dev/null
@@ -1,729 +0,0 @@
-- block:
- - name: Install dinginessentail-1.0-1
- yum:
- name: dinginessentail-1.0-1
- state: present
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- # ============================================================================
- - name: Install dinginessentail-1.0-1 again
- yum:
- name: dinginessentail-1.0-1
- state: present
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "not yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- # ============================================================================
- - name: Install dinginessentail-1:1.0-2
- yum:
- name: "dinginessentail-1:1.0-2.{{ ansible_architecture }}"
- state: present
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
-
- - name: Remove dinginessentail
- yum:
- name: dinginessentail
- state: absent
- # ============================================================================
- - name: Downgrade dinginessentail
- yum:
- name: dinginessentail-1.0-1
- state: present
- allow_downgrade: yes
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- # ============================================================================
- - name: Update to the latest dinginessentail
- yum:
- name: dinginessentail
- state: latest
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.1-1')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- # ============================================================================
- - name: Install dinginessentail-1.0-1 from a file (higher version is already installed)
- yum:
- name: "{{ repodir }}/dinginessentail-1.0-1.{{ ansible_architecture }}.rpm"
- state: present
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "not yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.1-1')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
-
- - name: Remove dinginessentail
- yum:
- name: dinginessentail
- state: absent
- # ============================================================================
- - name: Install dinginessentail-1.0-1 from a file
- yum:
- name: "{{ repodir }}/dinginessentail-1.0-1.{{ ansible_architecture }}.rpm"
- state: present
- disable_gpg_check: true
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- # ============================================================================
- - name: Install dinginessentail-1.0-1 from a file again
- yum:
- name: "{{ repodir }}/dinginessentail-1.0-1.{{ ansible_architecture }}.rpm"
- state: present
- disable_gpg_check: true
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "not yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- # ============================================================================
- - name: Install dinginessentail-1.0-2 from a file
- yum:
- name: "{{ repodir }}/dinginessentail-1.0-2.{{ ansible_architecture }}.rpm"
- state: present
- disable_gpg_check: true
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- # ============================================================================
- - name: Install dinginessentail-1.0-2 from a file again
- yum:
- name: "{{ repodir }}/dinginessentail-1.0-2.{{ ansible_architecture }}.rpm"
- state: present
- disable_gpg_check: true
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "not yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- # ============================================================================
- - name: Try to downgrade dinginessentail without allow_downgrade being set
- yum:
- name: dinginessentail-1.0-1
- state: present
- allow_downgrade: no
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "not yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- # ============================================================================
- - name: Update dinginessentail with update_only set
- yum:
- name: dinginessentail
- state: latest
- update_only: yes
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.1-1')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
-
- - name: Remove dinginessentail
- yum:
- name: dinginessentail
- state: absent
- # ============================================================================
- - name: Try to update dinginessentail which is not installed, update_only is set
- yum:
- name: dinginessentail
- state: latest
- update_only: yes
- register: yum_result
- ignore_errors: yes
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
- ignore_errors: yes
-
- - name: Verify installation
- assert:
- that:
- - "rpm_result.rc == 1"
- - "yum_result.rc == 0"
- - "not yum_result.changed"
- - "not yum_result is failed"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- # ============================================================================
- - name: Try to install incompatible arch
- yum:
- name: "{{ repodir_ppc64 }}/dinginessentail-1.0-1.ppc64.rpm"
- state: present
- register: yum_result
- ignore_errors: yes
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
- ignore_errors: yes
-
- - name: Verify installation
- assert:
- that:
- - "rpm_result.rc == 1"
- - "yum_result.rc == 1"
- - "not yum_result.changed"
- - "yum_result is failed"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- # ============================================================================
- - name: Make sure latest dinginessentail is installed
- yum:
- name: dinginessentail
- state: latest
-
- - name: Downgrade dinginessentail using rpm file
- yum:
- name: "{{ repodir }}/dinginessentail-1.0-1.{{ ansible_architecture }}.rpm"
- state: present
- allow_downgrade: yes
- disable_gpg_check: yes
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- # ============================================================================
- - block:
- - name: make sure dinginessentail is not installed
- yum:
- name: dinginessentail
- state: absent
-
- - name: install dinginessentail both archs
- yum:
- name: "{{ pkgs }}"
- state: present
- disable_gpg_check: true
- vars:
- pkgs:
- - "{{ repodir }}/dinginessentail-1.1-1.x86_64.rpm"
- - "{{ repodir_i686 }}/dinginessentail-1.1-1.i686.rpm"
-
- - name: try to install lower version of dinginessentail from rpm file, without allow_downgrade, just one arch
- yum:
- name: "{{ repodir_i686 }}/dinginessentail-1.0-1.i686.rpm"
- state: present
- register: yum_result
-
- - name: check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: verify installation
- assert:
- that:
- - "not yum_result.changed"
- - "rpm_result.stdout_lines[0].startswith('dinginessentail-1.1-1')"
- - "rpm_result.stdout_lines[1].startswith('dinginessentail-1.1-1')"
-
- - name: verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- when: ansible_architecture == "x86_64"
- # ============================================================================
- - block:
- - name: make sure dinginessentail is not installed
- yum:
- name: dinginessentail
- state: absent
-
- - name: install dinginessentail both archs
- yum:
- name: "{{ pkgs }}"
- state: present
- disable_gpg_check: true
- vars:
- pkgs:
- - "{{ repodir }}/dinginessentail-1.0-1.x86_64.rpm"
- - "{{ repodir_i686 }}/dinginessentail-1.0-1.i686.rpm"
-
- - name: Update both arch in one task using rpm files
- yum:
- name: "{{ repodir }}/dinginessentail-1.1-1.x86_64.rpm,{{ repodir_i686 }}/dinginessentail-1.1-1.i686.rpm"
- state: present
- disable_gpg_check: yes
- register: yum_result
-
- - name: check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: verify installation
- assert:
- that:
- - "yum_result.changed"
- - "rpm_result.stdout_lines[0].startswith('dinginessentail-1.1-1')"
- - "rpm_result.stdout_lines[1].startswith('dinginessentail-1.1-1')"
-
- - name: verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- when: ansible_architecture == "x86_64"
- # ============================================================================
- always:
- - name: Clean up
- yum:
- name: dinginessentail
- state: absent
-
-# FIXME: dnf currently doesn't support epoch as part of it's pkg_spec for
-# finding install candidates
-# https://bugzilla.redhat.com/show_bug.cgi?id=1619687
-- block:
- - name: Install 1:dinginessentail-1.0-2
- yum:
- name: "1:dinginessentail-1.0-2.{{ ansible_architecture }}"
- state: present
- disable_gpg_check: true
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- always:
- - name: Clean up
- yum:
- name: dinginessentail
- state: absent
-
- when: ansible_pkg_mgr == 'yum'
-
-# DNF1 (Fedora < 26) had some issues:
-# - did not accept architecture tag as valid component of a package spec unless
-# installing a file (i.e. can't search the repo)
-# - doesn't handle downgrade transactions via the API properly, marks it as a
-# conflict
-#
-# NOTE: Both DNF1 and Fedora < 26 have long been EOL'd by their respective
-# upstreams
-- block:
- # ============================================================================
- - name: Install dinginessentail-1.0-2
- yum:
- name: "dinginessentail-1.0-2.{{ ansible_architecture }}"
- state: present
- disable_gpg_check: true
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
-
- - name: Install dinginessentail-1.0-2 again
- yum:
- name: dinginessentail-1.0-2
- state: present
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "not yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0-2')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- always:
- - name: Clean up
- yum:
- name: dinginessentail
- state: absent
- when: not (ansible_distribution == "Fedora" and ansible_distribution_major_version|int < 26)
-
-# https://github.com/ansible/ansible/issues/47689
-- block:
- - name: Install dinginessentail == 1.0
- yum:
- name: "dinginessentail == 1.0"
- state: present
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0-1')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- always:
- - name: Clean up
- yum:
- name: dinginessentail
- state: absent
-
- when: ansible_pkg_mgr == 'yum'
-
-
-# https://github.com/ansible/ansible/pull/54603
-- block:
- - name: Install dinginessentail < 1.1
- yum:
- name: "dinginessentail < 1.1"
- state: present
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.0')"
-
- - name: Install dinginessentail >= 1.1
- yum:
- name: "dinginessentail >= 1.1"
- state: present
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify installation
- assert:
- that:
- - "yum_result.changed"
- - "rpm_result.stdout.startswith('dinginessentail-1.1')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
-
- always:
- - name: Clean up
- yum:
- name: dinginessentail
- state: absent
-
- when: ansible_pkg_mgr == 'yum'
-
-# https://github.com/ansible/ansible/issues/45250
-- block:
- - name: Install dinginessentail-1.0, dinginessentail-olive-1.0, landsidescalping-1.0
- yum:
- name: "dinginessentail-1.0,dinginessentail-olive-1.0,landsidescalping-1.0"
- state: present
-
- - name: Upgrade dinginessentail*
- yum:
- name: dinginessentail*
- state: latest
- register: yum_result
-
- - name: Check dinginessentail with rpm
- shell: rpm -q dinginessentail
- register: rpm_result
-
- - name: Verify update of dinginessentail
- assert:
- that:
- - "rpm_result.stdout.startswith('dinginessentail-1.1-1')"
-
- - name: Check dinginessentail-olive with rpm
- shell: rpm -q dinginessentail-olive
- register: rpm_result
-
- - name: Verify update of dinginessentail-olive
- assert:
- that:
- - "rpm_result.stdout.startswith('dinginessentail-olive-1.1-1')"
-
- - name: Check landsidescalping with rpm
- shell: rpm -q landsidescalping
- register: rpm_result
-
- - name: Verify landsidescalping did NOT get updated
- assert:
- that:
- - "rpm_result.stdout.startswith('landsidescalping-1.0-1')"
-
- - name: Verify yum module outputs
- assert:
- that:
- - "yum_result is changed"
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
- always:
- - name: Clean up
- yum:
- name: dinginessentail,dinginessentail-olive,landsidescalping
- state: absent
-
-- block:
- - yum:
- name: dinginessentail
- state: present
-
- - yum:
- list: dinginessentail*
- register: list_out
-
- - set_fact:
- passed: true
- loop: "{{ list_out.results }}"
- when: item.yumstate == 'installed'
-
- - name: Test that there is yumstate=installed in the result
- assert:
- that:
- - passed is defined
- always:
- - name: Clean up
- yum:
- name: dinginessentail
- state: absent
diff --git a/test/integration/targets/yum/tasks/yum.yml b/test/integration/targets/yum/tasks/yum.yml
deleted file mode 100644
index 511c577..0000000
--- a/test/integration/targets/yum/tasks/yum.yml
+++ /dev/null
@@ -1,884 +0,0 @@
-# Setup by setup_rpm_repo
-- set_fact:
- package1: dinginessentail
- package2: dinginessentail-olive
-
-# UNINSTALL
-- name: uninstall {{ package1 }}
- yum: name={{ package1 }} state=removed
- register: yum_result
-
-- name: check {{ package1 }} with rpm
- shell: rpm -q {{ package1 }}
- ignore_errors: True
- register: rpm_result
-
-- name: verify uninstallation of {{ package1 }}
- assert:
- that:
- - "yum_result is success"
- - "rpm_result is failed"
-
-# UNINSTALL AGAIN
-- name: uninstall {{ package1 }} again in check mode
- yum: name={{ package1 }} state=removed
- check_mode: true
- register: yum_result
-
-- name: verify no change on re-uninstall in check mode
- assert:
- that:
- - "not yum_result is changed"
-
-- name: uninstall {{ package1 }} again
- yum: name={{ package1 }} state=removed
- register: yum_result
-
-- name: verify no change on re-uninstall
- assert:
- that:
- - "not yum_result is changed"
-
-# INSTALL
-- name: install {{ package1 }} in check mode
- yum: name={{ package1 }} state=present
- check_mode: true
- register: yum_result
-
-- name: verify installation of {{ package1 }} in check mode
- assert:
- that:
- - "yum_result is changed"
-
-- name: install {{ package1 }}
- yum: name={{ package1 }} state=present
- register: yum_result
-
-- name: verify installation of {{ package1 }}
- assert:
- that:
- - "yum_result is success"
- - "yum_result is changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
- - "'results' in yum_result"
-
-- name: check {{ package1 }} with rpm
- shell: rpm -q {{ package1 }}
-
-# INSTALL AGAIN
-- name: install {{ package1 }} again in check mode
- yum: name={{ package1 }} state=present
- check_mode: true
- register: yum_result
-- name: verify no change on second install in check mode
- assert:
- that:
- - "not yum_result is changed"
-
-- name: install {{ package1 }} again
- yum: name={{ package1 }} state=present
- register: yum_result
-- name: verify no change on second install
- assert:
- that:
- - "not yum_result is changed"
-
-- name: install {{ package1 }} again with empty string enablerepo
- yum: name={{ package1 }} state=present enablerepo=""
- register: yum_result
-- name: verify no change on third install with empty string enablerepo
- assert:
- that:
- - "yum_result is success"
- - "not yum_result is changed"
-
-# This test case is unfortunately distro specific because we have to specify
-# repo names which are not the same across Fedora/RHEL/CentOS for base/updates
-- name: install {{ package1 }} again with missing repo enablerepo
- yum:
- name: '{{ package1 }}'
- state: present
- enablerepo: '{{ repos + ["thisrepodoesnotexist"] }}'
- disablerepo: "*"
- register: yum_result
- when: ansible_distribution == 'CentOS'
-- name: verify no change on fourth install with missing repo enablerepo (yum)
- assert:
- that:
- - "yum_result is success"
- - "yum_result is not changed"
- when: ansible_distribution == 'CentOS'
-
-# This test case is unfortunately distro specific because we have to specify
-# repo names which are not the same across Fedora/RHEL/CentOS for base/updates
-- name: install repos again with disable all and enable select repo(s)
- yum:
- name: '{{ package1 }}'
- state: present
- enablerepo: '{{ repos }}'
- disablerepo: "*"
- register: yum_result
- when: ansible_distribution == 'CentOS'
-- name: verify no change on fourth install with missing repo enablerepo (yum)
- assert:
- that:
- - "yum_result is success"
- - "yum_result is not changed"
- when: ansible_distribution == 'CentOS'
-
-- name: install {{ package1 }} again with only missing repo enablerepo
- yum:
- name: '{{ package1 }}'
- state: present
- enablerepo: "thisrepodoesnotexist"
- ignore_errors: true
- register: yum_result
-- name: verify no change on fifth install with only missing repo enablerepo (yum)
- assert:
- that:
- - "yum_result is not success"
- when: ansible_pkg_mgr == 'yum'
-- name: verify no change on fifth install with only missing repo enablerepo (dnf)
- assert:
- that:
- - "yum_result is success"
- when: ansible_pkg_mgr == 'dnf'
-
-# INSTALL AGAIN WITH LATEST
-- name: install {{ package1 }} again with state latest in check mode
- yum: name={{ package1 }} state=latest
- check_mode: true
- register: yum_result
-- name: verify install {{ package1 }} again with state latest in check mode
- assert:
- that:
- - "not yum_result is changed"
-
-- name: install {{ package1 }} again with state latest idempotence
- yum: name={{ package1 }} state=latest
- register: yum_result
-- name: verify install {{ package1 }} again with state latest idempotence
- assert:
- that:
- - "not yum_result is changed"
-
-# INSTALL WITH LATEST
-- name: uninstall {{ package1 }}
- yum: name={{ package1 }} state=removed
- register: yum_result
-- name: verify uninstall {{ package1 }}
- assert:
- that:
- - "yum_result is successful"
-
-- name: copy yum.conf file in case it is missing
- copy:
- src: yum.conf
- dest: /etc/yum.conf
- force: False
- register: yum_conf_copy
-
-- block:
- - name: install {{ package1 }} with state latest in check mode with config file param
- yum: name={{ package1 }} state=latest conf_file=/etc/yum.conf
- check_mode: true
- register: yum_result
- - name: verify install {{ package1 }} with state latest in check mode with config file param
- assert:
- that:
- - "yum_result is changed"
-
- always:
- - name: remove tmp yum.conf file if we created it
- file:
- path: /etc/yum.conf
- state: absent
- when: yum_conf_copy is changed
-
-- name: install {{ package1 }} with state latest in check mode
- yum: name={{ package1 }} state=latest
- check_mode: true
- register: yum_result
-- name: verify install {{ package1 }} with state latest in check mode
- assert:
- that:
- - "yum_result is changed"
-
-- name: install {{ package1 }} with state latest
- yum: name={{ package1 }} state=latest
- register: yum_result
-- name: verify install {{ package1 }} with state latest
- assert:
- that:
- - "yum_result is changed"
-
-- name: install {{ package1 }} with state latest idempotence
- yum: name={{ package1 }} state=latest
- register: yum_result
-- name: verify install {{ package1 }} with state latest idempotence
- assert:
- that:
- - "not yum_result is changed"
-
-- name: install {{ package1 }} with state latest idempotence with config file param
- yum: name={{ package1 }} state=latest
- register: yum_result
-- name: verify install {{ package1 }} with state latest idempotence with config file param
- assert:
- that:
- - "not yum_result is changed"
-
-
-# Multiple packages
-- name: uninstall {{ package1 }} and {{ package2 }}
- yum: name={{ package1 }},{{ package2 }} state=removed
-
-- name: check {{ package1 }} with rpm
- shell: rpm -q {{ package1 }}
- ignore_errors: True
- register: rpm_package1_result
-
-- name: check {{ package2 }} with rpm
- shell: rpm -q {{ package2 }}
- ignore_errors: True
- register: rpm_package2_result
-
-- name: verify packages installed
- assert:
- that:
- - "rpm_package1_result is failed"
- - "rpm_package2_result is failed"
-
-- name: install {{ package1 }} and {{ package2 }} as comma separated
- yum: name={{ package1 }},{{ package2 }} state=present
- register: yum_result
-
-- name: verify packages installed
- assert:
- that:
- - "yum_result is success"
- - "yum_result is changed"
-
-- name: check {{ package1 }} with rpm
- shell: rpm -q {{ package1 }}
-
-- name: check {{ package2 }} with rpm
- shell: rpm -q {{ package2 }}
-
-- name: uninstall {{ package1 }} and {{ package2 }}
- yum: name={{ package1 }},{{ package2 }} state=removed
- register: yum_result
-
-- name: install {{ package1 }} and {{ package2 }} as list
- yum:
- name:
- - '{{ package1 }}'
- - '{{ package2 }}'
- state: present
- register: yum_result
-
-- name: verify packages installed
- assert:
- that:
- - "yum_result is success"
- - "yum_result is changed"
-
-- name: check {{ package1 }} with rpm
- shell: rpm -q {{ package1 }}
-
-- name: check {{ package2 }} with rpm
- shell: rpm -q {{ package2 }}
-
-- name: uninstall {{ package1 }} and {{ package2 }}
- yum: name={{ package1 }},{{ package2 }} state=removed
- register: yum_result
-
-- name: install {{ package1 }} and {{ package2 }} as comma separated with spaces
- yum:
- name: "{{ package1 }}, {{ package2 }}"
- state: present
- register: yum_result
-
-- name: verify packages installed
- assert:
- that:
- - "yum_result is success"
- - "yum_result is changed"
-
-- name: check {{ package1 }} with rpm
- shell: rpm -q {{ package1 }}
-
-- name: check {{ package2 }} with rpm
- shell: rpm -q {{ package2 }}
-
-- name: uninstall {{ package1 }} and {{ package2 }}
- yum: name={{ package1 }},{{ package2 }} state=removed
-
-- name: install non-existent rpm
- yum:
- name: does-not-exist
- register: non_existent_rpm
- ignore_errors: True
-
-- name: check non-existent rpm install failed
- assert:
- that:
- - non_existent_rpm is failed
-
-# Install in installroot='/'
-- name: install {{ package1 }}
- yum: name={{ package1 }} state=present installroot='/'
- register: yum_result
-
-- name: verify installation of {{ package1 }}
- assert:
- that:
- - "yum_result is success"
- - "yum_result is changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
- - "'results' in yum_result"
-
-- name: check {{ package1 }} with rpm
- shell: rpm -q {{ package1 }} --root=/
-
-- name: uninstall {{ package1 }}
- yum:
- name: '{{ package1 }}'
- installroot: '/'
- state: removed
- register: yum_result
-
-# Seems like some yum versions won't download a package from local file repository, continue to use sos for this test.
-# https://stackoverflow.com/questions/58295660/yum-downloadonly-ignores-packages-in-local-repo
-- name: Test download_only
- yum:
- name: sos
- state: latest
- download_only: true
- register: yum_result
-
-- name: verify download of sos (part 1 -- yum "install" succeeded)
- assert:
- that:
- - "yum_result is success"
- - "yum_result is changed"
-
-- name: uninstall sos (noop)
- yum:
- name: sos
- state: removed
- register: yum_result
-
-- name: verify download of sos (part 2 -- nothing removed during uninstall)
- assert:
- that:
- - "yum_result is success"
- - "not yum_result is changed"
-
-- name: uninstall sos for downloadonly/downloaddir test
- yum:
- name: sos
- state: absent
-
-- name: Test download_only/download_dir
- yum:
- name: sos
- state: latest
- download_only: true
- download_dir: "/var/tmp/packages"
- register: yum_result
-
-- name: verify yum output
- assert:
- that:
- - "yum_result is success"
- - "yum_result is changed"
-
-- command: "ls /var/tmp/packages"
- register: ls_out
-
-- name: Verify specified download_dir was used
- assert:
- that:
- - "'sos' in ls_out.stdout"
-
-- name: install group
- yum:
- name: "@Custom Group"
- state: present
- register: yum_result
-
-- name: verify installation of the group
- assert:
- that:
- - "yum_result is success"
- - "yum_result is changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
- - "'results' in yum_result"
-
-- name: install the group again
- yum:
- name: "@Custom Group"
- state: present
- register: yum_result
-
-- name: verify nothing changed
- assert:
- that:
- - "yum_result is success"
- - "not yum_result is changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
- - "'results' in yum_result"
-
-- name: install the group again but also with a package that is not yet installed
- yum:
- name:
- - "@Custom Group"
- - '{{ package2 }}'
- state: present
- register: yum_result
-
-- name: verify {{ package3 }} is installed
- assert:
- that:
- - "yum_result is success"
- - "yum_result is changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
- - "'results' in yum_result"
-
-- name: try to install the group again, with --check to check 'changed'
- yum:
- name: "@Custom Group"
- state: present
- check_mode: yes
- register: yum_result
-
-- name: verify nothing changed
- assert:
- that:
- - "not yum_result is changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
- - "'results' in yum_result"
-
-- name: try to install non existing group
- yum:
- name: "@non-existing-group"
- state: present
- register: yum_result
- ignore_errors: True
-
-- name: verify installation of the non existing group failed
- assert:
- that:
- - "yum_result is failed"
- - "not yum_result is changed"
- - "yum_result is failed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
- - "'results' in yum_result"
-
-- name: try to install non existing file
- yum:
- name: /tmp/non-existing-1.0.0.fc26.noarch.rpm
- state: present
- register: yum_result
- ignore_errors: yes
-
-- name: verify installation failed
- assert:
- that:
- - "yum_result is failed"
- - "not yum_result is changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
-
-- name: try to install from non existing url
- yum:
- name: https://ci-files.testing.ansible.com/test/integration/targets/yum/non-existing-1.0.0.fc26.noarch.rpm
- state: present
- register: yum_result
- ignore_errors: yes
-
-- name: verify installation failed
- assert:
- that:
- - "yum_result is failed"
- - "not yum_result is changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
-
-- name: use latest to install httpd
- yum:
- name: httpd
- state: latest
- register: yum_result
-
-- name: verify httpd was installed
- assert:
- that:
- - "'changed' in yum_result"
-
-- name: uninstall httpd
- yum:
- name: httpd
- state: removed
-
-- name: update httpd only if it exists
- yum:
- name: httpd
- state: latest
- update_only: yes
- register: yum_result
-
-- name: verify httpd not installed
- assert:
- that:
- - "not yum_result is changed"
- - "'Packages providing httpd not installed due to update_only specified' in yum_result.results"
-
-- name: try to install uncompatible arch rpm on non-ppc64le, should fail
- yum:
- name: https://ci-files.testing.ansible.com/test/integration/targets/yum/banner-1.3.4-3.el7.ppc64le.rpm
- state: present
- register: yum_result
- ignore_errors: True
- when:
- - ansible_architecture not in ['ppc64le']
-
-- name: verify that yum failed on non-ppc64le
- assert:
- that:
- - "not yum_result is changed"
- - "yum_result is failed"
- when:
- - ansible_architecture not in ['ppc64le']
-
-- name: try to install uncompatible arch rpm on ppc64le, should fail
- yum:
- name: https://ci-files.testing.ansible.com/test/integration/targets/yum/tinyproxy-1.10.0-3.el7.x86_64.rpm
- state: present
- register: yum_result
- ignore_errors: True
- when:
- - ansible_architecture in ['ppc64le']
-
-- name: verify that yum failed on ppc64le
- assert:
- that:
- - "not yum_result is changed"
- - "yum_result is failed"
- when:
- - ansible_architecture in ['ppc64le']
-
-# setup for testing installing an RPM from url
-
-- set_fact:
- pkg_name: noarchfake
- pkg_path: '{{ repodir }}/noarchfake-1.0-1.noarch.rpm'
-
-- name: cleanup
- yum:
- name: "{{ pkg_name }}"
- state: absent
-
-# setup end
-
-- name: install a local noarch rpm from file
- yum:
- name: "{{ pkg_path }}"
- state: present
- disable_gpg_check: true
- register: yum_result
-
-- name: verify installation
- assert:
- that:
- - "yum_result is success"
- - "yum_result is changed"
- - "yum_result is not failed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
- - "'results' in yum_result"
-
-- name: install the downloaded rpm again
- yum:
- name: "{{ pkg_path }}"
- state: present
- register: yum_result
-
-- name: verify installation
- assert:
- that:
- - "yum_result is success"
- - "not yum_result is changed"
- - "yum_result is not failed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
- - "'results' in yum_result"
-
-- name: clean up
- yum:
- name: "{{ pkg_name }}"
- state: absent
-
-- name: install from url
- yum:
- name: "file://{{ pkg_path }}"
- state: present
- disable_gpg_check: true
- register: yum_result
-
-- name: verify installation
- assert:
- that:
- - "yum_result is success"
- - "yum_result is changed"
- - "yum_result is not failed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
- - "'results' in yum_result"
-
-- name: Create a temp RPM file which does not contain nevra information
- file:
- name: "/tmp/non_existent_pkg.rpm"
- state: touch
-
-- name: Try installing RPM file which does not contain nevra information
- yum:
- name: "/tmp/non_existent_pkg.rpm"
- state: present
- register: no_nevra_info_result
- ignore_errors: yes
-
-- name: Verify RPM failed to install
- assert:
- that:
- - "'changed' in no_nevra_info_result"
- - "'msg' in no_nevra_info_result"
-
-- name: Delete a temp RPM file
- file:
- name: "/tmp/non_existent_pkg.rpm"
- state: absent
-
-- name: get yum version
- yum:
- list: yum
- register: yum_version
-
-- name: set yum_version of installed version
- set_fact:
- yum_version: "{%- if item.yumstate == 'installed' -%}{{ item.version }}{%- else -%}{{ yum_version }}{%- endif -%}"
- with_items: "{{ yum_version.results }}"
-
-- name: Ensure double uninstall of wildcard globs works
- block:
- - name: "Install lohit-*-fonts"
- yum:
- name: "lohit-*-fonts"
- state: present
-
- - name: "Remove lohit-*-fonts (1st time)"
- yum:
- name: "lohit-*-fonts"
- state: absent
- register: remove_lohit_fonts_1
-
- - name: "Verify lohit-*-fonts (1st time)"
- assert:
- that:
- - "remove_lohit_fonts_1 is changed"
- - "'msg' in remove_lohit_fonts_1"
- - "'results' in remove_lohit_fonts_1"
-
- - name: "Remove lohit-*-fonts (2nd time)"
- yum:
- name: "lohit-*-fonts"
- state: absent
- register: remove_lohit_fonts_2
-
- - name: "Verify lohit-*-fonts (2nd time)"
- assert:
- that:
- - "remove_lohit_fonts_2 is not changed"
- - "'msg' in remove_lohit_fonts_2"
- - "'results' in remove_lohit_fonts_2"
- - "'lohit-*-fonts is not installed' in remove_lohit_fonts_2['results']"
-
-- block:
- - name: uninstall {{ package2 }}
- yum: name={{ package2 }} state=removed
-
- - name: check {{ package2 }} with rpm
- shell: rpm -q {{ package2 }}
- ignore_errors: True
- register: rpm_package2_result
-
- - name: verify {{ package2 }} is uninstalled
- assert:
- that:
- - "rpm_package2_result is failed"
-
- - name: exclude {{ package2 }} (yum backend)
- lineinfile:
- dest: /etc/yum.conf
- regexp: (^exclude=)(.)*
- line: "exclude={{ package2 }}*"
- state: present
- when: ansible_pkg_mgr == 'yum'
-
- - name: exclude {{ package2 }} (dnf backend)
- lineinfile:
- dest: /etc/dnf/dnf.conf
- regexp: (^excludepkgs=)(.)*
- line: "excludepkgs={{ package2 }}*"
- state: present
- when: ansible_pkg_mgr == 'dnf'
-
- # begin test case where disable_excludes is supported
- - name: Try install {{ package2 }} without disable_excludes
- yum: name={{ package2 }} state=latest
- register: yum_package2_result
- ignore_errors: True
-
- - name: verify {{ package2 }} did not install because it is in exclude list
- assert:
- that:
- - "yum_package2_result is failed"
-
- - name: install {{ package2 }} with disable_excludes
- yum: name={{ package2 }} state=latest disable_excludes=all
- register: yum_package2_result_using_excludes
-
- - name: verify {{ package2 }} did install using disable_excludes=all
- assert:
- that:
- - "yum_package2_result_using_excludes is success"
- - "yum_package2_result_using_excludes is changed"
- - "yum_package2_result_using_excludes is not failed"
-
- - name: remove exclude {{ package2 }} (cleanup yum.conf)
- lineinfile:
- dest: /etc/yum.conf
- regexp: (^exclude={{ package2 }}*)
- line: "exclude="
- state: present
- when: ansible_pkg_mgr == 'yum'
-
- - name: remove exclude {{ package2 }} (cleanup dnf.conf)
- lineinfile:
- dest: /etc/dnf/dnf.conf
- regexp: (^excludepkgs={{ package2 }}*)
- line: "excludepkgs="
- state: present
- when: ansible_pkg_mgr == 'dnf'
-
- # Fedora < 26 has a bug in dnf where package excludes in dnf.conf aren't
- # actually honored and those releases are EOL'd so we have no expectation they
- # will ever be fixed
- when: not ((ansible_distribution == "Fedora") and (ansible_distribution_major_version|int < 26))
-
-- name: Check that packages with Provides are handled correctly in state=absent
- block:
- - name: Install test packages
- yum:
- name:
- - https://ci-files.testing.ansible.com/test/integration/targets/yum/test-package-that-provides-toaster-1.3.3.7-1.el7.noarch.rpm
- - https://ci-files.testing.ansible.com/test/integration/targets/yum/toaster-1.2.3.4-1.el7.noarch.rpm
- disable_gpg_check: true
- register: install
-
- - name: Remove toaster
- yum:
- name: toaster
- state: absent
- register: remove
-
- - name: rpm -qa
- command: rpm -qa
- register: rpmqa
-
- - assert:
- that:
- - install is successful
- - install is changed
- - remove is successful
- - remove is changed
- - "'toaster-1.2.3.4' not in rpmqa.stdout"
- - "'test-package-that-provides-toaster' in rpmqa.stdout"
- always:
- - name: Remove test packages
- yum:
- name:
- - test-package-that-provides-toaster
- - toaster
- state: absent
-
-- yum:
- list: "{{ package1 }}"
- register: list_out
-
-- name: check that both yum and dnf return envra
- assert:
- that:
- - '"envra" in list_out["results"][0]'
-
-- name: check that dnf returns nevra for backwards compat
- assert:
- that:
- - '"nevra" in list_out["results"][0]'
- when: ansible_pkg_mgr == 'dnf'
diff --git a/test/integration/targets/yum/tasks/yum_group_remove.yml b/test/integration/targets/yum/tasks/yum_group_remove.yml
deleted file mode 100644
index 22c6dcb..0000000
--- a/test/integration/targets/yum/tasks/yum_group_remove.yml
+++ /dev/null
@@ -1,152 +0,0 @@
-- name: install a group to test and yum-utils
- yum:
- name: "{{ pkgs }}"
- state: present
- vars:
- pkgs:
- - "@Custom Group"
- - yum-utils
- when: ansible_pkg_mgr == "yum"
-
-- name: install a group to test and dnf-utils
- yum:
- name: "{{ pkgs }}"
- state: present
- vars:
- pkgs:
- - "@Custom Group"
- - dnf-utils
- when: ansible_pkg_mgr == "dnf"
-
-- name: check mode remove the group
- yum:
- name: "@Custom Group"
- state: absent
- check_mode: yes
- register: yum_result
-
-- name: verify changed
- assert:
- that:
- - "yum_result.changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'results' in yum_result"
-
-- name: remove the group
- yum:
- name: "@Custom Group"
- state: absent
- register: yum_result
-
-- name: verify changed
- assert:
- that:
- - "yum_result.rc == 0"
- - "yum_result.changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
- - "'results' in yum_result"
-
-- name: remove the group again
- yum:
- name: "@Custom Group"
- state: absent
- register: yum_result
-
-- name: verify changed
- assert:
- that:
- - "not yum_result.changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
- - "'results' in yum_result"
-
-- name: check mode remove the group again
- yum:
- name: "@Custom Group"
- state: absent
- check_mode: yes
- register: yum_result
-
-- name: verify changed
- assert:
- that:
- - "not yum_result.changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'results' in yum_result"
-
-- name: install a group and a package to test
- yum:
- name: "@Custom Group,sos"
- state: present
- register: yum_output
-
-- name: check mode remove the group along with the package
- yum:
- name: "@Custom Group,sos"
- state: absent
- register: yum_result
- check_mode: yes
-
-- name: verify changed
- assert:
- that:
- - "yum_result.changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'results' in yum_result"
-
-- name: remove the group along with the package
- yum:
- name: "@Custom Group,sos"
- state: absent
- register: yum_result
-
-- name: verify changed
- assert:
- that:
- - "yum_result.changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
- - "'results' in yum_result"
-
-- name: check mode remove the group along with the package
- yum:
- name: "@Custom Group,sos"
- state: absent
- register: yum_result
- check_mode: yes
-
-- name: verify not changed
- assert:
- that:
- - "not yum_result.changed"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'results' in yum_result"
diff --git a/test/integration/targets/yum/tasks/yuminstallroot.yml b/test/integration/targets/yum/tasks/yuminstallroot.yml
deleted file mode 100644
index 028e805..0000000
--- a/test/integration/targets/yum/tasks/yuminstallroot.yml
+++ /dev/null
@@ -1,132 +0,0 @@
-# make a installroot
-- name: Create installroot
- command: mktemp -d "{{ remote_tmp_dir }}/ansible.test.XXXXXX"
- register: yumroot
-
-#- name: Populate directory
-# file:
-# path: "/{{ yumroot.stdout }}/etc/"
-# state: directory
-# mode: 0755
-#
-#- name: Populate directory2
-# copy:
-# content: "[main]\ndistropkgver={{ ansible_distribution_version }}\n"
-# dest: "/{{ yumroot.stdout }}/etc/yum.conf"
-
-- name: Make a necessary directory
- file:
- path: "{{ yumroot.stdout }}/etc/yum/vars/"
- state: directory
- mode: 0755
-
-- name: get yum releasever
- command: "{{ ansible_python_interpreter }} -c 'import yum; yb = yum.YumBase(); print(yb.conf.yumvar[\"releasever\"])'"
- register: releasever
- ignore_errors: yes
-
-- name: Populate directory
- copy:
- content: "{{ releasever.stdout_lines[-1] }}\n"
- dest: "/{{ yumroot.stdout }}/etc/yum/vars/releasever"
- when: releasever is successful
-
-# This will drag in > 200 MB.
-- name: attempt installroot
- yum: name=zlib installroot="{{ yumroot.stdout }}/" disable_gpg_check=yes
- register: yum_result
-
-- name: check sos with rpm in installroot
- shell: rpm -q zlib --root="{{ yumroot.stdout }}/"
- failed_when: False
- register: rpm_result
-
-- name: verify installation of sos
- assert:
- that:
- - "yum_result.rc == 0"
- - "yum_result.changed"
- - "rpm_result.rc == 0"
-
-- name: verify yum module outputs
- assert:
- that:
- - "'changed' in yum_result"
- - "'msg' in yum_result"
- - "'rc' in yum_result"
- - "'results' in yum_result"
-
-- name: cleanup installroot
- file:
- path: "{{ yumroot.stdout }}/"
- state: absent
-
-# Test for releasever working correctly
-#
-# Bugfix: https://github.com/ansible/ansible/issues/67050
-#
-# This test case is based on a reproducer originally reported on Reddit:
-# https://www.reddit.com/r/ansible/comments/g2ps32/ansible_yum_module_throws_up_an_error_when/
-#
-# NOTE: For the Ansible upstream CI we can only run this for RHEL7 because the
-# containerized runtimes in shippable don't allow the nested mounting of
-# buildah container volumes.
-- name: perform yuminstallroot in a buildah mount with releasever
- when:
- - ansible_facts["distribution_major_version"] == "7"
- - ansible_facts["distribution"] == "RedHat"
- block:
- - name: install required packages for buildah test
- yum:
- state: present
- name:
- - buildah
- - name: create buildah container from scratch
- command: "buildah --name yum_installroot_releasever_test from scratch"
- - name: mount the buildah container
- command: "buildah mount yum_installroot_releasever_test"
- register: buildah_mount
- - name: figure out yum value of $releasever
- shell: python -c 'import yum; yb = yum.YumBase(); print(yb.conf.yumvar["releasever"])' | tail -1
- register: buildah_host_releasever
- - name: test yum install of python using releasever
- yum:
- name: 'python'
- state: present
- installroot: "{{ buildah_mount.stdout }}"
- releasever: "{{ buildah_host_releasever.stdout }}"
- register: yum_result
- - name: verify installation of python
- assert:
- that:
- - "yum_result.rc == 0"
- - "yum_result.changed"
- - "rpm_result.rc == 0"
- - name: remove python before another test
- yum:
- name: 'python'
- state: absent
- installroot: "{{ buildah_mount.stdout }}"
- releasever: "{{ buildah_host_releasever.stdout }}"
- - name: test yum install of python using releasever with latest
- yum:
- name: 'python'
- state: latest
- installroot: "{{ buildah_mount.stdout }}"
- releasever: "{{ buildah_host_releasever.stdout }}"
- register: yum_result
- - name: verify installation of python
- assert:
- that:
- - "yum_result.rc == 0"
- - "yum_result.changed"
- - "rpm_result.rc == 0"
- always:
- - name: remove buildah container
- command: "buildah rm yum_installroot_releasever_test"
- ignore_errors: yes
- - name: remove buildah from CI system
- yum:
- state: absent
- name:
- - buildah
diff --git a/test/integration/targets/yum/vars/main.yml b/test/integration/targets/yum/vars/main.yml
deleted file mode 100644
index a2a073f..0000000
--- a/test/integration/targets/yum/vars/main.yml
+++ /dev/null
@@ -1 +0,0 @@
-multiarch_repo_baseurl: https://ci-files.testing.ansible.com/test/integration/targets/yum/multiarch-test-repo/RPMS/
diff --git a/test/lib/ansible_test/__init__.py b/test/lib/ansible_test/__init__.py
index 527d413..223f9b4 100644
--- a/test/lib/ansible_test/__init__.py
+++ b/test/lib/ansible_test/__init__.py
@@ -1,2 +1 @@
-# Empty __init__.py to allow importing of `ansible_test._util.target.common` under Python 2.x.
-# This allows the ansible-test entry point to report supported Python versions before exiting.
+# Empty __init__.py to allow relative imports to work under mypy.
diff --git a/test/lib/ansible_test/_data/completion/docker.txt b/test/lib/ansible_test/_data/completion/docker.txt
index a863ecb..b8603ec 100644
--- a/test/lib/ansible_test/_data/completion/docker.txt
+++ b/test/lib/ansible_test/_data/completion/docker.txt
@@ -1,9 +1,7 @@
-base image=quay.io/ansible/base-test-container:5.10.0 python=3.12,2.7,3.6,3.7,3.8,3.9,3.10,3.11
-default image=quay.io/ansible/default-test-container:8.12.0 python=3.12,2.7,3.6,3.7,3.8,3.9,3.10,3.11 context=collection
-default image=quay.io/ansible/ansible-core-test-container:8.12.0 python=3.12,2.7,3.6,3.7,3.8,3.9,3.10,3.11 context=ansible-core
-alpine3 image=quay.io/ansible/alpine3-test-container:6.3.0 python=3.11 cgroup=none audit=none
-centos7 image=quay.io/ansible/centos7-test-container:6.3.0 python=2.7 cgroup=v1-only
-fedora38 image=quay.io/ansible/fedora38-test-container:6.3.0 python=3.11
-opensuse15 image=quay.io/ansible/opensuse15-test-container:6.3.0 python=3.6
-ubuntu2004 image=quay.io/ansible/ubuntu2004-test-container:6.3.0 python=3.8
-ubuntu2204 image=quay.io/ansible/ubuntu2204-test-container:6.3.0 python=3.10
+base image=quay.io/ansible/base-test-container:6.2.0 python=3.12,3.7,3.8,3.9,3.10,3.11
+default image=quay.io/ansible/default-test-container:9.6.0 python=3.12,3.7,3.8,3.9,3.10,3.11 context=collection
+default image=quay.io/ansible/ansible-core-test-container:9.6.0 python=3.12,3.7,3.8,3.9,3.10,3.11 context=ansible-core
+alpine319 image=quay.io/ansible/alpine319-test-container:7.1.0 python=3.11 cgroup=none audit=none
+fedora39 image=quay.io/ansible/fedora39-test-container:7.1.0 python=3.12
+ubuntu2004 image=quay.io/ansible/ubuntu2004-test-container:7.1.0 python=3.8
+ubuntu2204 image=quay.io/ansible/ubuntu2204-test-container:7.1.0 python=3.10
diff --git a/test/lib/ansible_test/_data/completion/remote.txt b/test/lib/ansible_test/_data/completion/remote.txt
index 06d4b5e..cad7fa4 100644
--- a/test/lib/ansible_test/_data/completion/remote.txt
+++ b/test/lib/ansible_test/_data/completion/remote.txt
@@ -1,14 +1,13 @@
-alpine/3.18 python=3.11 become=doas_sudo provider=aws arch=x86_64
+alpine/3.19 python=3.11 become=doas_sudo provider=aws arch=x86_64
alpine become=doas_sudo provider=aws arch=x86_64
-fedora/38 python=3.11 become=sudo provider=aws arch=x86_64
+fedora/39 python=3.12 become=sudo provider=aws arch=x86_64
fedora become=sudo provider=aws arch=x86_64
-freebsd/13.2 python=3.9,3.11 python_dir=/usr/local/bin become=su_sudo provider=aws arch=x86_64
+freebsd/13.3 python=3.9,3.11 python_dir=/usr/local/bin become=su_sudo provider=aws arch=x86_64
+freebsd/14.0 python=3.9,3.11 python_dir=/usr/local/bin become=su_sudo provider=aws arch=x86_64
freebsd python_dir=/usr/local/bin become=su_sudo provider=aws arch=x86_64
-macos/13.2 python=3.11 python_dir=/usr/local/bin become=sudo provider=parallels arch=x86_64
+macos/14.3 python=3.11 python_dir=/usr/local/bin become=sudo provider=parallels arch=x86_64
macos python_dir=/usr/local/bin become=sudo provider=parallels arch=x86_64
-rhel/7.9 python=2.7 become=sudo provider=aws arch=x86_64
-rhel/8.8 python=3.6,3.11 become=sudo provider=aws arch=x86_64
-rhel/9.2 python=3.9,3.11 become=sudo provider=aws arch=x86_64
+rhel/9.3 python=3.9,3.11 become=sudo provider=aws arch=x86_64
rhel become=sudo provider=aws arch=x86_64
ubuntu/22.04 python=3.10 become=sudo provider=aws arch=x86_64
ubuntu become=sudo provider=aws arch=x86_64
diff --git a/test/lib/ansible_test/_data/requirements/ansible-test.txt b/test/lib/ansible_test/_data/requirements/ansible-test.txt
index 17662f0..e0bb945 100644
--- a/test/lib/ansible_test/_data/requirements/ansible-test.txt
+++ b/test/lib/ansible_test/_data/requirements/ansible-test.txt
@@ -1,5 +1,3 @@
# The test-constraints sanity test verifies this file, but changes must be made manually to keep it in up-to-date.
-virtualenv == 16.7.12 ; python_version < '3'
coverage == 7.3.2 ; python_version >= '3.8' and python_version <= '3.12'
coverage == 6.5.0 ; python_version >= '3.7' and python_version <= '3.7'
-coverage == 4.5.4 ; python_version >= '2.6' and python_version <= '3.6'
diff --git a/test/lib/ansible_test/_data/requirements/constraints.txt b/test/lib/ansible_test/_data/requirements/constraints.txt
index dd837e3..17f3638 100644
--- a/test/lib/ansible_test/_data/requirements/constraints.txt
+++ b/test/lib/ansible_test/_data/requirements/constraints.txt
@@ -1,15 +1,11 @@
# do not add a cryptography or pyopenssl constraint to this file, they require special handling, see get_cryptography_requirements in python_requirements.py
# do not add a coverage constraint to this file, it is handled internally by ansible-test
-packaging < 21.0 ; python_version < '3.6' # packaging 21.0 requires Python 3.6 or newer
+pypsrp < 1.0.0 # in case the next major version is too big of a change
pywinrm >= 0.3.0 ; python_version < '3.11' # message encryption support
pywinrm >= 0.4.3 ; python_version >= '3.11' # support for Python 3.11
-pytest < 5.0.0, >= 4.5.0 ; python_version == '2.7' # pytest 5.0.0 and later will no longer support python 2.7
-pytest >= 4.5.0 ; python_version > '2.7' # pytest 4.5.0 added support for --strict-markers
+pytest >= 4.5.0 # pytest 4.5.0 added support for --strict-markers
ntlm-auth >= 1.3.0 # message encryption support using cryptography
requests-ntlm >= 1.1.0 # message encryption support
requests-credssp >= 0.1.0 # message encryption support
-pyparsing < 3.0.0 ; python_version < '3.5' # pyparsing 3 and later require python 3.5 or later
mock >= 2.0.0 # needed for features backported from Python 3.6 unittest.mock (assert_called, assert_called_once...)
pytest-mock >= 1.4.0 # needed for mock_use_standalone_module pytest option
-setuptools < 45 ; python_version == '2.7' # setuptools 45 and later require python 3.5 or later
-wheel < 0.38.0 ; python_version < '3.7' # wheel 0.38.0 and later require python 3.7 or later
diff --git a/test/lib/ansible_test/_data/requirements/sanity.ansible-doc.txt b/test/lib/ansible_test/_data/requirements/sanity.ansible-doc.txt
index 6680145..60ef86f 100644
--- a/test/lib/ansible_test/_data/requirements/sanity.ansible-doc.txt
+++ b/test/lib/ansible_test/_data/requirements/sanity.ansible-doc.txt
@@ -1,5 +1,5 @@
# edit "sanity.ansible-doc.in" and generate with: hacking/update-sanity-requirements.py --test ansible-doc
-Jinja2==3.1.2
-MarkupSafe==2.1.3
-packaging==23.2
+Jinja2==3.1.3
+MarkupSafe==2.1.5
+packaging==24.0
PyYAML==6.0.1
diff --git a/test/lib/ansible_test/_data/requirements/sanity.changelog.txt b/test/lib/ansible_test/_data/requirements/sanity.changelog.txt
index d763bad..cc5b635 100644
--- a/test/lib/ansible_test/_data/requirements/sanity.changelog.txt
+++ b/test/lib/ansible_test/_data/requirements/sanity.changelog.txt
@@ -1,9 +1,9 @@
# edit "sanity.changelog.in" and generate with: hacking/update-sanity-requirements.py --test changelog
-antsibull-changelog==0.23.0
+antsibull-changelog==0.26.0
docutils==0.18.1
-packaging==23.2
+packaging==24.0
PyYAML==6.0.1
rstcheck==5.0.0
semantic-version==2.10.0
types-docutils==0.18.3
-typing_extensions==4.8.0
+typing_extensions==4.10.0
diff --git a/test/lib/ansible_test/_data/requirements/sanity.import.plugin.txt b/test/lib/ansible_test/_data/requirements/sanity.import.plugin.txt
index 56366b7..9116ed9 100644
--- a/test/lib/ansible_test/_data/requirements/sanity.import.plugin.txt
+++ b/test/lib/ansible_test/_data/requirements/sanity.import.plugin.txt
@@ -1,4 +1,4 @@
# edit "sanity.import.plugin.in" and generate with: hacking/update-sanity-requirements.py --test import.plugin
-Jinja2==3.1.2
-MarkupSafe==2.1.3
+Jinja2==3.1.3
+MarkupSafe==2.1.5
PyYAML==6.0.1
diff --git a/test/lib/ansible_test/_data/requirements/sanity.mypy.txt b/test/lib/ansible_test/_data/requirements/sanity.mypy.txt
index f6a47fb..651aea8 100644
--- a/test/lib/ansible_test/_data/requirements/sanity.mypy.txt
+++ b/test/lib/ansible_test/_data/requirements/sanity.mypy.txt
@@ -1,18 +1,18 @@
# edit "sanity.mypy.in" and generate with: hacking/update-sanity-requirements.py --test mypy
cffi==1.16.0
-cryptography==41.0.4
-Jinja2==3.1.2
-MarkupSafe==2.1.3
-mypy==1.5.1
+cryptography==42.0.5
+Jinja2==3.1.3
+MarkupSafe==2.1.5
+mypy==1.9.0
mypy-extensions==1.0.0
-packaging==23.2
+packaging==24.0
pycparser==2.21
tomli==2.0.1
types-backports==0.1.3
-types-paramiko==3.3.0.0
-types-PyYAML==6.0.12.12
-types-requests==2.31.0.7
-types-setuptools==68.2.0.0
-types-toml==0.10.8.7
-typing_extensions==4.8.0
-urllib3==2.0.6
+types-paramiko==3.4.0.20240311
+types-PyYAML==6.0.12.20240311
+types-requests==2.31.0.20240311
+types-setuptools==69.2.0.20240317
+types-toml==0.10.8.20240310
+typing_extensions==4.10.0
+urllib3==2.2.1
diff --git a/test/lib/ansible_test/_data/requirements/sanity.pep8.txt b/test/lib/ansible_test/_data/requirements/sanity.pep8.txt
index 1a36d4d..51d2b64 100644
--- a/test/lib/ansible_test/_data/requirements/sanity.pep8.txt
+++ b/test/lib/ansible_test/_data/requirements/sanity.pep8.txt
@@ -1,2 +1,2 @@
# edit "sanity.pep8.in" and generate with: hacking/update-sanity-requirements.py --test pep8
-pycodestyle==2.11.0
+pycodestyle==2.11.1
diff --git a/test/lib/ansible_test/_data/requirements/sanity.pylint.txt b/test/lib/ansible_test/_data/requirements/sanity.pylint.txt
index c3144fe..b6bdec5 100644
--- a/test/lib/ansible_test/_data/requirements/sanity.pylint.txt
+++ b/test/lib/ansible_test/_data/requirements/sanity.pylint.txt
@@ -1,11 +1,11 @@
# edit "sanity.pylint.in" and generate with: hacking/update-sanity-requirements.py --test pylint
-astroid==3.0.0
-dill==0.3.7
-isort==5.12.0
+astroid==3.1.0
+dill==0.3.8
+isort==5.13.2
mccabe==0.7.0
-platformdirs==3.11.0
-pylint==3.0.1
+platformdirs==4.2.0
+pylint==3.1.0
PyYAML==6.0.1
tomli==2.0.1
-tomlkit==0.12.1
-typing_extensions==4.8.0
+tomlkit==0.12.4
+typing_extensions==4.10.0
diff --git a/test/lib/ansible_test/_data/requirements/sanity.runtime-metadata.txt b/test/lib/ansible_test/_data/requirements/sanity.runtime-metadata.txt
index 4af9b95..8e6e2ce 100644
--- a/test/lib/ansible_test/_data/requirements/sanity.runtime-metadata.txt
+++ b/test/lib/ansible_test/_data/requirements/sanity.runtime-metadata.txt
@@ -1,3 +1,3 @@
# edit "sanity.runtime-metadata.in" and generate with: hacking/update-sanity-requirements.py --test runtime-metadata
PyYAML==6.0.1
-voluptuous==0.13.1
+voluptuous==0.14.2
diff --git a/test/lib/ansible_test/_data/requirements/sanity.validate-modules.txt b/test/lib/ansible_test/_data/requirements/sanity.validate-modules.txt
index 4e24d64..fba0da1 100644
--- a/test/lib/ansible_test/_data/requirements/sanity.validate-modules.txt
+++ b/test/lib/ansible_test/_data/requirements/sanity.validate-modules.txt
@@ -1,6 +1,6 @@
# edit "sanity.validate-modules.in" and generate with: hacking/update-sanity-requirements.py --test validate-modules
antsibull-docs-parser==1.0.0
-Jinja2==3.1.2
-MarkupSafe==2.1.3
+Jinja2==3.1.3
+MarkupSafe==2.1.5
PyYAML==6.0.1
-voluptuous==0.13.1
+voluptuous==0.14.2
diff --git a/test/lib/ansible_test/_data/requirements/sanity.yamllint.txt b/test/lib/ansible_test/_data/requirements/sanity.yamllint.txt
index bafd30b..2c91d9e 100644
--- a/test/lib/ansible_test/_data/requirements/sanity.yamllint.txt
+++ b/test/lib/ansible_test/_data/requirements/sanity.yamllint.txt
@@ -1,4 +1,4 @@
# edit "sanity.yamllint.in" and generate with: hacking/update-sanity-requirements.py --test yamllint
-pathspec==0.11.2
+pathspec==0.12.1
PyYAML==6.0.1
-yamllint==1.32.0
+yamllint==1.35.1
diff --git a/test/lib/ansible_test/_internal/bootstrap.py b/test/lib/ansible_test/_internal/bootstrap.py
index b0cfb60..a9dd637 100644
--- a/test/lib/ansible_test/_internal/bootstrap.py
+++ b/test/lib/ansible_test/_internal/bootstrap.py
@@ -28,7 +28,7 @@ class Bootstrap:
"""Base class for bootstrapping systems."""
controller: bool
- python_versions: list[str]
+ python_interpreters: dict[str, str]
ssh_key: SshKey
@property
@@ -41,7 +41,7 @@ class Bootstrap:
return dict(
bootstrap_type=self.bootstrap_type,
controller='yes' if self.controller else '',
- python_versions=self.python_versions,
+ python_interpreters=[f'{key}:{value}' for key, value in self.python_interpreters.items()],
ssh_key_type=self.ssh_key.KEY_TYPE,
ssh_private_key=self.ssh_key.key_contents,
ssh_public_key=self.ssh_key.pub_contents,
diff --git a/test/lib/ansible_test/_internal/classification/__init__.py b/test/lib/ansible_test/_internal/classification/__init__.py
index deda27e..b512284 100644
--- a/test/lib/ansible_test/_internal/classification/__init__.py
+++ b/test/lib/ansible_test/_internal/classification/__init__.py
@@ -674,11 +674,6 @@ class PathMapper:
# Early classification that needs to occur before common classification belongs here.
- if path.startswith('test/units/compat/'):
- return {
- 'units': 'test/units/',
- }
-
if dirname == '.azure-pipelines/commands':
test_map = {
'cloud.sh': 'integration:cloud/',
diff --git a/test/lib/ansible_test/_internal/commands/integration/cloud/cs.py b/test/lib/ansible_test/_internal/commands/integration/cloud/cs.py
index 8060804..ebb2734 100644
--- a/test/lib/ansible_test/_internal/commands/integration/cloud/cs.py
+++ b/test/lib/ansible_test/_internal/commands/integration/cloud/cs.py
@@ -38,7 +38,7 @@ class CsCloudProvider(CloudProvider):
def __init__(self, args: IntegrationConfig) -> None:
super().__init__(args)
- self.image = os.environ.get('ANSIBLE_CLOUDSTACK_CONTAINER', 'quay.io/ansible/cloudstack-test-container:1.6.1')
+ self.image = os.environ.get('ANSIBLE_CLOUDSTACK_CONTAINER', 'quay.io/ansible/cloudstack-test-container:1.7.0')
self.host = ''
self.port = 0
diff --git a/test/lib/ansible_test/_internal/commands/integration/cloud/nios.py b/test/lib/ansible_test/_internal/commands/integration/cloud/nios.py
index 62dd155..876968f 100644
--- a/test/lib/ansible_test/_internal/commands/integration/cloud/nios.py
+++ b/test/lib/ansible_test/_internal/commands/integration/cloud/nios.py
@@ -28,7 +28,7 @@ class NiosProvider(CloudProvider):
#
# It's source source itself resides at:
# https://github.com/ansible/nios-test-container
- DOCKER_IMAGE = 'quay.io/ansible/nios-test-container:2.0.0'
+ DOCKER_IMAGE = 'quay.io/ansible/nios-test-container:3.0.0'
def __init__(self, args: IntegrationConfig) -> None:
super().__init__(args)
diff --git a/test/lib/ansible_test/_internal/commands/sanity/__init__.py b/test/lib/ansible_test/_internal/commands/sanity/__init__.py
index 9b675e4..143fe33 100644
--- a/test/lib/ansible_test/_internal/commands/sanity/__init__.py
+++ b/test/lib/ansible_test/_internal/commands/sanity/__init__.py
@@ -765,11 +765,6 @@ class SanityTest(metaclass=abc.ABCMeta):
return False
@property
- def py2_compat(self) -> bool:
- """True if the test only applies to code that runs on Python 2.x."""
- return False
-
- @property
def supported_python_versions(self) -> t.Optional[tuple[str, ...]]:
"""A tuple of supported Python versions or None if the test does not depend on specific Python versions."""
return CONTROLLER_PYTHON_VERSIONS
@@ -786,23 +781,11 @@ class SanityTest(metaclass=abc.ABCMeta):
def filter_targets_by_version(self, args: SanityConfig, targets: list[TestTarget], python_version: str) -> list[TestTarget]:
"""Return the given list of test targets, filtered to include only those relevant for the test, taking into account the Python version."""
+ del args # args is not used here, but derived classes may make use of it
del python_version # python_version is not used here, but derived classes may make use of it
targets = self.filter_targets(targets)
- if self.py2_compat:
- # This sanity test is a Python 2.x compatibility test.
- content_config = get_content_config(args)
-
- if content_config.py2_support:
- # This collection supports Python 2.x.
- # Filter targets to include only those that require support for remote-only Python versions.
- targets = self.filter_remote_targets(targets)
- else:
- # This collection does not support Python 2.x.
- # There are no targets to test.
- targets = []
-
return targets
@staticmethod
@@ -878,7 +861,6 @@ class SanityCodeSmellTest(SanitySingleVersion):
self.__no_targets: bool = self.config.get('no_targets')
self.__include_directories: bool = self.config.get('include_directories')
self.__include_symlinks: bool = self.config.get('include_symlinks')
- self.__py2_compat: bool = self.config.get('py2_compat', False)
self.__error_code: str | None = self.config.get('error_code', None)
else:
self.output = None
@@ -894,7 +876,6 @@ class SanityCodeSmellTest(SanitySingleVersion):
self.__no_targets = True
self.__include_directories = False
self.__include_symlinks = False
- self.__py2_compat = False
self.__error_code = None
if self.no_targets:
@@ -940,11 +921,6 @@ class SanityCodeSmellTest(SanitySingleVersion):
return self.__include_symlinks
@property
- def py2_compat(self) -> bool:
- """True if the test only applies to code that runs on Python 2.x."""
- return self.__py2_compat
-
- @property
def supported_python_versions(self) -> t.Optional[tuple[str, ...]]:
"""A tuple of supported Python versions or None if the test does not depend on specific Python versions."""
versions = super().supported_python_versions
@@ -1141,10 +1117,8 @@ def create_sanity_virtualenv(
commands = collect_requirements( # create_sanity_virtualenv()
python=python,
controller=True,
- virtualenv=False,
command=None,
ansible=False,
- cryptography=False,
coverage=coverage,
minimize=minimize,
sanity=name,
diff --git a/test/lib/ansible_test/_internal/commands/sanity/import.py b/test/lib/ansible_test/_internal/commands/sanity/import.py
index 36f5241..55b90f7 100644
--- a/test/lib/ansible_test/_internal/commands/sanity/import.py
+++ b/test/lib/ansible_test/_internal/commands/sanity/import.py
@@ -47,11 +47,6 @@ from ...ansible_util import (
ansible_environment,
)
-from ...python_requirements import (
- PipUnavailableError,
- install_requirements,
-)
-
from ...config import (
SanityConfig,
)
@@ -68,10 +63,6 @@ from ...host_configs import (
PythonConfig,
)
-from ...venv import (
- get_virtualenv_version,
-)
-
def _get_module_test(module_restrictions: bool) -> c.Callable[[str], bool]:
"""Create a predicate which tests whether a path can be used by modules or not."""
@@ -109,15 +100,6 @@ class ImportTest(SanityMultipleVersion):
paths = [target.path for target in targets.include]
- if python.version.startswith('2.') and (get_virtualenv_version(args, python.path) or (0,)) < (13,):
- # hack to make sure that virtualenv is available under Python 2.x
- # on Python 3.x we can use the built-in venv
- # version 13+ is required to use the `--no-wheel` option
- try:
- install_requirements(args, python, virtualenv=True, controller=False) # sanity (import)
- except PipUnavailableError as ex:
- display.warning(str(ex))
-
temp_root = os.path.join(ResultType.TMP.path, 'sanity', 'import')
messages = []
diff --git a/test/lib/ansible_test/_internal/commands/sanity/mypy.py b/test/lib/ansible_test/_internal/commands/sanity/mypy.py
index c93474e..0465951 100644
--- a/test/lib/ansible_test/_internal/commands/sanity/mypy.py
+++ b/test/lib/ansible_test/_internal/commands/sanity/mypy.py
@@ -66,7 +66,6 @@ class MypyTest(SanityMultipleVersion):
vendored_paths = (
'lib/ansible/module_utils/six/__init__.py',
'lib/ansible/module_utils/distro/_distro.py',
- 'lib/ansible/module_utils/compat/_selectors2.py',
)
def filter_targets(self, targets: list[TestTarget]) -> list[TestTarget]:
@@ -77,15 +76,6 @@ class MypyTest(SanityMultipleVersion):
or target.path.startswith('test/lib/ansible_test/_util/target/sanity/import/'))]
@property
- def supported_python_versions(self) -> t.Optional[tuple[str, ...]]:
- """A tuple of supported Python versions or None if the test does not depend on specific Python versions."""
- # mypy 0.981 dropped support for Python 2
- # see: https://mypy-lang.blogspot.com/2022/09/mypy-0981-released.html
- # cryptography dropped support for Python 3.5 in version 3.3
- # see: https://cryptography.io/en/latest/changelog/#v3-3
- return tuple(version for version in SUPPORTED_PYTHON_VERSIONS if str_to_version(version) >= (3, 6))
-
- @property
def error_code(self) -> t.Optional[str]:
"""Error code for ansible-test matching the format used by the underlying test program, or None if the program does not use error codes."""
return 'ansible-test'
@@ -95,6 +85,13 @@ class MypyTest(SanityMultipleVersion):
"""True if the test requires PyPI, otherwise False."""
return True
+ @property
+ def supported_python_versions(self) -> t.Optional[tuple[str, ...]]:
+ """A tuple of supported Python versions or None if the test does not depend on specific Python versions."""
+ # Because the version of typeshed mypy use in 1.9 doesn't support 3.7, neither does mypy 1.9.
+ # see: https://mypy-lang.blogspot.com/2024/03/mypy-19-released.html
+ return tuple(version for version in SUPPORTED_PYTHON_VERSIONS if str_to_version(version) >= (3, 8))
+
def test(self, args: SanityConfig, targets: SanityTargets, python: PythonConfig) -> TestResult:
settings = self.load_processor(args, python.version)
diff --git a/test/lib/ansible_test/_internal/commands/units/__init__.py b/test/lib/ansible_test/_internal/commands/units/__init__.py
index 71ce5c4..9427262 100644
--- a/test/lib/ansible_test/_internal/commands/units/__init__.py
+++ b/test/lib/ansible_test/_internal/commands/units/__init__.py
@@ -245,7 +245,7 @@ def command_units(args: UnitsConfig) -> None:
#
# NOTE: This only affects use of pytest-mock.
# Collection unit tests may directly import mock, which will be provided by ansible-test when it installs requirements using pip.
- # Although mock is available for ansible-core unit tests, they should import units.compat.mock instead.
+ # Although mock is available for ansible-core unit tests, they should import unittest.mock instead.
if str_to_version(python.version) < (3, 8):
config_name = 'legacy.ini'
else:
diff --git a/test/lib/ansible_test/_internal/config.py b/test/lib/ansible_test/_internal/config.py
index dbc137b..18d815c 100644
--- a/test/lib/ansible_test/_internal/config.py
+++ b/test/lib/ansible_test/_internal/config.py
@@ -65,7 +65,6 @@ class ContentConfig:
modules: ModulesConfig
python_versions: tuple[str, ...]
- py2_support: bool
class EnvironmentConfig(CommonConfig):
diff --git a/test/lib/ansible_test/_internal/content_config.py b/test/lib/ansible_test/_internal/content_config.py
index 7ac1876..c9c37df 100644
--- a/test/lib/ansible_test/_internal/content_config.py
+++ b/test/lib/ansible_test/_internal/content_config.py
@@ -29,7 +29,6 @@ from .io import (
from .util import (
ApplicationError,
display,
- str_to_version,
)
from .data import (
@@ -75,13 +74,9 @@ def parse_content_config(data: t.Any) -> ContentConfig:
python_versions = tuple(version for version in SUPPORTED_PYTHON_VERSIONS
if version in CONTROLLER_PYTHON_VERSIONS or version in modules.python_versions)
- # True if Python 2.x is supported.
- py2_support = any(version for version in python_versions if str_to_version(version)[0] == 2)
-
return ContentConfig(
modules=modules,
python_versions=python_versions,
- py2_support=py2_support,
)
diff --git a/test/lib/ansible_test/_internal/coverage_util.py b/test/lib/ansible_test/_internal/coverage_util.py
index 3017623..28e66b5 100644
--- a/test/lib/ansible_test/_internal/coverage_util.py
+++ b/test/lib/ansible_test/_internal/coverage_util.py
@@ -71,7 +71,6 @@ COVERAGE_VERSIONS = (
# IMPORTANT: Keep this in sync with the ansible-test.txt requirements file.
CoverageVersion('7.3.2', 7, (3, 8), (3, 12)),
CoverageVersion('6.5.0', 7, (3, 7), (3, 7)),
- CoverageVersion('4.5.4', 0, (2, 6), (3, 6)),
)
"""
This tuple specifies the coverage version to use for Python version ranges.
diff --git a/test/lib/ansible_test/_internal/docker_util.py b/test/lib/ansible_test/_internal/docker_util.py
index 52b9691..97c022c 100644
--- a/test/lib/ansible_test/_internal/docker_util.py
+++ b/test/lib/ansible_test/_internal/docker_util.py
@@ -496,7 +496,7 @@ def get_docker_hostname() -> str:
"""Return the hostname of the Docker service."""
docker_host = os.environ.get('DOCKER_HOST')
- if docker_host and docker_host.startswith('tcp://'):
+ if docker_host and docker_host.startswith(('tcp://', 'ssh://')):
try:
hostname = urllib.parse.urlparse(docker_host)[1].split(':')[0]
display.info('Detected Docker host: %s' % hostname, verbosity=1)
diff --git a/test/lib/ansible_test/_internal/host_profiles.py b/test/lib/ansible_test/_internal/host_profiles.py
index 0981245..39fe7d2 100644
--- a/test/lib/ansible_test/_internal/host_profiles.py
+++ b/test/lib/ansible_test/_internal/host_profiles.py
@@ -958,7 +958,7 @@ class DockerProfile(ControllerHostProfile[DockerConfig], SshTargetHostProfile[Do
"""Perform out-of-band setup before delegation."""
bootstrapper = BootstrapDocker(
controller=self.controller,
- python_versions=[self.python.version],
+ python_interpreters={self.python.version: self.python.path},
ssh_key=SshKey(self.args),
)
@@ -1214,8 +1214,9 @@ class PosixRemoteProfile(ControllerHostProfile[PosixRemoteConfig], RemoteProfile
def configure(self) -> None:
"""Perform in-band configuration. Executed before delegation for the controller and after delegation for targets."""
# a target uses a single python version, but a controller may include additional versions for targets running on the controller
- python_versions = [self.python.version] + [target.python.version for target in self.targets if isinstance(target, ControllerConfig)]
- python_versions = sorted_versions(list(set(python_versions)))
+ python_interpreters = {self.python.version: self.python.path}
+ python_interpreters.update({target.python.version: target.python.path for target in self.targets if isinstance(target, ControllerConfig)})
+ python_interpreters = {version: python_interpreters[version] for version in sorted_versions(list(python_interpreters.keys()))}
core_ci = self.wait_for_instance()
pwd = self.wait_until_ready()
@@ -1226,7 +1227,7 @@ class PosixRemoteProfile(ControllerHostProfile[PosixRemoteConfig], RemoteProfile
controller=self.controller,
platform=self.config.platform,
platform_version=self.config.version,
- python_versions=python_versions,
+ python_interpreters=python_interpreters,
ssh_key=core_ci.ssh_key,
)
diff --git a/test/lib/ansible_test/_internal/python_requirements.py b/test/lib/ansible_test/_internal/python_requirements.py
index 81006e4..404f2cd 100644
--- a/test/lib/ansible_test/_internal/python_requirements.py
+++ b/test/lib/ansible_test/_internal/python_requirements.py
@@ -5,7 +5,6 @@ import base64
import dataclasses
import json
import os
-import re
import typing as t
from .encoding import (
@@ -20,14 +19,9 @@ from .io import (
from .util import (
ANSIBLE_TEST_DATA_ROOT,
ANSIBLE_TEST_TARGET_ROOT,
- ANSIBLE_TEST_TOOLS_ROOT,
ApplicationError,
SubprocessError,
display,
- find_executable,
- raw_command,
- str_to_version,
- version_to_str,
)
from .util_common import (
@@ -63,9 +57,6 @@ from .coverage_util import (
QUIET_PIP_SCRIPT_PATH = os.path.join(ANSIBLE_TEST_TARGET_ROOT, 'setup', 'quiet_pip.py')
REQUIREMENTS_SCRIPT_PATH = os.path.join(ANSIBLE_TEST_TARGET_ROOT, 'setup', 'requirements.py')
-# IMPORTANT: Keep this in sync with the ansible-test.txt requirements file.
-VIRTUALENV_VERSION = '16.7.12'
-
# Pip Abstraction
@@ -132,7 +123,6 @@ def install_requirements(
ansible: bool = False,
command: bool = False,
coverage: bool = False,
- virtualenv: bool = False,
controller: bool = True,
connection: t.Optional[Connection] = None,
) -> None:
@@ -145,8 +135,6 @@ def install_requirements(
if command and isinstance(args, (UnitsConfig, IntegrationConfig)) and args.coverage:
coverage = True
- cryptography = False
-
if ansible:
try:
ansible_cache = install_requirements.ansible_cache # type: ignore[attr-defined]
@@ -160,19 +148,12 @@ def install_requirements(
else:
ansible_cache[python.path] = True
- # Install the latest cryptography version that the current requirements can support if it is not already available.
- # This avoids downgrading cryptography when OS packages provide a newer version than we are able to install using pip.
- # If not installed here, later install commands may try to install a version of cryptography which cannot be installed.
- cryptography = not is_cryptography_available(python.path)
-
commands = collect_requirements(
python=python,
controller=controller,
ansible=ansible,
- cryptography=cryptography,
command=args.command if command else None,
coverage=coverage,
- virtualenv=virtualenv,
minimize=False,
sanity=None,
)
@@ -205,9 +186,7 @@ def collect_requirements(
python: PythonConfig,
controller: bool,
ansible: bool,
- cryptography: bool,
coverage: bool,
- virtualenv: bool,
minimize: bool,
command: t.Optional[str],
sanity: t.Optional[str],
@@ -215,17 +194,9 @@ def collect_requirements(
"""Collect requirements for the given Python using the specified arguments."""
commands: list[PipCommand] = []
- if virtualenv:
- # sanity tests on Python 2.x install virtualenv when it is too old or is not already installed and the `--requirements` option is given
- # the last version of virtualenv with no dependencies is used to minimize the changes made outside a virtual environment
- commands.extend(collect_package_install(packages=[f'virtualenv=={VIRTUALENV_VERSION}'], constraints=False))
-
if coverage:
commands.extend(collect_package_install(packages=[f'coverage=={get_coverage_version(python.version).coverage_version}'], constraints=False))
- if cryptography:
- commands.extend(collect_package_install(packages=get_cryptography_requirements(python)))
-
if ansible or command:
commands.extend(collect_general_install(command, ansible))
@@ -446,17 +417,7 @@ def get_venv_packages(python: PythonConfig) -> dict[str, str]:
wheel='0.37.1',
)
- override_packages = {
- '2.7': dict(
- pip='20.3.4', # 21.0 requires Python 3.6+
- setuptools='44.1.1', # 45.0.0 requires Python 3.5+
- wheel=None,
- ),
- '3.6': dict(
- pip='21.3.1', # 22.0 requires Python 3.7+
- setuptools='59.6.0', # 59.7.0 requires Python 3.7+
- wheel=None,
- ),
+ override_packages: dict[str, dict[str, str]] = {
}
packages = {name: version or default_packages[name] for name, version in override_packages.get(python.version, default_packages).items()}
@@ -510,82 +471,3 @@ def prepare_pip_script(commands: list[PipCommand]) -> str:
def usable_pip_file(path: t.Optional[str]) -> bool:
"""Return True if the specified pip file is usable, otherwise False."""
return bool(path) and os.path.exists(path) and bool(os.path.getsize(path))
-
-
-# Cryptography
-
-
-def is_cryptography_available(python: str) -> bool:
- """Return True if cryptography is available for the given python."""
- try:
- raw_command([python, '-c', 'import cryptography'], capture=True)
- except SubprocessError:
- return False
-
- return True
-
-
-def get_cryptography_requirements(python: PythonConfig) -> list[str]:
- """
- Return the correct cryptography and pyopenssl requirements for the given python version.
- The version of cryptography installed depends on the python version and openssl version.
- """
- openssl_version = get_openssl_version(python)
-
- if openssl_version and openssl_version < (1, 1, 0):
- # cryptography 3.2 requires openssl 1.1.x or later
- # see https://cryptography.io/en/latest/changelog.html#v3-2
- cryptography = 'cryptography < 3.2'
- # pyopenssl 20.0.0 requires cryptography 3.2 or later
- pyopenssl = 'pyopenssl < 20.0.0'
- else:
- # cryptography 3.4+ builds require a working rust toolchain
- # systems bootstrapped using ansible-core-ci can access additional wheels through the spare-tire package index
- cryptography = 'cryptography'
- # any future installation of pyopenssl is free to use any compatible version of cryptography
- pyopenssl = ''
-
- requirements = [
- cryptography,
- pyopenssl,
- ]
-
- requirements = [requirement for requirement in requirements if requirement]
-
- return requirements
-
-
-def get_openssl_version(python: PythonConfig) -> t.Optional[tuple[int, ...]]:
- """Return the openssl version."""
- if not python.version.startswith('2.'):
- # OpenSSL version checking only works on Python 3.x.
- # This should be the most accurate, since it is the Python we will be using.
- version = json.loads(raw_command([python.path, os.path.join(ANSIBLE_TEST_TOOLS_ROOT, 'sslcheck.py')], capture=True)[0])['version']
-
- if version:
- display.info(f'Detected OpenSSL version {version_to_str(version)} under Python {python.version}.', verbosity=1)
-
- return tuple(version)
-
- # Fall back to detecting the OpenSSL version from the CLI.
- # This should provide an adequate solution on Python 2.x.
- openssl_path = find_executable('openssl', required=False)
-
- if openssl_path:
- try:
- result = raw_command([openssl_path, 'version'], capture=True)[0]
- except SubprocessError:
- result = ''
-
- match = re.search(r'^OpenSSL (?P<version>[0-9]+\.[0-9]+\.[0-9]+)', result)
-
- if match:
- version = str_to_version(match.group('version'))
-
- display.info(f'Detected OpenSSL version {version_to_str(version)} using the openssl CLI.', verbosity=1)
-
- return version
-
- display.info('Unable to detect OpenSSL version.', verbosity=1)
-
- return None
diff --git a/test/lib/ansible_test/_internal/ssh.py b/test/lib/ansible_test/_internal/ssh.py
index b2a2678..8125768 100644
--- a/test/lib/ansible_test/_internal/ssh.py
+++ b/test/lib/ansible_test/_internal/ssh.py
@@ -245,6 +245,7 @@ def create_ssh_port_forwards(
"""
options: dict[str, t.Union[str, int]] = dict(
LogLevel='INFO', # info level required to get messages on stderr indicating the ports assigned to each forward
+ ControlPath='none', # if the user has ControlPath set up for every host, it will prevent creation of forwards
)
cli_args = []
diff --git a/test/lib/ansible_test/_internal/util.py b/test/lib/ansible_test/_internal/util.py
index 394c263..903cbcc 100644
--- a/test/lib/ansible_test/_internal/util.py
+++ b/test/lib/ansible_test/_internal/util.py
@@ -998,7 +998,7 @@ def retry(func: t.Callable[..., TValue], ex_type: t.Type[BaseException] = Subpro
def parse_to_list_of_dict(pattern: str, value: str) -> list[dict[str, str]]:
"""Parse lines from the given value using the specified pattern and return the extracted list of key/value pair dictionaries."""
matched = []
- unmatched = []
+ unmatched: list[str] = []
for line in value.splitlines():
match = re.search(pattern, line)
diff --git a/test/lib/ansible_test/_internal/util_common.py b/test/lib/ansible_test/_internal/util_common.py
index 77a6165..a690497 100644
--- a/test/lib/ansible_test/_internal/util_common.py
+++ b/test/lib/ansible_test/_internal/util_common.py
@@ -409,7 +409,7 @@ def create_interpreter_wrapper(interpreter: str, injected_interpreter: str) -> N
code = textwrap.dedent('''
#!%s
- from __future__ import absolute_import
+ from __future__ import annotations
from os import execv
from sys import argv
diff --git a/test/lib/ansible_test/_internal/venv.py b/test/lib/ansible_test/_internal/venv.py
index a83fc8b..cdd73b0 100644
--- a/test/lib/ansible_test/_internal/venv.py
+++ b/test/lib/ansible_test/_internal/venv.py
@@ -15,7 +15,6 @@ from .config import (
from .util import (
find_python,
SubprocessError,
- get_available_python_versions,
ANSIBLE_TEST_TARGET_TOOLS_ROOT,
display,
remove_tree,
@@ -85,49 +84,21 @@ def create_virtual_environment(
system_site_packages: bool = False,
pip: bool = False,
) -> bool:
- """Create a virtual environment using venv or virtualenv for the requested Python version."""
+ """Create a virtual environment using venv for the requested Python version."""
if not os.path.exists(python.path):
# the requested python version could not be found
return False
- if str_to_version(python.version) >= (3, 0):
- # use the built-in 'venv' module on Python 3.x
- # creating a virtual environment using 'venv' when running in a virtual environment created by 'virtualenv' results
- # in a copy of the original virtual environment instead of creation of a new one
- # avoid this issue by only using "real" python interpreters to invoke 'venv'
- for real_python in iterate_real_pythons(python.version):
- if run_venv(args, real_python, system_site_packages, pip, path):
- display.info('Created Python %s virtual environment using "venv": %s' % (python.version, path), verbosity=1)
- return True
-
- # something went wrong, most likely the package maintainer for the Python installation removed ensurepip
- # which will prevent creation of a virtual environment without installation of other OS packages
-
- # use the installed 'virtualenv' module on the Python requested version
- if run_virtualenv(args, python.path, python.path, system_site_packages, pip, path):
- display.info('Created Python %s virtual environment using "virtualenv": %s' % (python.version, path), verbosity=1)
- return True
-
- available_pythons = get_available_python_versions()
-
- for available_python_version, available_python_interpreter in sorted(available_pythons.items()):
- if available_python_interpreter == python.path:
- # already attempted to use this interpreter
- continue
-
- virtualenv_version = get_virtualenv_version(args, available_python_interpreter)
-
- if not virtualenv_version:
- # virtualenv not available for this Python or we were unable to detect the version
- continue
-
- # try using 'virtualenv' from another Python to setup the desired version
- if run_virtualenv(args, available_python_interpreter, python.path, system_site_packages, pip, path):
- display.info('Created Python %s virtual environment using "virtualenv" on Python %s: %s' % (python.version, available_python_version, path),
- verbosity=1)
+ # creating a virtual environment using 'venv' when running in a virtual environment created by 'virtualenv' results
+ # in a copy of the original virtual environment instead of creation of a new one
+ # avoid this issue by only using "real" python interpreters to invoke 'venv'
+ for real_python in iterate_real_pythons(python.version):
+ if run_venv(args, real_python, system_site_packages, pip, path):
+ display.info('Created Python %s virtual environment using "venv": %s' % (python.version, path), verbosity=1)
return True
- # no suitable 'virtualenv' available
+ # something went wrong, most likely the package maintainer for the Python installation removed ensurepip
+ # which will prevent creation of a virtual environment without installation of other OS packages
return False
@@ -188,7 +159,7 @@ def run_venv(
pip: bool,
path: str,
) -> bool:
- """Create a virtual environment using the 'venv' module. Not available on Python 2.x."""
+ """Create a virtual environment using the 'venv' module."""
cmd = [run_python, '-m', 'venv']
if system_site_packages:
@@ -210,72 +181,3 @@ def run_venv(
return False
return True
-
-
-def run_virtualenv(
- args: EnvironmentConfig,
- run_python: str,
- env_python: str,
- system_site_packages: bool,
- pip: bool,
- path: str,
-) -> bool:
- """Create a virtual environment using the 'virtualenv' module."""
- # always specify which interpreter to use to guarantee the desired interpreter is provided
- # otherwise virtualenv may select a different interpreter than the one running virtualenv
- cmd = [run_python, '-m', 'virtualenv', '--python', env_python]
-
- if system_site_packages:
- cmd.append('--system-site-packages')
-
- if not pip:
- cmd.append('--no-pip')
- # these options provide consistency with venv, which does not install them without pip
- cmd.append('--no-setuptools')
- cmd.append('--no-wheel')
-
- cmd.append(path)
-
- try:
- run_command(args, cmd, capture=True)
- except SubprocessError as ex:
- remove_tree(path)
-
- if args.verbosity > 1:
- display.error(ex.message)
-
- return False
-
- return True
-
-
-def get_virtualenv_version(args: EnvironmentConfig, python: str) -> t.Optional[tuple[int, ...]]:
- """Get the virtualenv version for the given python interpreter, if available, otherwise return None."""
- try:
- cache = get_virtualenv_version.cache # type: ignore[attr-defined]
- except AttributeError:
- cache = get_virtualenv_version.cache = {} # type: ignore[attr-defined]
-
- if python not in cache:
- try:
- stdout = run_command(args, [python, '-m', 'virtualenv', '--version'], capture=True)[0]
- except SubprocessError as ex:
- stdout = ''
-
- if args.verbosity > 1:
- display.error(ex.message)
-
- version = None
-
- if stdout:
- # noinspection PyBroadException
- try:
- version = str_to_version(stdout.strip())
- except Exception: # pylint: disable=broad-except
- pass
-
- cache[python] = version
-
- version = cache[python]
-
- return version
diff --git a/test/lib/ansible_test/_util/__init__.py b/test/lib/ansible_test/_util/__init__.py
index 527d413..8f58623 100644
--- a/test/lib/ansible_test/_util/__init__.py
+++ b/test/lib/ansible_test/_util/__init__.py
@@ -1,2 +1 @@
-# Empty __init__.py to allow importing of `ansible_test._util.target.common` under Python 2.x.
-# This allows the ansible-test entry point to report supported Python versions before exiting.
+# Empty __init__.py to keep pylint happy.
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/future-import-boilerplate.py b/test/lib/ansible_test/_util/controller/sanity/code-smell/future-import-boilerplate.py
deleted file mode 100644
index 7b39c37..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/future-import-boilerplate.py
+++ /dev/null
@@ -1,46 +0,0 @@
-"""Enforce proper usage of __future__ imports."""
-from __future__ import annotations
-
-import ast
-import sys
-
-
-def main():
- """Main entry point."""
- for path in sys.argv[1:] or sys.stdin.read().splitlines():
- with open(path, 'rb') as path_fd:
- lines = path_fd.read().splitlines()
-
- missing = True
- if not lines:
- # Files are allowed to be empty of everything including boilerplate
- missing = False
-
- for text in lines:
- if text in (b'from __future__ import (absolute_import, division, print_function)',
- b'from __future__ import absolute_import, division, print_function'):
- missing = False
- break
-
- if missing:
- with open(path, encoding='utf-8') as file:
- contents = file.read()
-
- # noinspection PyBroadException
- try:
- node = ast.parse(contents)
-
- # files consisting of only assignments have no need for future import boilerplate
- # the only exception would be division during assignment, but we'll overlook that for simplicity
- # the most likely case is that of a documentation only python file
- if all(isinstance(statement, ast.Assign) for statement in node.body):
- missing = False
- except Exception: # pylint: disable=broad-except
- pass # the compile sanity test will report this error
-
- if missing:
- print('%s: missing: from __future__ import (absolute_import, division, print_function)' % path)
-
-
-if __name__ == '__main__':
- main()
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/metaclass-boilerplate.json b/test/lib/ansible_test/_util/controller/sanity/code-smell/metaclass-boilerplate.json
deleted file mode 100644
index 4ebce32..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/metaclass-boilerplate.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extensions": [
- ".py"
- ],
- "py2_compat": true,
- "output": "path-message"
-}
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/metaclass-boilerplate.py b/test/lib/ansible_test/_util/controller/sanity/code-smell/metaclass-boilerplate.py
deleted file mode 100644
index 8bdcfc9..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/metaclass-boilerplate.py
+++ /dev/null
@@ -1,44 +0,0 @@
-"""Require __metaclass__ boilerplate for code that supports Python 2.x."""
-from __future__ import annotations
-
-import ast
-import sys
-
-
-def main():
- """Main entry point."""
- for path in sys.argv[1:] or sys.stdin.read().splitlines():
- with open(path, 'rb') as path_fd:
- lines = path_fd.read().splitlines()
-
- missing = True
- if not lines:
- # Files are allowed to be empty of everything including boilerplate
- missing = False
-
- for text in lines:
- if text == b'__metaclass__ = type':
- missing = False
- break
-
- if missing:
- with open(path, encoding='utf-8') as file:
- contents = file.read()
-
- # noinspection PyBroadException
- try:
- node = ast.parse(contents)
-
- # files consisting of only assignments have no need for metaclass boilerplate
- # the most likely case is that of a documentation only python file
- if all(isinstance(statement, ast.Assign) for statement in node.body):
- missing = False
- except Exception: # pylint: disable=broad-except
- pass # the compile sanity test will report this error
-
- if missing:
- print('%s: missing: __metaclass__ = type' % path)
-
-
-if __name__ == '__main__':
- main()
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-basestring.json b/test/lib/ansible_test/_util/controller/sanity/code-smell/no-basestring.json
deleted file mode 100644
index 88858ae..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-basestring.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extensions": [
- ".py"
- ],
- "ignore_self": true,
- "output": "path-line-column-message"
-}
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-basestring.py b/test/lib/ansible_test/_util/controller/sanity/code-smell/no-basestring.py
deleted file mode 100644
index 74e38d7..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-basestring.py
+++ /dev/null
@@ -1,21 +0,0 @@
-"""Disallow use of basestring isinstance checks."""
-from __future__ import annotations
-
-import re
-import sys
-
-
-def main():
- """Main entry point."""
- for path in sys.argv[1:] or sys.stdin.read().splitlines():
- with open(path, 'r', encoding='utf-8') as path_fd:
- for line, text in enumerate(path_fd.readlines()):
- match = re.search(r'(isinstance.*basestring)', text)
-
- if match:
- print('%s:%d:%d: do not use `isinstance(s, basestring)`' % (
- path, line + 1, match.start(1) + 1))
-
-
-if __name__ == '__main__':
- main()
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iteritems.json b/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iteritems.json
deleted file mode 100644
index 88858ae..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iteritems.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extensions": [
- ".py"
- ],
- "ignore_self": true,
- "output": "path-line-column-message"
-}
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iteritems.py b/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iteritems.py
deleted file mode 100644
index b4e4002..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iteritems.py
+++ /dev/null
@@ -1,21 +0,0 @@
-"""Disallow use of the dict.iteritems function."""
-from __future__ import annotations
-
-import re
-import sys
-
-
-def main():
- """Main entry point."""
- for path in sys.argv[1:] or sys.stdin.read().splitlines():
- with open(path, 'r', encoding='utf-8') as path_fd:
- for line, text in enumerate(path_fd.readlines()):
- match = re.search(r'(?<! six)\.(iteritems)', text)
-
- if match:
- print('%s:%d:%d: use `dict.items` or `ansible.module_utils.six.iteritems` instead of `dict.iteritems`' % (
- path, line + 1, match.start(1) + 1))
-
-
-if __name__ == '__main__':
- main()
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iterkeys.json b/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iterkeys.json
deleted file mode 100644
index 88858ae..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iterkeys.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extensions": [
- ".py"
- ],
- "ignore_self": true,
- "output": "path-line-column-message"
-}
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iterkeys.py b/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iterkeys.py
deleted file mode 100644
index 00c8703..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-iterkeys.py
+++ /dev/null
@@ -1,21 +0,0 @@
-"""Disallow use of the dict.iterkeys function."""
-from __future__ import annotations
-
-import re
-import sys
-
-
-def main():
- """Main entry point."""
- for path in sys.argv[1:] or sys.stdin.read().splitlines():
- with open(path, 'r', encoding='utf-8') as path_fd:
- for line, text in enumerate(path_fd.readlines()):
- match = re.search(r'\.(iterkeys)', text)
-
- if match:
- print('%s:%d:%d: use `dict.keys` or `for key in dict:` instead of `dict.iterkeys`' % (
- path, line + 1, match.start(1) + 1))
-
-
-if __name__ == '__main__':
- main()
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-itervalues.json b/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-itervalues.json
deleted file mode 100644
index 88858ae..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-itervalues.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extensions": [
- ".py"
- ],
- "ignore_self": true,
- "output": "path-line-column-message"
-}
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-itervalues.py b/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-itervalues.py
deleted file mode 100644
index 2e8036a..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-dict-itervalues.py
+++ /dev/null
@@ -1,21 +0,0 @@
-"""Disallow use of the dict.itervalues function."""
-from __future__ import annotations
-
-import re
-import sys
-
-
-def main():
- """Main entry point."""
- for path in sys.argv[1:] or sys.stdin.read().splitlines():
- with open(path, 'r', encoding='utf-8') as path_fd:
- for line, text in enumerate(path_fd.readlines()):
- match = re.search(r'(?<! six)\.(itervalues)', text)
-
- if match:
- print('%s:%d:%d: use `dict.values` or `ansible.module_utils.six.itervalues` instead of `dict.itervalues`' % (
- path, line + 1, match.start(1) + 1))
-
-
-if __name__ == '__main__':
- main()
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-main-display.json b/test/lib/ansible_test/_util/controller/sanity/code-smell/no-main-display.json
deleted file mode 100644
index ccee80a..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-main-display.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "extensions": [
- ".py"
- ],
- "prefixes": [
- "lib/ansible/",
- "plugins/"
- ],
- "output": "path-line-column-message"
-}
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-main-display.py b/test/lib/ansible_test/_util/controller/sanity/code-smell/no-main-display.py
deleted file mode 100644
index eb5987d..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-main-display.py
+++ /dev/null
@@ -1,21 +0,0 @@
-"""Disallow importing display from __main__."""
-from __future__ import annotations
-
-import sys
-
-MAIN_DISPLAY_IMPORT = 'from __main__ import display'
-
-
-def main():
- """Main entry point."""
- for path in sys.argv[1:] or sys.stdin.read().splitlines():
- with open(path, 'r', encoding='utf-8') as file:
- for i, line in enumerate(file.readlines()):
- if MAIN_DISPLAY_IMPORT in line:
- lineno = i + 1
- colno = line.index(MAIN_DISPLAY_IMPORT) + 1
- print('%s:%d:%d: Display is a singleton, just import and instantiate' % (path, lineno, colno))
-
-
-if __name__ == '__main__':
- main()
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-unicode-literals.json b/test/lib/ansible_test/_util/controller/sanity/code-smell/no-unicode-literals.json
deleted file mode 100644
index 88858ae..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-unicode-literals.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "extensions": [
- ".py"
- ],
- "ignore_self": true,
- "output": "path-line-column-message"
-}
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-unicode-literals.py b/test/lib/ansible_test/_util/controller/sanity/code-smell/no-unicode-literals.py
deleted file mode 100644
index 75c34f2..0000000
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/no-unicode-literals.py
+++ /dev/null
@@ -1,21 +0,0 @@
-"""Disallow use of the unicode_literals future."""
-from __future__ import annotations
-
-import re
-import sys
-
-
-def main():
- """Main entry point."""
- for path in sys.argv[1:] or sys.stdin.read().splitlines():
- with open(path, 'r', encoding='utf-8') as path_fd:
- for line, text in enumerate(path_fd.readlines()):
- match = re.search(r'(unicode_literals)', text)
-
- if match:
- print('%s:%d:%d: do not use `unicode_literals`' % (
- path, line + 1, match.start(1) + 1))
-
-
-if __name__ == '__main__':
- main()
diff --git a/test/lib/ansible_test/_util/controller/sanity/mypy/ansible-core.ini b/test/lib/ansible_test/_util/controller/sanity/mypy/ansible-core.ini
index 41d824b..0251f67 100644
--- a/test/lib/ansible_test/_util/controller/sanity/mypy/ansible-core.ini
+++ b/test/lib/ansible_test/_util/controller/sanity/mypy/ansible-core.ini
@@ -46,9 +46,6 @@ ignore_missing_imports = True
[mypy-lxml.*]
ignore_missing_imports = True
-[mypy-yum.*]
-ignore_missing_imports = True
-
[mypy-rpmUtils.*]
ignore_missing_imports = True
@@ -85,9 +82,6 @@ ignore_missing_imports = True
[mypy-distro.*]
ignore_missing_imports = True
-[mypy-selectors2.*]
-ignore_missing_imports = True
-
[mypy-resolvelib.*]
ignore_missing_imports = True
diff --git a/test/lib/ansible_test/_util/controller/sanity/mypy/modules.ini b/test/lib/ansible_test/_util/controller/sanity/mypy/modules.ini
index d6a608f..b4e7b05 100644
--- a/test/lib/ansible_test/_util/controller/sanity/mypy/modules.ini
+++ b/test/lib/ansible_test/_util/controller/sanity/mypy/modules.ini
@@ -13,9 +13,6 @@ ignore_missing_imports = True
[mypy-md5.*]
ignore_missing_imports = True
-[mypy-yum.*]
-ignore_missing_imports = True
-
[mypy-rpmUtils.*]
ignore_missing_imports = True
@@ -52,9 +49,6 @@ ignore_missing_imports = True
[mypy-distro.*]
ignore_missing_imports = True
-[mypy-selectors2.*]
-ignore_missing_imports = True
-
[mypy-selinux.*]
ignore_missing_imports = True
diff --git a/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test-target.cfg b/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test-target.cfg
index f8a0a8a..51d0bb0 100644
--- a/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test-target.cfg
+++ b/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test-target.cfg
@@ -35,7 +35,6 @@ bad-names=
tutu,
good-names=
- __metaclass__,
C,
ex,
i,
diff --git a/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test.cfg b/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test.cfg
index 5bec36f..801adbe 100644
--- a/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test.cfg
+++ b/test/lib/ansible_test/_util/controller/sanity/pylint/config/ansible-test.cfg
@@ -34,7 +34,6 @@ bad-names=
tutu,
good-names=
- __metaclass__,
C,
ex,
i,
diff --git a/test/lib/ansible_test/_util/controller/sanity/pylint/config/code-smell.cfg b/test/lib/ansible_test/_util/controller/sanity/pylint/config/code-smell.cfg
index c30eb37..adc0b95 100644
--- a/test/lib/ansible_test/_util/controller/sanity/pylint/config/code-smell.cfg
+++ b/test/lib/ansible_test/_util/controller/sanity/pylint/config/code-smell.cfg
@@ -33,7 +33,6 @@ bad-names=
tutu,
good-names=
- __metaclass__,
C,
ex,
i,
diff --git a/test/lib/ansible_test/_util/controller/sanity/pylint/config/collection.cfg b/test/lib/ansible_test/_util/controller/sanity/pylint/config/collection.cfg
index 762d488..bb6c3e4 100644
--- a/test/lib/ansible_test/_util/controller/sanity/pylint/config/collection.cfg
+++ b/test/lib/ansible_test/_util/controller/sanity/pylint/config/collection.cfg
@@ -102,7 +102,6 @@ disable=
undefined-loop-variable,
unexpected-keyword-arg,
ungrouped-imports,
- unidiomatic-typecheck,
unnecessary-pass,
unnecessary-dunder-call,
unsubscriptable-object,
diff --git a/test/lib/ansible_test/_util/controller/sanity/pylint/config/default.cfg b/test/lib/ansible_test/_util/controller/sanity/pylint/config/default.cfg
index 825e5df..6264948 100644
--- a/test/lib/ansible_test/_util/controller/sanity/pylint/config/default.cfg
+++ b/test/lib/ansible_test/_util/controller/sanity/pylint/config/default.cfg
@@ -95,7 +95,6 @@ disable=
undefined-loop-variable,
unexpected-keyword-arg,
ungrouped-imports,
- unidiomatic-typecheck,
unnecessary-pass,
unsubscriptable-object,
unsupported-assignment-operation,
diff --git a/test/lib/ansible_test/_util/controller/sanity/pylint/plugins/deprecated.py b/test/lib/ansible_test/_util/controller/sanity/pylint/plugins/deprecated.py
index f6c8337..be4dba5 100644
--- a/test/lib/ansible_test/_util/controller/sanity/pylint/plugins/deprecated.py
+++ b/test/lib/ansible_test/_util/controller/sanity/pylint/plugins/deprecated.py
@@ -32,7 +32,6 @@ except ImportError:
from pylint.checkers import BaseChecker, BaseTokenChecker
from ansible.module_utils.compat.version import LooseVersion
-from ansible.module_utils.six import string_types
from ansible.release import __version__ as ansible_version_raw
from ansible.utils.version import SemanticVersion
@@ -137,7 +136,7 @@ def _get_func_name(node):
def parse_isodate(value):
"""Parse an ISO 8601 date string."""
msg = 'Expected ISO 8601 date string (YYYY-MM-DD)'
- if not isinstance(value, string_types):
+ if not isinstance(value, str):
raise ValueError(msg)
# From Python 3.7 in, there is datetime.date.fromisoformat(). For older versions,
# we have to do things manually.
diff --git a/test/lib/ansible_test/_util/controller/sanity/shellcheck/exclude.txt b/test/lib/ansible_test/_util/controller/sanity/shellcheck/exclude.txt
index 29588dd..6563f8f 100644
--- a/test/lib/ansible_test/_util/controller/sanity/shellcheck/exclude.txt
+++ b/test/lib/ansible_test/_util/controller/sanity/shellcheck/exclude.txt
@@ -1,3 +1,2 @@
SC1090
SC1091
-SC2164
diff --git a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py
index 2b92a56..5e3a07e 100644
--- a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py
+++ b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/main.py
@@ -70,13 +70,12 @@ from ansible.module_utils.common.collections import is_iterable
from ansible.module_utils.common.parameters import DEFAULT_TYPE_VALIDATORS
from ansible.module_utils.compat.version import StrictVersion, LooseVersion
from ansible.module_utils.basic import to_bytes
-from ansible.module_utils.six import PY3, with_metaclass, string_types
from ansible.plugins.loader import fragment_loader
from ansible.plugins.list import IGNORE as REJECTLIST
from ansible.utils.plugin_docs import add_collection_to_versions_and_dates, add_fragments, get_docstring
from ansible.utils.version import SemanticVersion
-from .module_args import AnsibleModuleImportError, AnsibleModuleNotInitialized, get_argument_spec
+from .module_args import AnsibleModuleImportError, AnsibleModuleNotInitialized, get_py_argument_spec, get_ps_argument_spec
from .schema import (
ansible_module_kwargs_schema,
@@ -87,18 +86,14 @@ from .schema import (
from .utils import CaptureStd, NoArgsAnsibleModule, compare_unordered_lists, parse_yaml, parse_isodate
-if PY3:
- # Because there is no ast.TryExcept in Python 3 ast module
- TRY_EXCEPT = ast.Try
- # REPLACER_WINDOWS from ansible.executor.module_common is byte
- # string but we need unicode for Python 3
- REPLACER_WINDOWS = REPLACER_WINDOWS.decode('utf-8')
-else:
- TRY_EXCEPT = ast.TryExcept
+# Because there is no ast.TryExcept in Python 3 ast module
+TRY_EXCEPT = ast.Try
+# REPLACER_WINDOWS from ansible.executor.module_common is byte
+# string but we need unicode for Python 3
+REPLACER_WINDOWS = REPLACER_WINDOWS.decode('utf-8')
REJECTLIST_DIRS = frozenset(('.git', 'test', '.github', '.idea'))
INDENT_REGEX = re.compile(r'([\t]*)')
-TYPE_REGEX = re.compile(r'.*(if|or)(\s+[^"\']*|\s+)(?<!_)(?<!str\()type\([^)].*')
SYS_EXIT_REGEX = re.compile(r'[^#]*sys.exit\s*\(.*')
NO_LOG_REGEX = re.compile(r'(?:pass(?!ive)|secret|token|key)', re.I)
@@ -269,7 +264,7 @@ class Reporter:
return 3 if sum(ret) else 0
-class Validator(with_metaclass(abc.ABCMeta, object)):
+class Validator(metaclass=abc.ABCMeta):
"""Validator instances are intended to be run on a single object. if you
are scanning multiple objects for problems, you'll want to have a separate
Validator for each one."""
@@ -335,8 +330,6 @@ class ModuleValidator(Validator):
self.git_cache = git_cache
self.base_module = self.git_cache.get_original_path(self.path)
- self._python_module_override = False
-
with open(path) as f:
self.text = f.read()
self.length = len(self.text.splitlines())
@@ -383,7 +376,7 @@ class ModuleValidator(Validator):
pass
def _python_module(self):
- if self.path.endswith('.py') or self._python_module_override:
+ if self.path.endswith('.py'):
return True
return False
@@ -421,7 +414,7 @@ class ModuleValidator(Validator):
return self.git_cache.is_new(self.path)
def _check_interpreter(self, powershell=False):
- if powershell:
+ if self._powershell_module():
if not self.text.startswith('#!powershell\n'):
self.reporter.error(
path=self.object_path,
@@ -430,34 +423,20 @@ class ModuleValidator(Validator):
)
return
- missing_python_interpreter = False
-
- if not self.text.startswith('#!/usr/bin/python'):
- if NEW_STYLE_PYTHON_MODULE_RE.search(to_bytes(self.text)):
- missing_python_interpreter = self.text.startswith('#!') # shebang optional, but if present must match
- else:
- missing_python_interpreter = True # shebang required
+ if self._python_module():
+ missing_python_interpreter = False
- if missing_python_interpreter:
- self.reporter.error(
- path=self.object_path,
- code='missing-python-interpreter',
- msg='Interpreter line is not "#!/usr/bin/python"',
- )
+ if not self.text.startswith('#!/usr/bin/python'):
+ if NEW_STYLE_PYTHON_MODULE_RE.search(to_bytes(self.text)):
+ missing_python_interpreter = self.text.startswith('#!') # shebang optional, but if present must match
+ else:
+ missing_python_interpreter = True # shebang required
- def _check_type_instead_of_isinstance(self, powershell=False):
- if powershell:
- return
- for line_no, line in enumerate(self.text.splitlines()):
- typekeyword = TYPE_REGEX.match(line)
- if typekeyword:
- # TODO: add column
+ if missing_python_interpreter:
self.reporter.error(
path=self.object_path,
- code='unidiomatic-typecheck',
- msg=('Type comparison using type() found. '
- 'Use isinstance() instead'),
- line=line_no + 1
+ code='missing-python-interpreter',
+ msg='Interpreter line is not "#!/usr/bin/python"',
)
def _check_for_sys_exit(self):
@@ -1120,14 +1099,6 @@ class ModuleValidator(Validator):
' documentation for removed'
)
else:
- # We are testing a collection
- if self.object_name.startswith('_'):
- self.reporter.error(
- path=self.object_path,
- code='collections-no-underscore-on-deprecation',
- msg='Deprecated content in collections MUST NOT start with "_", update meta/runtime.yml instead',
- )
-
if not (doc_deprecated == routing_says_deprecated):
# DOCUMENTATION.deprecated and meta/runtime.yml disagree
self.reporter.error(
@@ -1193,7 +1164,7 @@ class ModuleValidator(Validator):
for entry in object:
self._validate_semantic_markup(entry)
return
- if not isinstance(object, string_types):
+ if not isinstance(object, str):
return
if self.collection:
@@ -1312,7 +1283,12 @@ class ModuleValidator(Validator):
def _validate_ansible_module_call(self, docs):
try:
- spec, kwargs = get_argument_spec(self.path, self.collection)
+ if self._python_module():
+ spec, kwargs = get_py_argument_spec(self.path, self.collection)
+ elif self._powershell_module():
+ spec, kwargs = get_ps_argument_spec(self.path, self.collection)
+ else:
+ raise NotImplementedError()
except AnsibleModuleNotInitialized:
self.reporter.error(
path=self.object_path,
@@ -1374,7 +1350,7 @@ class ModuleValidator(Validator):
continue
bad_term = False
for term in check:
- if not isinstance(term, string_types):
+ if not isinstance(term, str):
msg = name
if context:
msg += " found in %s" % " -> ".join(context)
@@ -1442,7 +1418,7 @@ class ModuleValidator(Validator):
continue
bad_term = False
for term in requirements:
- if not isinstance(term, string_types):
+ if not isinstance(term, str):
msg = "required_if"
if context:
msg += " found in %s" % " -> ".join(context)
@@ -1525,13 +1501,13 @@ class ModuleValidator(Validator):
# This is already reported by schema checking
return
for key, value in terms.items():
- if isinstance(value, string_types):
+ if isinstance(value, str):
value = [value]
if not isinstance(value, (list, tuple)):
# This is already reported by schema checking
continue
for term in value:
- if not isinstance(term, string_types):
+ if not isinstance(term, str):
# This is already reported by schema checking
continue
if len(set(value)) != len(value) or key in value:
@@ -2268,7 +2244,6 @@ class ModuleValidator(Validator):
'extension for python modules or a .ps1 '
'for powershell modules')
)
- self._python_module_override = True
if self._python_module() and self.ast is None:
self.reporter.error(
@@ -2380,10 +2355,7 @@ class ModuleValidator(Validator):
self._check_gpl3_header()
if not self._just_docs() and not self._sidecar_doc() and not end_of_deprecation_should_be_removed_only:
if self.plugin_type == 'module':
- self._check_interpreter(powershell=self._powershell_module())
- self._check_type_instead_of_isinstance(
- powershell=self._powershell_module()
- )
+ self._check_interpreter()
class PythonPackageValidator(Validator):
diff --git a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/module_args.py b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/module_args.py
index 1b71217..bff9306 100644
--- a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/module_args.py
+++ b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/module_args.py
@@ -167,10 +167,3 @@ def get_py_argument_spec(filename, collection):
return argument_spec, fake.kwargs
except (TypeError, IndexError):
return {}, {}
-
-
-def get_argument_spec(filename, collection):
- if filename.endswith('.py'):
- return get_py_argument_spec(filename, collection)
- else:
- return get_ps_argument_spec(filename, collection)
diff --git a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/schema.py b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/schema.py
index a6068c6..ba4e188 100644
--- a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/schema.py
+++ b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/schema.py
@@ -297,6 +297,7 @@ def argument_spec_schema(for_collection):
[is_callable, list_string_types],
),
'choices': Any([object], (object,)),
+ 'context': dict,
'required': bool,
'no_log': bool,
'aliases': Any(list_string_types, tuple(list_string_types)),
@@ -487,10 +488,17 @@ def check_option_choices(v):
type_checker, type_name = get_type_checker({'type': v.get('elements')})
else:
type_checker, type_name = get_type_checker(v)
+
if type_checker is None:
return v
- for value in v_choices:
+ if isinstance(v_choices, dict):
+ # choices are still a list (the keys) but dict form serves to document each choice.
+ iterate = v_choices.keys()
+ else:
+ iterate = v_choices
+
+ for value in iterate:
try:
type_checker(value)
except Exception as exc:
@@ -542,7 +550,7 @@ def list_dict_option_schema(for_collection, plugin_type):
basic_option_schema = {
Required('description'): doc_string_or_strings,
'required': bool,
- 'choices': list,
+ 'choices': Any(list, {object: doc_string_or_strings}),
'aliases': Any(list_string_types),
'version_added': version(for_collection),
'version_added_collection': collection_name,
diff --git a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/utils.py b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/utils.py
index 15cb703..84bab28 100644
--- a/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/utils.py
+++ b/test/lib/ansible_test/_util/controller/sanity/validate-modules/validate_modules/utils.py
@@ -192,7 +192,7 @@ def compare_unordered_lists(a, b):
- unordered lists
- unhashable elements
"""
- return len(a) == len(b) and all(x in b for x in a)
+ return len(a) == len(b) and all(x in b for x in a) and all(x in a for x in b)
class NoArgsAnsibleModule(AnsibleModule):
diff --git a/test/lib/ansible_test/_util/controller/sanity/yamllint/yamllinter.py b/test/lib/ansible_test/_util/controller/sanity/yamllint/yamllinter.py
index ed1afcf..0c39fc7 100644
--- a/test/lib/ansible_test/_util/controller/sanity/yamllint/yamllinter.py
+++ b/test/lib/ansible_test/_util/controller/sanity/yamllint/yamllinter.py
@@ -126,19 +126,31 @@ class YamlChecker:
yaml_data = yaml_data[1:]
lineno += 1
- self.check_parsable(path, yaml_data, lineno)
+ multiple_docs_allowed = [
+ "EXAMPLES",
+ ]
+ self.check_parsable(path, yaml_data, lineno, (key in multiple_docs_allowed), key)
messages = list(linter.run(yaml_data, conf, path))
self.messages += [self.result_to_message(r, path, lineno - 1, key) for r in messages]
- def check_parsable(self, path, contents, lineno=1): # type: (str, str, int) -> None
+ def check_parsable(self, path, contents, lineno=1, allow_multiple=False, prefix=""): # type: (str, str, int, bool) -> None
"""Check the given contents to verify they can be parsed as YAML."""
+ prefix = f"{prefix}: " if prefix else ""
try:
- yaml.load(contents, Loader=TestLoader)
+ documents = len(list(yaml.load_all(contents, Loader=TestLoader)))
+ if documents > 1 and not allow_multiple:
+ self.messages += [{'code': 'multiple-yaml-documents',
+ 'message': f'{prefix}expected a single document in the stream',
+ 'path': path,
+ 'line': lineno,
+ 'column': 1,
+ 'level': 'error',
+ }]
except MarkedYAMLError as ex:
self.messages += [{'code': 'unparsable-with-libyaml',
- 'message': '%s - %s' % (ex.args[0], ex.args[2]),
+ 'message': f'{prefix}{ex.args[0]} - {ex.args[2]}',
'path': path,
'line': ex.problem_mark.line + lineno,
'column': ex.problem_mark.column + 1,
diff --git a/test/lib/ansible_test/_util/controller/tools/sslcheck.py b/test/lib/ansible_test/_util/controller/tools/sslcheck.py
deleted file mode 100644
index c25fed6..0000000
--- a/test/lib/ansible_test/_util/controller/tools/sslcheck.py
+++ /dev/null
@@ -1,22 +0,0 @@
-"""Show openssl version."""
-from __future__ import annotations
-
-import json
-
-# noinspection PyBroadException
-try:
- from ssl import OPENSSL_VERSION_INFO
- VERSION = list(OPENSSL_VERSION_INFO[:3])
-except Exception: # pylint: disable=broad-except
- VERSION = None
-
-
-def main():
- """Main program entry point."""
- print(json.dumps(dict(
- version=VERSION,
- )))
-
-
-if __name__ == '__main__':
- main()
diff --git a/test/lib/ansible_test/_util/target/__init__.py b/test/lib/ansible_test/_util/target/__init__.py
index 527d413..8f58623 100644
--- a/test/lib/ansible_test/_util/target/__init__.py
+++ b/test/lib/ansible_test/_util/target/__init__.py
@@ -1,2 +1 @@
-# Empty __init__.py to allow importing of `ansible_test._util.target.common` under Python 2.x.
-# This allows the ansible-test entry point to report supported Python versions before exiting.
+# Empty __init__.py to keep pylint happy.
diff --git a/test/lib/ansible_test/_util/target/cli/ansible_test_cli_stub.py b/test/lib/ansible_test/_util/target/cli/ansible_test_cli_stub.py
index 930654f..9cb5d04 100755
--- a/test/lib/ansible_test/_util/target/cli/ansible_test_cli_stub.py
+++ b/test/lib/ansible_test/_util/target/cli/ansible_test_cli_stub.py
@@ -4,8 +4,7 @@
# NOTE: This file resides in the _util/target directory to ensure compatibility with all supported Python versions.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import sys
diff --git a/test/lib/ansible_test/_util/target/common/__init__.py b/test/lib/ansible_test/_util/target/common/__init__.py
deleted file mode 100644
index 527d413..0000000
--- a/test/lib/ansible_test/_util/target/common/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# Empty __init__.py to allow importing of `ansible_test._util.target.common` under Python 2.x.
-# This allows the ansible-test entry point to report supported Python versions before exiting.
diff --git a/test/lib/ansible_test/_util/target/common/constants.py b/test/lib/ansible_test/_util/target/common/constants.py
index 36a5a2c..fdad9f2 100644
--- a/test/lib/ansible_test/_util/target/common/constants.py
+++ b/test/lib/ansible_test/_util/target/common/constants.py
@@ -2,12 +2,9 @@
# NOTE: This file resides in the _util/target directory to ensure compatibility with all supported Python versions.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
REMOTE_ONLY_PYTHON_VERSIONS = (
- '2.7',
- '3.6',
'3.7',
'3.8',
'3.9',
diff --git a/test/lib/ansible_test/_util/target/injector/python.py b/test/lib/ansible_test/_util/target/injector/python.py
index c1e88a9..82f59b1 100644
--- a/test/lib/ansible_test/_util/target/injector/python.py
+++ b/test/lib/ansible_test/_util/target/injector/python.py
@@ -1,8 +1,8 @@
# auto-shebang
"""Provides an entry point for python scripts and python modules on the controller with the current python interpreter and optional code coverage collection."""
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
+import importlib.util
import os
import sys
@@ -19,22 +19,7 @@ def main():
if coverage_output:
args += ['-m', 'coverage.__main__', 'run', '--rcfile', coverage_config]
else:
- if sys.version_info >= (3, 4):
- # noinspection PyUnresolvedReferences
- import importlib.util
-
- # noinspection PyUnresolvedReferences
- found = bool(importlib.util.find_spec('coverage'))
- else:
- # noinspection PyDeprecation
- import imp
-
- try:
- # noinspection PyDeprecation
- imp.find_module('coverage')
- found = True
- except ImportError:
- found = False
+ found = bool(importlib.util.find_spec('coverage'))
if not found:
sys.exit('ERROR: Could not find `coverage` module. '
@@ -62,7 +47,7 @@ def find_program(name, executable): # type: (str, bool) -> str
Raises an exception if the program is not found.
"""
path = os.environ.get('PATH', os.path.defpath)
- seen = set([os.path.abspath(__file__)])
+ seen = {os.path.abspath(__file__)}
mode = os.F_OK | os.X_OK if executable else os.F_OK
for base in path.split(os.path.pathsep):
diff --git a/test/lib/ansible_test/_util/target/pytest/plugins/ansible_forked.py b/test/lib/ansible_test/_util/target/pytest/plugins/ansible_forked.py
index d00d9e9..9e98359 100644
--- a/test/lib/ansible_test/_util/target/pytest/plugins/ansible_forked.py
+++ b/test/lib/ansible_test/_util/target/pytest/plugins/ansible_forked.py
@@ -4,21 +4,14 @@
# https://github.com/pytest-dev/pytest-forked
# https://github.com/pytest-dev/py
# TIP: Disable pytest-xdist when debugging internal errors in this plugin.
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
import os
import pickle
import tempfile
import warnings
-from pytest import Item, hookimpl
-
-try:
- from pytest import TestReport
-except ImportError:
- from _pytest.runner import TestReport # Backwards compatibility with pytest < 7. Remove once Python 2.7 is not supported.
+from pytest import Item, hookimpl, TestReport
from _pytest.runner import runtestprotocol
diff --git a/test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_collections.py b/test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_collections.py
index 2f77c03..3aa2e12 100644
--- a/test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_collections.py
+++ b/test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_collections.py
@@ -1,6 +1,5 @@
"""Enable unit testing of Ansible collections. PYTEST_DONT_REWRITE"""
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
@@ -39,9 +38,6 @@ def enable_assertion_rewriting_hook(): # type: () -> None
"""
import sys
- if sys.version_info[0] == 2:
- return # Python 2.x is not supported
-
hook_name = '_pytest.assertion.rewrite.AssertionRewritingHook'
hooks = [hook for hook in sys.meta_path if hook.__class__.__module__ + '.' + hook.__class__.__qualname__ == hook_name]
diff --git a/test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_coverage.py b/test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_coverage.py
index b05298a..577a498 100644
--- a/test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_coverage.py
+++ b/test/lib/ansible_test/_util/target/pytest/plugins/ansible_pytest_coverage.py
@@ -1,6 +1,5 @@
"""Monkey patch os._exit when running under coverage so we don't lose coverage data in forks, such as with `pytest --boxed`. PYTEST_DONT_REWRITE"""
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def pytest_configure():
diff --git a/test/lib/ansible_test/_util/target/sanity/compile/compile.py b/test/lib/ansible_test/_util/target/sanity/compile/compile.py
index bd2446f..3dfec39 100644
--- a/test/lib/ansible_test/_util/target/sanity/compile/compile.py
+++ b/test/lib/ansible_test/_util/target/sanity/compile/compile.py
@@ -1,12 +1,10 @@
"""Python syntax checker with lint friendly output."""
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import sys
ENCODING = 'utf-8'
ERRORS = 'replace'
-Text = type(u'')
def main():
@@ -29,21 +27,14 @@ def compile_source(path):
else:
return
- # In some situations offset can be None. This can happen for syntax errors on Python 2.6
- # (__future__ import following after a regular import).
- offset = offset or 0
-
result = "%s:%d:%d: %s: %s" % (path, lineno, offset, extype.__name__, safe_message(message))
- if sys.version_info <= (3,):
- result = result.encode(ENCODING, ERRORS)
-
print(result)
def safe_message(value):
- """Given an input value as text or bytes, return the first non-empty line as text, ensuring it can be round-tripped as UTF-8."""
- if isinstance(value, Text):
+ """Given an input value as str or bytes, return the first non-empty line as str, ensuring it can be round-tripped as UTF-8."""
+ if isinstance(value, str):
value = value.encode(ENCODING, ERRORS)
value = value.decode(ENCODING, ERRORS)
diff --git a/test/lib/ansible_test/_util/target/sanity/import/importer.py b/test/lib/ansible_test/_util/target/sanity/import/importer.py
index 38a7364..28f3f85 100644
--- a/test/lib/ansible_test/_util/target/sanity/import/importer.py
+++ b/test/lib/ansible_test/_util/target/sanity/import/importer.py
@@ -1,6 +1,5 @@
"""Import the given python module(s) and report error(s) encountered."""
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
def main():
@@ -542,16 +541,6 @@ def main():
"ignore",
"AnsibleCollectionFinder has already been configured")
- if sys.version_info[0] == 2:
- warnings.filterwarnings(
- "ignore",
- "Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography,"
- " and will be removed in a future release.")
- warnings.filterwarnings(
- "ignore",
- "Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography,"
- " and will be removed in the next release.")
-
# ansible.utils.unsafe_proxy attempts patching sys.intern generating a warning if it was already patched
warnings.filterwarnings(
"ignore",
diff --git a/test/lib/ansible_test/_util/target/setup/bootstrap.sh b/test/lib/ansible_test/_util/target/setup/bootstrap.sh
index 65673da..16e6d38 100644
--- a/test/lib/ansible_test/_util/target/setup/bootstrap.sh
+++ b/test/lib/ansible_test/_util/target/setup/bootstrap.sh
@@ -2,6 +2,16 @@
set -eu
+remove_externally_managed_marker()
+{
+ "${python_interpreter}" -c '
+import pathlib
+import sysconfig
+path = pathlib.Path(sysconfig.get_path("stdlib")) / "EXTERNALLY-MANAGED"
+path.unlink(missing_ok=True)
+'
+}
+
install_ssh_keys()
{
if [ ! -f "${ssh_private_key_path}" ]; then
@@ -49,9 +59,6 @@ customize_bashrc()
install_pip() {
if ! "${python_interpreter}" -m pip.__main__ --version --disable-pip-version-check 2>/dev/null; then
case "${python_version}" in
- "2.7")
- pip_bootstrap_url="https://ci-files.testing.ansible.com/ansible-test/get-pip-20.3.4.py"
- ;;
*)
pip_bootstrap_url="https://ci-files.testing.ansible.com/ansible-test/get-pip-23.1.2.py"
;;
@@ -68,18 +75,6 @@ install_pip() {
fi
}
-pip_install() {
- pip_packages="$1"
-
- while true; do
- # shellcheck disable=SC2086
- "${python_interpreter}" -m pip install --disable-pip-version-check ${pip_packages} \
- && break
- echo "Failed to install packages. Sleeping before trying again..."
- sleep 10
- done
-}
-
bootstrap_remote_alpine()
{
py_pkg_prefix="py3"
@@ -168,19 +163,39 @@ bootstrap_remote_freebsd()
jinja2_pkg="py${python_package_version}-jinja2"
cryptography_pkg="py${python_package_version}-cryptography"
pyyaml_pkg="py${python_package_version}-yaml"
+ packaging_pkg="py${python_package_version}-packaging"
# Declare platform/python version combinations which do not have supporting OS packages available.
# For these combinations ansible-test will use pip to install the requirements instead.
case "${platform_version}/${python_version}" in
+ 13.3/3.9)
+ # defaults above 'just work'TM
+ ;;
+ 13.3/3.11)
+ jinja2_pkg="" # not available
+ cryptography_pkg="" # not available
+ pyyaml_pkg="" # not available
+ ;;
+ 14.0/3.9)
+ # defaults above 'just work'TM
+ ;;
+ 14.0/3.11)
+ cryptography_pkg="" # not available
+ jinja2_pkg="" # not available
+ pyyaml_pkg="" # not available
+ ;;
*)
+ # just assume nothing is available
jinja2_pkg="" # not available
cryptography_pkg="" # not available
pyyaml_pkg="" # not available
+ packaging_pkg="" # not available
;;
esac
packages="
${packages}
+ ${packaging_pkg}
libyaml
${pyyaml_pkg}
${jinja2_pkg}
@@ -242,79 +257,6 @@ bootstrap_remote_macos()
echo 'PATH="/usr/local/bin:$PATH"' > /etc/zshenv
}
-bootstrap_remote_rhel_7()
-{
- packages="
- gcc
- python-devel
- python-virtualenv
- "
-
- while true; do
- # shellcheck disable=SC2086
- yum install -q -y ${packages} \
- && break
- echo "Failed to install packages. Sleeping before trying again..."
- sleep 10
- done
-
- install_pip
-
- bootstrap_remote_rhel_pinned_pip_packages
-}
-
-bootstrap_remote_rhel_8()
-{
- if [ "${python_version}" = "3.6" ]; then
- py_pkg_prefix="python3"
- else
- py_pkg_prefix="python${python_version}"
- fi
-
- packages="
- gcc
- ${py_pkg_prefix}-devel
- "
-
- # pip isn't included in the Python devel package under Python 3.11
- if [ "${python_version}" != "3.6" ]; then
- packages="
- ${packages}
- ${py_pkg_prefix}-pip
- "
- fi
-
- # Jinja2 is not installed with an OS package since the provided version is too old.
- # Instead, ansible-test will install it using pip.
- if [ "${controller}" ]; then
- packages="
- ${packages}
- ${py_pkg_prefix}-cryptography
- "
- fi
-
- # Python 3.11 isn't a module like the earlier versions
- if [ "${python_version}" = "3.6" ]; then
- while true; do
- # shellcheck disable=SC2086
- yum module install -q -y "python${python_package_version}" \
- && break
- echo "Failed to install packages. Sleeping before trying again..."
- sleep 10
- done
- fi
-
- while true; do
- # shellcheck disable=SC2086
- yum install -q -y ${packages} \
- && break
- echo "Failed to install packages. Sleeping before trying again..."
- sleep 10
- done
-
- bootstrap_remote_rhel_pinned_pip_packages
-}
-
bootstrap_remote_rhel_9()
{
if [ "${python_version}" = "3.9" ]; then
@@ -360,23 +302,10 @@ bootstrap_remote_rhel_9()
bootstrap_remote_rhel()
{
case "${platform_version}" in
- 7.*) bootstrap_remote_rhel_7 ;;
- 8.*) bootstrap_remote_rhel_8 ;;
9.*) bootstrap_remote_rhel_9 ;;
esac
}
-bootstrap_remote_rhel_pinned_pip_packages()
-{
- # pin packaging and pyparsing to match the downstream vendored versions
- pip_packages="
- packaging==20.4
- pyparsing==2.4.7
- "
-
- pip_install "${pip_packages}"
-}
-
bootstrap_remote_ubuntu()
{
py_pkg_prefix="python3"
@@ -430,14 +359,27 @@ bootstrap_docker()
{
# Required for newer mysql-server packages to install/upgrade on Ubuntu 16.04.
rm -f /usr/sbin/policy-rc.d
+
+ for key_value in ${python_interpreters}; do
+ IFS=':' read -r python_version python_interpreter << EOF
+${key_value}
+EOF
+
+ echo "Bootstrapping Python ${python_version} at: ${python_interpreter}"
+
+ remove_externally_managed_marker
+ done
}
bootstrap_remote()
{
- for python_version in ${python_versions}; do
- echo "Bootstrapping Python ${python_version}"
+ for key_value in ${python_interpreters}; do
+ IFS=':' read -r python_version python_interpreter << EOF
+${key_value}
+EOF
+
+ echo "Bootstrapping Python ${python_version} at: ${python_interpreter}"
- python_interpreter="python${python_version}"
python_package_version="$(echo "${python_version}" | tr -d '.')"
case "${platform}" in
@@ -448,6 +390,8 @@ bootstrap_remote()
"rhel") bootstrap_remote_rhel ;;
"ubuntu") bootstrap_remote_ubuntu ;;
esac
+
+ remove_externally_managed_marker
done
}
@@ -474,7 +418,7 @@ bootstrap_type=#{bootstrap_type}
controller=#{controller}
platform=#{platform}
platform_version=#{platform_version}
-python_versions=#{python_versions}
+python_interpreters=#{python_interpreters}
ssh_key_type=#{ssh_key_type}
ssh_private_key=#{ssh_private_key}
ssh_public_key=#{ssh_public_key}
diff --git a/test/lib/ansible_test/_util/target/setup/probe_cgroups.py b/test/lib/ansible_test/_util/target/setup/probe_cgroups.py
index 2ac7ecb..a09c024 100644
--- a/test/lib/ansible_test/_util/target/setup/probe_cgroups.py
+++ b/test/lib/ansible_test/_util/target/setup/probe_cgroups.py
@@ -1,6 +1,5 @@
"""A tool for probing cgroups to determine write access."""
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import os
diff --git a/test/lib/ansible_test/_util/target/setup/quiet_pip.py b/test/lib/ansible_test/_util/target/setup/quiet_pip.py
index 171ff8f..c2e9ba2 100644
--- a/test/lib/ansible_test/_util/target/setup/quiet_pip.py
+++ b/test/lib/ansible_test/_util/target/setup/quiet_pip.py
@@ -1,20 +1,17 @@
"""Custom entry-point for pip that filters out unwanted logging and warnings."""
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import logging
import os
import re
import runpy
import sys
-import warnings
BUILTIN_FILTERER_FILTER = logging.Filterer.filter
LOGGING_MESSAGE_FILTER = re.compile("^("
".*Running pip install with root privileges is generally not a good idea.*|" # custom Fedora patch [1]
".*Running pip as the 'root' user can result in broken permissions .*|" # pip 21.1
- "DEPRECATION: Python 2.7 will reach the end of its life .*|" # pip 19.2.3
"Ignoring .*: markers .* don't match your environment|"
"Looking in indexes: .*|" # pypi-test-container
"Requirement already satisfied.*"
@@ -22,13 +19,6 @@ LOGGING_MESSAGE_FILTER = re.compile("^("
# [1] https://src.fedoraproject.org/rpms/python-pip/blob/f34/f/emit-a-warning-when-running-with-root-privileges.patch
-WARNING_MESSAGE_FILTERS = (
- # DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained.
- # pip 21.0 will drop support for Python 2.7 in January 2021.
- # More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
- 'DEPRECATION: Python 2.7 reached the end of its life ',
-)
-
def custom_filterer_filter(self, record):
"""Globally omit logging of unwanted messages."""
@@ -44,11 +34,6 @@ def main():
# It also avoids problems with loss of color output and mixing up the order of stdout/stderr messages.
logging.Filterer.filter = custom_filterer_filter
- for message_filter in WARNING_MESSAGE_FILTERS:
- # Setting filterwarnings in code is necessary because of the following:
- # Python 2.7 cannot use the -W option to match warning text after a colon. This makes it impossible to match specific warning messages.
- warnings.filterwarnings('ignore', message_filter)
-
get_pip = os.environ.get('GET_PIP')
try:
diff --git a/test/lib/ansible_test/_util/target/setup/requirements.py b/test/lib/ansible_test/_util/target/setup/requirements.py
index b145fde..a320dfc 100644
--- a/test/lib/ansible_test/_util/target/setup/requirements.py
+++ b/test/lib/ansible_test/_util/target/setup/requirements.py
@@ -1,6 +1,5 @@
"""A tool for installing test requirements on the controller and target host."""
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
# pylint: disable=wrong-import-position
@@ -250,6 +249,14 @@ def common_pip_environment(): # type: () -> t.Dict[str, str]
"""Return common environment variables used to run pip."""
env = os.environ.copy()
+ # When ansible-test installs requirements outside a virtual environment, it does so under one of two conditions:
+ # 1) The environment is an ephemeral one provisioned by ansible-test.
+ # 2) The user has provided the `--requirements` option to force installation of requirements.
+ # It seems reasonable to bypass PEP 668 checks in both of these cases.
+ # Doing so with an environment variable allows it to work under any version of pip which supports it, without breaking older versions.
+ # NOTE: pip version 23.0 enforces PEP 668 but does not support the override, in which case upgrading pip is required.
+ env.update(PIP_BREAK_SYSTEM_PACKAGES='1')
+
return env
diff --git a/test/lib/ansible_test/_util/target/tools/virtualenvcheck.py b/test/lib/ansible_test/_util/target/tools/virtualenvcheck.py
index a38ad07..49b308b 100644
--- a/test/lib/ansible_test/_util/target/tools/virtualenvcheck.py
+++ b/test/lib/ansible_test/_util/target/tools/virtualenvcheck.py
@@ -1,6 +1,5 @@
"""Detect the real python interpreter when running in a virtual environment created by the 'virtualenv' module."""
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/lib/ansible_test/_util/target/tools/yamlcheck.py b/test/lib/ansible_test/_util/target/tools/yamlcheck.py
index dfd08e5..07dccca 100644
--- a/test/lib/ansible_test/_util/target/tools/yamlcheck.py
+++ b/test/lib/ansible_test/_util/target/tools/yamlcheck.py
@@ -1,6 +1,5 @@
"""Show availability of PyYAML and libyaml support."""
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/sanity/code-smell/ansible-test-future-boilerplate.json b/test/sanity/code-smell/ansible-test-future-boilerplate.json
deleted file mode 100644
index ca4c067..0000000
--- a/test/sanity/code-smell/ansible-test-future-boilerplate.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "extensions": [
- ".py"
- ],
- "prefixes": [
- "test/sanity/",
- "test/lib/ansible_test/"
- ],
- "output": "path-message"
-}
diff --git a/test/lib/ansible_test/_util/controller/sanity/code-smell/future-import-boilerplate.json b/test/sanity/code-smell/boilerplate.json
index 4ebce32..6f1edb7 100644
--- a/test/lib/ansible_test/_util/controller/sanity/code-smell/future-import-boilerplate.json
+++ b/test/sanity/code-smell/boilerplate.json
@@ -2,6 +2,5 @@
"extensions": [
".py"
],
- "py2_compat": true,
"output": "path-message"
}
diff --git a/test/sanity/code-smell/ansible-test-future-boilerplate.py b/test/sanity/code-smell/boilerplate.py
index 9a62225..d0ab20d 100644
--- a/test/sanity/code-smell/ansible-test-future-boilerplate.py
+++ b/test/sanity/code-smell/boilerplate.py
@@ -5,15 +5,7 @@ import sys
def main():
- # The following directories contain code which must work under Python 2.x.
- py2_compat = (
- 'test/lib/ansible_test/_util/target/',
- )
-
for path in sys.argv[1:] or sys.stdin.read().splitlines():
- if any(path.startswith(prefix) for prefix in py2_compat):
- continue
-
with open(path, 'rb') as path_fd:
lines = path_fd.read().splitlines()
@@ -25,11 +17,11 @@ def main():
invalid_future = []
for text in lines:
- if text == b'from __future__ import annotations':
+ if text in (b'from __future__ import annotations', b'from __future__ import annotations # pragma: nocover'):
missing = False
break
- if text.startswith(b'from __future__ ') or text == b'__metaclass__ = type':
+ if text.strip().startswith(b'from __future__ ') or text.strip().startswith(b'__metaclass__ '):
invalid_future.append(text.decode())
if missing:
@@ -41,7 +33,6 @@ def main():
node = ast.parse(contents)
# files consisting of only assignments have no need for future import boilerplate
- # the only exception would be division during assignment, but we'll overlook that for simplicity
# the most likely case is that of a documentation only python file
if all(isinstance(statement, ast.Assign) for statement in node.body):
missing = False
diff --git a/test/sanity/code-smell/deprecated-config.py b/test/sanity/code-smell/deprecated-config.py
index 474628a..7056ca2 100644
--- a/test/sanity/code-smell/deprecated-config.py
+++ b/test/sanity/code-smell/deprecated-config.py
@@ -55,8 +55,7 @@ def find_deprecations(obj, path=None):
this_path.append(key)
if key != 'deprecated':
- for result in find_deprecations(value, path=this_path):
- yield result
+ yield from find_deprecations(value, path=this_path)
else:
try:
version = value['version']
diff --git a/test/sanity/code-smell/deprecated-config.requirements.txt b/test/sanity/code-smell/deprecated-config.requirements.txt
index ae96cdf..42c1825 100644
--- a/test/sanity/code-smell/deprecated-config.requirements.txt
+++ b/test/sanity/code-smell/deprecated-config.requirements.txt
@@ -1,4 +1,4 @@
# edit "deprecated-config.requirements.in" and generate with: hacking/update-sanity-requirements.py --test deprecated-config
-Jinja2==3.1.2
-MarkupSafe==2.1.3
+Jinja2==3.1.3
+MarkupSafe==2.1.5
PyYAML==6.0.1
diff --git a/test/sanity/code-smell/no-unwanted-characters.json b/test/sanity/code-smell/no-unwanted-characters.json
new file mode 100644
index 0000000..5648429
--- /dev/null
+++ b/test/sanity/code-smell/no-unwanted-characters.json
@@ -0,0 +1,4 @@
+{
+ "text": true,
+ "output": "path-line-column-message"
+}
diff --git a/test/sanity/code-smell/no-unwanted-characters.py b/test/sanity/code-smell/no-unwanted-characters.py
new file mode 100644
index 0000000..26e5912
--- /dev/null
+++ b/test/sanity/code-smell/no-unwanted-characters.py
@@ -0,0 +1,27 @@
+"""Disallow use of unwanted Unicode characters."""
+from __future__ import annotations
+
+import re
+import sys
+
+
+def main():
+ """Main entry point."""
+ for path in sys.argv[1:] or sys.stdin.read().splitlines():
+ with open(path, 'rb') as path_fd:
+ for line, text in enumerate(path_fd.readlines()):
+ try:
+ text = text.decode('utf-8')
+ except UnicodeDecodeError as ex:
+ print('%s:%d:%d: UnicodeDecodeError: %s' % (path, line + 1, ex.start + 1, ex))
+ continue
+
+ match = re.search('(\u00a0)', text)
+
+ if match:
+ print('%s:%d:%d: use an ASCII space instead of a Unicode no-break space' % (
+ path, line + 1, match.start(1) + 1))
+
+
+if __name__ == '__main__':
+ main()
diff --git a/test/sanity/code-smell/package-data.requirements.txt b/test/sanity/code-smell/package-data.requirements.txt
index ce0fb9c..4faee33 100644
--- a/test/sanity/code-smell/package-data.requirements.txt
+++ b/test/sanity/code-smell/package-data.requirements.txt
@@ -1,10 +1,10 @@
# edit "package-data.requirements.in" and generate with: hacking/update-sanity-requirements.py --test package-data
-antsibull-changelog==0.23.0
-build==1.0.3
+antsibull-changelog==0.26.0
+build==1.1.1
docutils==0.18.1
-Jinja2==3.1.2
-MarkupSafe==2.1.3
-packaging==23.2
+Jinja2==3.1.3
+MarkupSafe==2.1.5
+packaging==24.0
pyproject_hooks==1.0.0
PyYAML==6.0.1
resolvelib==1.0.1
@@ -13,5 +13,5 @@ semantic-version==2.10.0
setuptools==66.1.0
tomli==2.0.1
types-docutils==0.18.3
-typing_extensions==4.8.0
-wheel==0.41.2
+typing_extensions==4.10.0
+wheel==0.43.0
diff --git a/test/sanity/code-smell/pymarkdown.requirements.txt b/test/sanity/code-smell/pymarkdown.requirements.txt
index f906e14..c1571c9 100644
--- a/test/sanity/code-smell/pymarkdown.requirements.txt
+++ b/test/sanity/code-smell/pymarkdown.requirements.txt
@@ -1,9 +1,9 @@
# edit "pymarkdown.requirements.in" and generate with: hacking/update-sanity-requirements.py --test pymarkdown
-application-properties==0.8.1
+application_properties==0.8.2
Columnar==1.4.1
-pymarkdownlnt==0.9.13.4
+pymarkdownlnt==0.9.18
PyYAML==6.0.1
tomli==2.0.1
-toolz==0.12.0
-typing_extensions==4.8.0
-wcwidth==0.2.8
+toolz==0.12.1
+typing_extensions==4.10.0
+wcwidth==0.2.13
diff --git a/test/sanity/code-smell/test-constraints.py b/test/sanity/code-smell/test-constraints.py
index ac5bb4e..3802228 100644
--- a/test/sanity/code-smell/test-constraints.py
+++ b/test/sanity/code-smell/test-constraints.py
@@ -69,16 +69,13 @@ def main():
def check_ansible_test(path: str, requirements: list[tuple[int, str, re.Match]]) -> None:
sys.path.insert(0, str(pathlib.Path(__file__).parent.parent.parent.joinpath('lib')))
- from ansible_test._internal.python_requirements import VIRTUALENV_VERSION
from ansible_test._internal.coverage_util import COVERAGE_VERSIONS
from ansible_test._internal.util import version_to_str
- expected_lines = set([
- f"virtualenv == {VIRTUALENV_VERSION} ; python_version < '3'",
- ] + [
+ expected_lines = set((
f"coverage == {item.coverage_version} ; python_version >= '{version_to_str(item.min_python)}' and python_version <= '{version_to_str(item.max_python)}'"
for item in COVERAGE_VERSIONS
- ])
+ ))
for idx, requirement in enumerate(requirements):
lineno, line, match = requirement
diff --git a/test/sanity/code-smell/update-bundled.py b/test/sanity/code-smell/update-bundled.py
index 4bad77a..61c837c 100644
--- a/test/sanity/code-smell/update-bundled.py
+++ b/test/sanity/code-smell/update-bundled.py
@@ -49,7 +49,6 @@ def get_bundled_libs(paths):
for filename in fnmatch.filter(paths, 'lib/ansible/compat/*/__init__.py'):
bundled_libs.add(filename)
- bundled_libs.add('lib/ansible/module_utils/compat/selectors.py')
bundled_libs.add('lib/ansible/module_utils/distro/__init__.py')
bundled_libs.add('lib/ansible/module_utils/six/__init__.py')
# backports.ssl_match_hostname should be moved to its own file in the future
diff --git a/test/sanity/code-smell/update-bundled.requirements.txt b/test/sanity/code-smell/update-bundled.requirements.txt
index 53f1e43..76bf9c5 100644
--- a/test/sanity/code-smell/update-bundled.requirements.txt
+++ b/test/sanity/code-smell/update-bundled.requirements.txt
@@ -1,2 +1,2 @@
# edit "update-bundled.requirements.in" and generate with: hacking/update-sanity-requirements.py --test update-bundled
-packaging==23.2
+packaging==24.0
diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt
index c683fbe..89fcd02 100644
--- a/test/sanity/ignore.txt
+++ b/test/sanity/ignore.txt
@@ -37,7 +37,6 @@ lib/ansible/modules/git.py use-argspec-type-path
lib/ansible/modules/git.py validate-modules:doc-required-mismatch
lib/ansible/modules/lineinfile.py validate-modules:doc-choices-do-not-match-spec
lib/ansible/modules/lineinfile.py validate-modules:doc-default-does-not-match-spec
-lib/ansible/modules/lineinfile.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/package_facts.py validate-modules:doc-choices-do-not-match-spec
lib/ansible/modules/replace.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/replace.py pylint:used-before-assignment # false positive detection by pylint
@@ -48,24 +47,17 @@ lib/ansible/modules/systemd_service.py validate-modules:parameter-invalid
lib/ansible/modules/uri.py validate-modules:doc-required-mismatch
lib/ansible/modules/user.py validate-modules:doc-default-does-not-match-spec
lib/ansible/modules/user.py validate-modules:use-run-command-not-popen
-lib/ansible/modules/yum.py validate-modules:parameter-invalid
+lib/ansible/module_utils/basic.py no-get-exception # only referenced in deprecation code
lib/ansible/module_utils/basic.py pylint:unused-import # deferring resolution to allow enabling the rule now
-lib/ansible/module_utils/compat/_selectors2.py future-import-boilerplate # ignore bundled
-lib/ansible/module_utils/compat/_selectors2.py metaclass-boilerplate # ignore bundled
-lib/ansible/module_utils/compat/selinux.py import-2.7!skip # pass/fail depends on presence of libselinux.so
-lib/ansible/module_utils/compat/selinux.py import-3.6!skip # pass/fail depends on presence of libselinux.so
lib/ansible/module_utils/compat/selinux.py import-3.7!skip # pass/fail depends on presence of libselinux.so
lib/ansible/module_utils/compat/selinux.py import-3.8!skip # pass/fail depends on presence of libselinux.so
lib/ansible/module_utils/compat/selinux.py import-3.9!skip # pass/fail depends on presence of libselinux.so
lib/ansible/module_utils/compat/selinux.py import-3.10!skip # pass/fail depends on presence of libselinux.so
lib/ansible/module_utils/compat/selinux.py import-3.11!skip # pass/fail depends on presence of libselinux.so
lib/ansible/module_utils/compat/selinux.py import-3.12!skip # pass/fail depends on presence of libselinux.so
-lib/ansible/module_utils/distro/_distro.py future-import-boilerplate # ignore bundled
-lib/ansible/module_utils/distro/_distro.py metaclass-boilerplate # ignore bundled
+lib/ansible/module_utils/compat/selinux.py pylint:unidiomatic-typecheck
lib/ansible/module_utils/distro/_distro.py no-assert
lib/ansible/module_utils/distro/_distro.py pep8!skip # bundled code we don't want to modify
-lib/ansible/module_utils/distro/_distro.py pylint:undefined-variable # ignore bundled
-lib/ansible/module_utils/distro/_distro.py pylint:using-constant-test # bundled code we don't want to modify
lib/ansible/module_utils/distro/__init__.py empty-init # breaks namespacing, bundled, do not override
lib/ansible/module_utils/facts/__init__.py empty-init # breaks namespacing, deprecate and eventually remove
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.ArgvParser.psm1 pslint:PSUseApprovedVerbs
@@ -78,14 +70,9 @@ lib/ansible/module_utils/powershell/Ansible.ModuleUtils.Legacy.psm1 pslint:PSUse
lib/ansible/module_utils/powershell/Ansible.ModuleUtils.LinkUtil.psm1 pslint:PSUseApprovedVerbs
lib/ansible/module_utils/pycompat24.py no-get-exception
lib/ansible/module_utils/six/__init__.py empty-init # breaks namespacing, bundled, do not override
-lib/ansible/module_utils/six/__init__.py future-import-boilerplate # ignore bundled
-lib/ansible/module_utils/six/__init__.py metaclass-boilerplate # ignore bundled
-lib/ansible/module_utils/six/__init__.py no-basestring
-lib/ansible/module_utils/six/__init__.py no-dict-iteritems
-lib/ansible/module_utils/six/__init__.py no-dict-iterkeys
-lib/ansible/module_utils/six/__init__.py no-dict-itervalues
lib/ansible/module_utils/six/__init__.py pylint:self-assigning-variable
lib/ansible/module_utils/six/__init__.py pylint:trailing-comma-tuple
+lib/ansible/module_utils/six/__init__.py pylint:unidiomatic-typecheck
lib/ansible/module_utils/six/__init__.py replace-urlopen
lib/ansible/module_utils/urls.py replace-urlopen
lib/ansible/parsing/yaml/objects.py pylint:arguments-renamed
@@ -112,6 +99,8 @@ 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
@@ -122,16 +111,19 @@ test/integration/targets/incidental_win_reboot/templates/post_reboot.ps1 pslint!
test/integration/targets/json_cleanup/library/bad_json shebang
test/integration/targets/lookup_csvfile/files/crlf.csv line-endings
test/integration/targets/lookup_ini/lookup-8859-15.ini no-smart-quotes
+test/integration/targets/lookup_ini/lookup-8859-15.ini no-unwanted-characters
test/integration/targets/module_precedence/lib_with_extension/a.ini shebang
test/integration/targets/module_precedence/lib_with_extension/ping.ini shebang
test/integration/targets/module_precedence/roles_with_extension/foo/library/a.ini shebang
test/integration/targets/module_precedence/roles_with_extension/foo/library/ping.ini shebang
-test/integration/targets/module_utils/library/test.py future-import-boilerplate # allow testing of Python 2.x implicit relative imports
test/integration/targets/old_style_modules_posix/library/helloworld.sh shebang
test/integration/targets/template/files/encoding_1252_utf-8.expected no-smart-quotes
+test/integration/targets/template/files/encoding_1252_utf-8.expected no-unwanted-characters
test/integration/targets/template/files/encoding_1252_windows-1252.expected no-smart-quotes
+test/integration/targets/template/files/encoding_1252_windows-1252.expected no-unwanted-characters
test/integration/targets/template/files/foo.dos.txt line-endings
test/integration/targets/template/templates/encoding_1252.j2 no-smart-quotes
+test/integration/targets/template/templates/encoding_1252.j2 no-unwanted-characters
test/integration/targets/unicode/unicode.yml no-smart-quotes
test/integration/targets/windows-minimal/library/win_ping_syntax_error.ps1 pslint!skip
test/integration/targets/win_exec_wrapper/library/test_fail.ps1 pslint:PSCustomUseLiteralPath
@@ -144,7 +136,6 @@ test/integration/targets/win_script/files/test_script_removes_file.ps1 pslint:PS
test/integration/targets/win_script/files/test_script_with_args.ps1 pslint:PSAvoidUsingWriteHost # Keep
test/integration/targets/win_script/files/test_script_with_splatting.ps1 pslint:PSAvoidUsingWriteHost # Keep
test/lib/ansible_test/_data/requirements/sanity.pslint.ps1 pslint:PSCustomUseLiteralPath # Uses wildcards on purpose
-test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/compat/ipaddress.py no-unicode-literals
test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py pylint:arguments-renamed
test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/cliconf/vyos.py pylint:arguments-renamed
test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/module_utils/WebRequest.psm1 pslint!skip
@@ -179,6 +170,7 @@ test/units/utils/collection_loader/fixtures/collections_masked/ansible_collectio
test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/__init__.py empty-init # testing that collections don't need inits
test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/testcoll/__init__.py empty-init # testing that collections don't need inits
test/units/utils/collection_loader/test_collection_loader.py pylint:undefined-variable # magic runtime local var splatting
+test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/module_utils/my_util.py boilerplate # test requires missing boilerplate
.github/CONTRIBUTING.md pymarkdown:line-length
hacking/backport/README.md pymarkdown:no-bare-urls
hacking/ticket_stubs/bug_internal_api.md pymarkdown:no-bare-urls
@@ -202,3 +194,5 @@ README.md pymarkdown:line-length
test/integration/targets/ansible-vault/invalid_format/README.md pymarkdown:no-bare-urls
test/support/README.md pymarkdown:no-bare-urls
test/units/cli/test_data/role_skeleton/README.md pymarkdown:line-length
+test/integration/targets/find/files/hello_world.gbk no-smart-quotes
+test/integration/targets/find/files/hello_world.gbk no-unwanted-characters
diff --git a/test/support/integration/plugins/filter/json_query.py b/test/support/integration/plugins/filter/json_query.py
deleted file mode 100644
index d1da71b..0000000
--- a/test/support/integration/plugins/filter/json_query.py
+++ /dev/null
@@ -1,53 +0,0 @@
-# (c) 2015, Filipe Niero Felisbino <filipenf@gmail.com>
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-from ansible.errors import AnsibleError, AnsibleFilterError
-
-try:
- import jmespath
- HAS_LIB = True
-except ImportError:
- HAS_LIB = False
-
-
-def json_query(data, expr):
- '''Query data using jmespath query language ( http://jmespath.org ). Example:
- - debug: msg="{{ instance | json_query(tagged_instances[*].block_device_mapping.*.volume_id') }}"
- '''
- if not HAS_LIB:
- raise AnsibleError('You need to install "jmespath" prior to running '
- 'json_query filter')
-
- try:
- return jmespath.search(expr, data)
- except jmespath.exceptions.JMESPathError as e:
- raise AnsibleFilterError('JMESPathError in json_query filter plugin:\n%s' % e)
- except Exception as e:
- # For older jmespath, we can get ValueError and TypeError without much info.
- raise AnsibleFilterError('Error in jmespath.search in json_query filter plugin:\n%s' % e)
-
-
-class FilterModule(object):
- ''' Query filter '''
-
- def filters(self):
- return {
- 'json_query': json_query
- }
diff --git a/test/support/integration/plugins/modules/pkgng.py b/test/support/integration/plugins/modules/pkgng.py
index 1136347..85c5636 100644
--- a/test/support/integration/plugins/modules/pkgng.py
+++ b/test/support/integration/plugins/modules/pkgng.py
@@ -9,8 +9,7 @@
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
diff --git a/test/support/integration/plugins/modules/sefcontext.py b/test/support/integration/plugins/modules/sefcontext.py
deleted file mode 100644
index 946ae88..0000000
--- a/test/support/integration/plugins/modules/sefcontext.py
+++ /dev/null
@@ -1,308 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-# Copyright: (c) 2016, Dag Wieers (@dagwieers) <dag@wieers.com>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
-
-ANSIBLE_METADATA = {'metadata_version': '1.1',
- 'status': ['preview'],
- 'supported_by': 'community'}
-
-DOCUMENTATION = r'''
----
-module: sefcontext
-short_description: Manages SELinux file context mapping definitions
-description:
-- Manages SELinux file context mapping definitions.
-- Similar to the C(semanage fcontext) command.
-version_added: '2.2'
-options:
- target:
- description:
- - Target path (expression).
- type: str
- required: yes
- aliases: [ path ]
- ftype:
- description:
- - The file type that should have SELinux contexts applied.
- - "The following file type options are available:"
- - C(a) for all files,
- - C(b) for block devices,
- - C(c) for character devices,
- - C(d) for directories,
- - C(f) for regular files,
- - C(l) for symbolic links,
- - C(p) for named pipes,
- - C(s) for socket files.
- type: str
- choices: [ a, b, c, d, f, l, p, s ]
- default: a
- setype:
- description:
- - SELinux type for the specified target.
- type: str
- required: yes
- seuser:
- description:
- - SELinux user for the specified target.
- type: str
- selevel:
- description:
- - SELinux range for the specified target.
- type: str
- aliases: [ serange ]
- state:
- description:
- - Whether the SELinux file context must be C(absent) or C(present).
- type: str
- choices: [ absent, present ]
- default: present
- reload:
- description:
- - Reload SELinux policy after commit.
- - Note that this does not apply SELinux file contexts to existing files.
- type: bool
- default: yes
- ignore_selinux_state:
- description:
- - Useful for scenarios (chrooted environment) that you can't get the real SELinux state.
- type: bool
- default: no
- version_added: '2.8'
-notes:
-- The changes are persistent across reboots.
-- The M(sefcontext) module does not modify existing files to the new
- SELinux context(s), so it is advisable to first create the SELinux
- file contexts before creating files, or run C(restorecon) manually
- for the existing files that require the new SELinux file contexts.
-- Not applying SELinux fcontexts to existing files is a deliberate
- decision as it would be unclear what reported changes would entail
- to, and there's no guarantee that applying SELinux fcontext does
- not pick up other unrelated prior changes.
-requirements:
-- libselinux-python
-- policycoreutils-python
-author:
-- Dag Wieers (@dagwieers)
-'''
-
-EXAMPLES = r'''
-- name: Allow apache to modify files in /srv/git_repos
- sefcontext:
- target: '/srv/git_repos(/.*)?'
- setype: httpd_git_rw_content_t
- state: present
-
-- name: Apply new SELinux file context to filesystem
- command: restorecon -irv /srv/git_repos
-'''
-
-RETURN = r'''
-# Default return values
-'''
-
-import traceback
-
-from ansible.module_utils.basic import AnsibleModule, missing_required_lib
-from ansible.module_utils.common.respawn import has_respawned, probe_interpreters_for_module, respawn_module
-from ansible.module_utils.common.text.converters import to_native
-
-SELINUX_IMP_ERR = None
-try:
- import selinux
- HAVE_SELINUX = True
-except ImportError:
- SELINUX_IMP_ERR = traceback.format_exc()
- HAVE_SELINUX = False
-
-SEOBJECT_IMP_ERR = None
-try:
- import seobject
- HAVE_SEOBJECT = True
-except ImportError:
- SEOBJECT_IMP_ERR = traceback.format_exc()
- HAVE_SEOBJECT = False
-
-# Add missing entries (backward compatible)
-if HAVE_SEOBJECT:
- seobject.file_types.update(
- a=seobject.SEMANAGE_FCONTEXT_ALL,
- b=seobject.SEMANAGE_FCONTEXT_BLOCK,
- c=seobject.SEMANAGE_FCONTEXT_CHAR,
- d=seobject.SEMANAGE_FCONTEXT_DIR,
- f=seobject.SEMANAGE_FCONTEXT_REG,
- l=seobject.SEMANAGE_FCONTEXT_LINK,
- p=seobject.SEMANAGE_FCONTEXT_PIPE,
- s=seobject.SEMANAGE_FCONTEXT_SOCK,
- )
-
-# Make backward compatible
-option_to_file_type_str = dict(
- a='all files',
- b='block device',
- c='character device',
- d='directory',
- f='regular file',
- l='symbolic link',
- p='named pipe',
- s='socket',
-)
-
-
-def get_runtime_status(ignore_selinux_state=False):
- return True if ignore_selinux_state is True else selinux.is_selinux_enabled()
-
-
-def semanage_fcontext_exists(sefcontext, target, ftype):
- ''' Get the SELinux file context mapping definition from policy. Return None if it does not exist. '''
-
- # Beware that records comprise of a string representation of the file_type
- record = (target, option_to_file_type_str[ftype])
- records = sefcontext.get_all()
- try:
- return records[record]
- except KeyError:
- return None
-
-
-def semanage_fcontext_modify(module, result, target, ftype, setype, do_reload, serange, seuser, sestore=''):
- ''' Add or modify SELinux file context mapping definition to the policy. '''
-
- changed = False
- prepared_diff = ''
-
- try:
- sefcontext = seobject.fcontextRecords(sestore)
- sefcontext.set_reload(do_reload)
- exists = semanage_fcontext_exists(sefcontext, target, ftype)
- if exists:
- # Modify existing entry
- orig_seuser, orig_serole, orig_setype, orig_serange = exists
-
- if seuser is None:
- seuser = orig_seuser
- if serange is None:
- serange = orig_serange
-
- if setype != orig_setype or seuser != orig_seuser or serange != orig_serange:
- if not module.check_mode:
- sefcontext.modify(target, setype, ftype, serange, seuser)
- changed = True
-
- if module._diff:
- prepared_diff += '# Change to semanage file context mappings\n'
- prepared_diff += '-%s %s %s:%s:%s:%s\n' % (target, ftype, orig_seuser, orig_serole, orig_setype, orig_serange)
- prepared_diff += '+%s %s %s:%s:%s:%s\n' % (target, ftype, seuser, orig_serole, setype, serange)
- else:
- # Add missing entry
- if seuser is None:
- seuser = 'system_u'
- if serange is None:
- serange = 's0'
-
- if not module.check_mode:
- sefcontext.add(target, setype, ftype, serange, seuser)
- changed = True
-
- if module._diff:
- prepared_diff += '# Addition to semanage file context mappings\n'
- prepared_diff += '+%s %s %s:%s:%s:%s\n' % (target, ftype, seuser, 'object_r', setype, serange)
-
- except Exception as e:
- module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, to_native(e)))
-
- if module._diff and prepared_diff:
- result['diff'] = dict(prepared=prepared_diff)
-
- module.exit_json(changed=changed, seuser=seuser, serange=serange, **result)
-
-
-def semanage_fcontext_delete(module, result, target, ftype, do_reload, sestore=''):
- ''' Delete SELinux file context mapping definition from the policy. '''
-
- changed = False
- prepared_diff = ''
-
- try:
- sefcontext = seobject.fcontextRecords(sestore)
- sefcontext.set_reload(do_reload)
- exists = semanage_fcontext_exists(sefcontext, target, ftype)
- if exists:
- # Remove existing entry
- orig_seuser, orig_serole, orig_setype, orig_serange = exists
-
- if not module.check_mode:
- sefcontext.delete(target, ftype)
- changed = True
-
- if module._diff:
- prepared_diff += '# Deletion to semanage file context mappings\n'
- prepared_diff += '-%s %s %s:%s:%s:%s\n' % (target, ftype, exists[0], exists[1], exists[2], exists[3])
-
- except Exception as e:
- module.fail_json(msg="%s: %s\n" % (e.__class__.__name__, to_native(e)))
-
- if module._diff and prepared_diff:
- result['diff'] = dict(prepared=prepared_diff)
-
- module.exit_json(changed=changed, **result)
-
-
-def main():
- module = AnsibleModule(
- argument_spec=dict(
- ignore_selinux_state=dict(type='bool', default=False),
- target=dict(type='str', required=True, aliases=['path']),
- ftype=dict(type='str', default='a', choices=option_to_file_type_str.keys()),
- setype=dict(type='str', required=True),
- seuser=dict(type='str'),
- selevel=dict(type='str', aliases=['serange']),
- state=dict(type='str', default='present', choices=['absent', 'present']),
- reload=dict(type='bool', default=True),
- ),
- supports_check_mode=True,
- )
-
- if not HAVE_SELINUX or not HAVE_SEOBJECT and not has_respawned():
- system_interpreters = [
- '/usr/libexec/platform-python',
- '/usr/bin/python3',
- '/usr/bin/python2',
- ]
- # policycoreutils-python depends on libselinux-python
- interpreter = probe_interpreters_for_module(system_interpreters, 'seobject')
- if interpreter:
- respawn_module(interpreter)
-
- if not HAVE_SELINUX or not HAVE_SEOBJECT:
- module.fail_json(msg=missing_required_lib("policycoreutils-python(3)"), exception=SELINUX_IMP_ERR)
-
- ignore_selinux_state = module.params['ignore_selinux_state']
-
- if not get_runtime_status(ignore_selinux_state):
- module.fail_json(msg="SELinux is disabled on this host.")
-
- target = module.params['target']
- ftype = module.params['ftype']
- setype = module.params['setype']
- seuser = module.params['seuser']
- serange = module.params['selevel']
- state = module.params['state']
- do_reload = module.params['reload']
-
- result = dict(target=target, ftype=ftype, setype=setype, state=state)
-
- if state == 'present':
- semanage_fcontext_modify(module, result, target, ftype, setype, do_reload, serange, seuser)
- elif state == 'absent':
- semanage_fcontext_delete(module, result, target, ftype, do_reload)
- else:
- module.fail_json(msg='Invalid value of argument "state": {0}'.format(state))
-
-
-if __name__ == '__main__':
- main()
diff --git a/test/support/integration/plugins/modules/timezone.py b/test/support/integration/plugins/modules/timezone.py
index dd37483..9da4038 100644
--- a/test/support/integration/plugins/modules/timezone.py
+++ b/test/support/integration/plugins/modules/timezone.py
@@ -4,8 +4,7 @@
# Copyright: (c) 2016, Shinichi TAMURA (@tmshn)
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
diff --git a/test/support/integration/plugins/modules/zypper.py b/test/support/integration/plugins/modules/zypper.py
deleted file mode 100644
index cd67b60..0000000
--- a/test/support/integration/plugins/modules/zypper.py
+++ /dev/null
@@ -1,539 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-# (c) 2013, Patrick Callahan <pmc@patrickcallahan.com>
-# based on
-# openbsd_pkg
-# (c) 2013
-# Patrik Lundin <patrik.lundin.swe@gmail.com>
-#
-# yum
-# (c) 2012, Red Hat, Inc
-# Written by Seth Vidal <skvidal at fedoraproject.org>
-#
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
-
-
-ANSIBLE_METADATA = {'metadata_version': '1.1',
- 'status': ['preview'],
- 'supported_by': 'community'}
-
-
-DOCUMENTATION = '''
----
-module: zypper
-author:
- - "Patrick Callahan (@dirtyharrycallahan)"
- - "Alexander Gubin (@alxgu)"
- - "Thomas O'Donnell (@andytom)"
- - "Robin Roth (@robinro)"
- - "Andrii Radyk (@AnderEnder)"
-version_added: "1.2"
-short_description: Manage packages on SUSE and openSUSE
-description:
- - Manage packages on SUSE and openSUSE using the zypper and rpm tools.
-options:
- name:
- description:
- - Package name C(name) or package specifier or a list of either.
- - Can include a version like C(name=1.0), C(name>3.4) or C(name<=2.7). If a version is given, C(oldpackage) is implied and zypper is allowed to
- update the package within the version range given.
- - You can also pass a url or a local path to an rpm file.
- - When using state=latest, this can be '*', which updates all installed packages.
- required: true
- aliases: [ 'pkg' ]
- state:
- description:
- - C(present) will make sure the package is installed.
- C(latest) will make sure the latest version of the package is installed.
- C(absent) will make sure the specified package is not installed.
- C(dist-upgrade) will make sure the latest version of all installed packages from all enabled repositories is installed.
- - When using C(dist-upgrade), I(name) should be C('*').
- required: false
- choices: [ present, latest, absent, dist-upgrade ]
- default: "present"
- type:
- description:
- - The type of package to be operated on.
- required: false
- choices: [ package, patch, pattern, product, srcpackage, application ]
- default: "package"
- version_added: "2.0"
- extra_args_precommand:
- version_added: "2.6"
- required: false
- description:
- - Add additional global target options to C(zypper).
- - Options should be supplied in a single line as if given in the command line.
- disable_gpg_check:
- description:
- - Whether to disable to GPG signature checking of the package
- signature being installed. Has an effect only if state is
- I(present) or I(latest).
- required: false
- default: "no"
- type: bool
- disable_recommends:
- version_added: "1.8"
- description:
- - Corresponds to the C(--no-recommends) option for I(zypper). Default behavior (C(yes)) modifies zypper's default behavior; C(no) does
- install recommended packages.
- required: false
- default: "yes"
- type: bool
- force:
- version_added: "2.2"
- description:
- - Adds C(--force) option to I(zypper). Allows to downgrade packages and change vendor or architecture.
- required: false
- default: "no"
- type: bool
- force_resolution:
- version_added: "2.10"
- description:
- - Adds C(--force-resolution) option to I(zypper). Allows to (un)install packages with conflicting requirements (resolver will choose a solution).
- required: false
- default: "no"
- type: bool
- update_cache:
- version_added: "2.2"
- description:
- - Run the equivalent of C(zypper refresh) before the operation. Disabled in check mode.
- required: false
- default: "no"
- type: bool
- aliases: [ "refresh" ]
- oldpackage:
- version_added: "2.2"
- description:
- - Adds C(--oldpackage) option to I(zypper). Allows to downgrade packages with less side-effects than force. This is implied as soon as a
- version is specified as part of the package name.
- required: false
- default: "no"
- type: bool
- extra_args:
- version_added: "2.4"
- required: false
- description:
- - Add additional options to C(zypper) command.
- - Options should be supplied in a single line as if given in the command line.
-notes:
- - When used with a `loop:` each package will be processed individually,
- it is much more efficient to pass the list directly to the `name` option.
-# informational: requirements for nodes
-requirements:
- - "zypper >= 1.0 # included in openSUSE >= 11.1 or SUSE Linux Enterprise Server/Desktop >= 11.0"
- - python-xml
- - rpm
-'''
-
-EXAMPLES = '''
-# Install "nmap"
-- zypper:
- name: nmap
- state: present
-
-# Install apache2 with recommended packages
-- zypper:
- name: apache2
- state: present
- disable_recommends: no
-
-# Apply a given patch
-- zypper:
- name: openSUSE-2016-128
- state: present
- type: patch
-
-# Remove the "nmap" package
-- zypper:
- name: nmap
- state: absent
-
-# Install the nginx rpm from a remote repo
-- zypper:
- name: 'http://nginx.org/packages/sles/12/x86_64/RPMS/nginx-1.8.0-1.sles12.ngx.x86_64.rpm'
- state: present
-
-# Install local rpm file
-- zypper:
- name: /tmp/fancy-software.rpm
- state: present
-
-# Update all packages
-- zypper:
- name: '*'
- state: latest
-
-# Apply all available patches
-- zypper:
- name: '*'
- state: latest
- type: patch
-
-# Perform a dist-upgrade with additional arguments
-- zypper:
- name: '*'
- state: dist-upgrade
- extra_args: '--no-allow-vendor-change --allow-arch-change'
-
-# Refresh repositories and update package "openssl"
-- zypper:
- name: openssl
- state: present
- update_cache: yes
-
-# Install specific version (possible comparisons: <, >, <=, >=, =)
-- zypper:
- name: 'docker>=1.10'
- state: present
-
-# Wait 20 seconds to acquire the lock before failing
-- zypper:
- name: mosh
- state: present
- environment:
- ZYPP_LOCK_TIMEOUT: 20
-'''
-
-import xml
-import re
-from xml.dom.minidom import parseString as parseXML
-from ansible.module_utils.common.text.converters import to_native
-
-# import module snippets
-from ansible.module_utils.basic import AnsibleModule
-
-
-class Package:
- def __init__(self, name, prefix, version):
- self.name = name
- self.prefix = prefix
- self.version = version
- self.shouldinstall = (prefix == '+')
-
- def __str__(self):
- return self.prefix + self.name + self.version
-
-
-def split_name_version(name):
- """splits of the package name and desired version
-
- example formats:
- - docker>=1.10
- - apache=2.4
-
- Allowed version specifiers: <, >, <=, >=, =
- Allowed version format: [0-9.-]*
-
- Also allows a prefix indicating remove "-", "~" or install "+"
- """
-
- prefix = ''
- if name[0] in ['-', '~', '+']:
- prefix = name[0]
- name = name[1:]
- if prefix == '~':
- prefix = '-'
-
- version_check = re.compile('^(.*?)((?:<|>|<=|>=|=)[0-9.-]*)?$')
- try:
- reres = version_check.match(name)
- name, version = reres.groups()
- if version is None:
- version = ''
- return prefix, name, version
- except Exception:
- return prefix, name, ''
-
-
-def get_want_state(names, remove=False):
- packages = []
- urls = []
- for name in names:
- if '://' in name or name.endswith('.rpm'):
- urls.append(name)
- else:
- prefix, pname, version = split_name_version(name)
- if prefix not in ['-', '+']:
- if remove:
- prefix = '-'
- else:
- prefix = '+'
- packages.append(Package(pname, prefix, version))
- return packages, urls
-
-
-def get_installed_state(m, packages):
- "get installed state of packages"
-
- cmd = get_cmd(m, 'search')
- cmd.extend(['--match-exact', '--details', '--installed-only'])
- cmd.extend([p.name for p in packages])
- return parse_zypper_xml(m, cmd, fail_not_found=False)[0]
-
-
-def parse_zypper_xml(m, cmd, fail_not_found=True, packages=None):
- rc, stdout, stderr = m.run_command(cmd, check_rc=False)
-
- try:
- dom = parseXML(stdout)
- except xml.parsers.expat.ExpatError as exc:
- m.fail_json(msg="Failed to parse zypper xml output: %s" % to_native(exc),
- rc=rc, stdout=stdout, stderr=stderr, cmd=cmd)
-
- if rc == 104:
- # exit code 104 is ZYPPER_EXIT_INF_CAP_NOT_FOUND (no packages found)
- if fail_not_found:
- errmsg = dom.getElementsByTagName('message')[-1].childNodes[0].data
- m.fail_json(msg=errmsg, rc=rc, stdout=stdout, stderr=stderr, cmd=cmd)
- else:
- return {}, rc, stdout, stderr
- elif rc in [0, 106, 103]:
- # zypper exit codes
- # 0: success
- # 106: signature verification failed
- # 103: zypper was upgraded, run same command again
- if packages is None:
- firstrun = True
- packages = {}
- solvable_list = dom.getElementsByTagName('solvable')
- for solvable in solvable_list:
- name = solvable.getAttribute('name')
- packages[name] = {}
- packages[name]['version'] = solvable.getAttribute('edition')
- packages[name]['oldversion'] = solvable.getAttribute('edition-old')
- status = solvable.getAttribute('status')
- packages[name]['installed'] = status == "installed"
- packages[name]['group'] = solvable.parentNode.nodeName
- if rc == 103 and firstrun:
- # if this was the first run and it failed with 103
- # run zypper again with the same command to complete update
- return parse_zypper_xml(m, cmd, fail_not_found=fail_not_found, packages=packages)
-
- return packages, rc, stdout, stderr
- m.fail_json(msg='Zypper run command failed with return code %s.' % rc, rc=rc, stdout=stdout, stderr=stderr, cmd=cmd)
-
-
-def get_cmd(m, subcommand):
- "puts together the basic zypper command arguments with those passed to the module"
- is_install = subcommand in ['install', 'update', 'patch', 'dist-upgrade']
- is_refresh = subcommand == 'refresh'
- cmd = ['/usr/bin/zypper', '--quiet', '--non-interactive', '--xmlout']
- if m.params['extra_args_precommand']:
- args_list = m.params['extra_args_precommand'].split()
- cmd.extend(args_list)
- # add global options before zypper command
- if (is_install or is_refresh) and m.params['disable_gpg_check']:
- cmd.append('--no-gpg-checks')
-
- if subcommand == 'search':
- cmd.append('--disable-repositories')
-
- cmd.append(subcommand)
- if subcommand not in ['patch', 'dist-upgrade'] and not is_refresh:
- cmd.extend(['--type', m.params['type']])
- if m.check_mode and subcommand != 'search':
- cmd.append('--dry-run')
- if is_install:
- cmd.append('--auto-agree-with-licenses')
- if m.params['disable_recommends']:
- cmd.append('--no-recommends')
- if m.params['force']:
- cmd.append('--force')
- if m.params['force_resolution']:
- cmd.append('--force-resolution')
- if m.params['oldpackage']:
- cmd.append('--oldpackage')
- if m.params['extra_args']:
- args_list = m.params['extra_args'].split(' ')
- cmd.extend(args_list)
-
- return cmd
-
-
-def set_diff(m, retvals, result):
- # TODO: if there is only one package, set before/after to version numbers
- packages = {'installed': [], 'removed': [], 'upgraded': []}
- if result:
- for p in result:
- group = result[p]['group']
- if group == 'to-upgrade':
- versions = ' (' + result[p]['oldversion'] + ' => ' + result[p]['version'] + ')'
- packages['upgraded'].append(p + versions)
- elif group == 'to-install':
- packages['installed'].append(p)
- elif group == 'to-remove':
- packages['removed'].append(p)
-
- output = ''
- for state in packages:
- if packages[state]:
- output += state + ': ' + ', '.join(packages[state]) + '\n'
- if 'diff' not in retvals:
- retvals['diff'] = {}
- if 'prepared' not in retvals['diff']:
- retvals['diff']['prepared'] = output
- else:
- retvals['diff']['prepared'] += '\n' + output
-
-
-def package_present(m, name, want_latest):
- "install and update (if want_latest) the packages in name_install, while removing the packages in name_remove"
- retvals = {'rc': 0, 'stdout': '', 'stderr': ''}
- packages, urls = get_want_state(name)
-
- # add oldpackage flag when a version is given to allow downgrades
- if any(p.version for p in packages):
- m.params['oldpackage'] = True
-
- if not want_latest:
- # for state=present: filter out already installed packages
- # if a version is given leave the package in to let zypper handle the version
- # resolution
- packageswithoutversion = [p for p in packages if not p.version]
- prerun_state = get_installed_state(m, packageswithoutversion)
- # generate lists of packages to install or remove
- packages = [p for p in packages if p.shouldinstall != (p.name in prerun_state)]
-
- if not packages and not urls:
- # nothing to install/remove and nothing to update
- return None, retvals
-
- # zypper install also updates packages
- cmd = get_cmd(m, 'install')
- cmd.append('--')
- cmd.extend(urls)
- # pass packages to zypper
- # allow for + or - prefixes in install/remove lists
- # also add version specifier if given
- # do this in one zypper run to allow for dependency-resolution
- # for example "-exim postfix" runs without removing packages depending on mailserver
- cmd.extend([str(p) for p in packages])
-
- retvals['cmd'] = cmd
- result, retvals['rc'], retvals['stdout'], retvals['stderr'] = parse_zypper_xml(m, cmd)
-
- return result, retvals
-
-
-def package_update_all(m):
- "run update or patch on all available packages"
-
- retvals = {'rc': 0, 'stdout': '', 'stderr': ''}
- if m.params['type'] == 'patch':
- cmdname = 'patch'
- elif m.params['state'] == 'dist-upgrade':
- cmdname = 'dist-upgrade'
- else:
- cmdname = 'update'
-
- cmd = get_cmd(m, cmdname)
- retvals['cmd'] = cmd
- result, retvals['rc'], retvals['stdout'], retvals['stderr'] = parse_zypper_xml(m, cmd)
- return result, retvals
-
-
-def package_absent(m, name):
- "remove the packages in name"
- retvals = {'rc': 0, 'stdout': '', 'stderr': ''}
- # Get package state
- packages, urls = get_want_state(name, remove=True)
- if any(p.prefix == '+' for p in packages):
- m.fail_json(msg="Can not combine '+' prefix with state=remove/absent.")
- if urls:
- m.fail_json(msg="Can not remove via URL.")
- if m.params['type'] == 'patch':
- m.fail_json(msg="Can not remove patches.")
- prerun_state = get_installed_state(m, packages)
- packages = [p for p in packages if p.name in prerun_state]
-
- if not packages:
- return None, retvals
-
- cmd = get_cmd(m, 'remove')
- cmd.extend([p.name + p.version for p in packages])
-
- retvals['cmd'] = cmd
- result, retvals['rc'], retvals['stdout'], retvals['stderr'] = parse_zypper_xml(m, cmd)
- return result, retvals
-
-
-def repo_refresh(m):
- "update the repositories"
- retvals = {'rc': 0, 'stdout': '', 'stderr': ''}
-
- cmd = get_cmd(m, 'refresh')
-
- retvals['cmd'] = cmd
- result, retvals['rc'], retvals['stdout'], retvals['stderr'] = parse_zypper_xml(m, cmd)
-
- return retvals
-
-# ===========================================
-# Main control flow
-
-
-def main():
- module = AnsibleModule(
- argument_spec=dict(
- name=dict(required=True, aliases=['pkg'], type='list'),
- state=dict(required=False, default='present', choices=['absent', 'installed', 'latest', 'present', 'removed', 'dist-upgrade']),
- type=dict(required=False, default='package', choices=['package', 'patch', 'pattern', 'product', 'srcpackage', 'application']),
- extra_args_precommand=dict(required=False, default=None),
- disable_gpg_check=dict(required=False, default='no', type='bool'),
- disable_recommends=dict(required=False, default='yes', type='bool'),
- force=dict(required=False, default='no', type='bool'),
- force_resolution=dict(required=False, default='no', type='bool'),
- update_cache=dict(required=False, aliases=['refresh'], default='no', type='bool'),
- oldpackage=dict(required=False, default='no', type='bool'),
- extra_args=dict(required=False, default=None),
- ),
- supports_check_mode=True
- )
-
- name = module.params['name']
- state = module.params['state']
- update_cache = module.params['update_cache']
-
- # remove empty strings from package list
- name = list(filter(None, name))
-
- # Refresh repositories
- if update_cache and not module.check_mode:
- retvals = repo_refresh(module)
-
- if retvals['rc'] != 0:
- module.fail_json(msg="Zypper refresh run failed.", **retvals)
-
- # Perform requested action
- if name == ['*'] and state in ['latest', 'dist-upgrade']:
- packages_changed, retvals = package_update_all(module)
- elif name != ['*'] and state == 'dist-upgrade':
- module.fail_json(msg="Can not dist-upgrade specific packages.")
- else:
- if state in ['absent', 'removed']:
- packages_changed, retvals = package_absent(module, name)
- elif state in ['installed', 'present', 'latest']:
- packages_changed, retvals = package_present(module, name, state == 'latest')
-
- retvals['changed'] = retvals['rc'] == 0 and bool(packages_changed)
-
- if module._diff:
- set_diff(module, retvals, packages_changed)
-
- if retvals['rc'] != 0:
- module.fail_json(msg="Zypper run failed.", **retvals)
-
- if not retvals['changed']:
- del retvals['stdout']
- del retvals['stderr']
-
- module.exit_json(name=name, state=state, update_cache=update_cache, **retvals)
-
-
-if __name__ == "__main__":
- main()
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/cli_config.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/cli_config.py
index 089b339..1dbf890 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/cli_config.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/cli_config.py
@@ -16,9 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
from ansible_collections.ansible.netcommon.plugins.action.network import (
ActionModule as ActionNetworkModule,
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/net_get.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/net_get.py
index c6dbb2c..448b970 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/net_get.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/net_get.py
@@ -14,9 +14,8 @@
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import os
import re
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/net_put.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/net_put.py
index 6fa3b8d..38403c7 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/net_put.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/net_put.py
@@ -14,9 +14,8 @@
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import os
import uuid
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/network.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/network.py
index fbcc9c1..5c4c9fa 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/network.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/action/network.py
@@ -16,9 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import os
import time
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/connection/network_cli.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/connection/network_cli.py
index d0d977f..467c4b7 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/connection/network_cli.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/connection/network_cli.py
@@ -2,9 +2,8 @@
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
DOCUMENTATION = """
author:
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/connection/persistent.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/connection/persistent.py
index c7379a6..6866688 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/connection/persistent.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/connection/persistent.py
@@ -2,9 +2,8 @@
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
DOCUMENTATION = """author: Ansible Core Team
connection: persistent
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/doc_fragments/connection_persistent.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/doc_fragments/connection_persistent.py
index d572c30..506b559 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/doc_fragments/connection_persistent.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/doc_fragments/connection_persistent.py
@@ -1,9 +1,7 @@
# -*- coding: utf-8 -*-
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
class ModuleDocFragment(object):
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/compat/ipaddress.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/compat/ipaddress.py
index dc0a19f..312f1d6 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/compat/ipaddress.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/compat/ipaddress.py
@@ -60,7 +60,7 @@ and networks.
"""
-from __future__ import unicode_literals
+from __future__ import annotations
import itertools
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/cfg/base.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/cfg/base.py
index 68608d1..75f80aa 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/cfg/base.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/cfg/base.py
@@ -6,6 +6,7 @@
"""
The base class for all resource modules
"""
+from __future__ import annotations
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network import (
get_resource_connection,
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/config.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/config.py
index 6415040..d6f278a 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/config.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/config.py
@@ -25,6 +25,8 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
+from __future__ import annotations
+
import re
import hashlib
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/facts/facts.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/facts/facts.py
index 2afa650..0a484d0 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/facts/facts.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/facts/facts.py
@@ -7,6 +7,8 @@
The facts base class
this contains methods common to all facts subsets
"""
+from __future__ import annotations
+
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.network import (
get_resource_connection,
)
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/netconf.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/netconf.py
index 1857f7d..4979dac 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/netconf.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/netconf.py
@@ -25,6 +25,8 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
+from __future__ import annotations
+
import sys
from ansible.module_utils.common.text.converters import to_text, to_bytes
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/network.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/network.py
index 149b441..c1f1d7b 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/network.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/network.py
@@ -24,6 +24,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+from __future__ import annotations
import traceback
import json
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/parsing.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/parsing.py
index 2dd1de9..2e8e174 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/parsing.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/parsing.py
@@ -24,6 +24,7 @@
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+from __future__ import annotations
import re
import shlex
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/utils.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/utils.py
index 4095f59..0b594ad 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/utils.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/utils.py
@@ -27,6 +27,7 @@
#
# Networking tools for network modules only
+from __future__ import annotations
import re
import ast
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/modules/cli_config.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/modules/cli_config.py
index 9d07e85..ef6f102 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/modules/cli_config.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/modules/cli_config.py
@@ -4,9 +4,7 @@
# (c) 2018, Ansible by Red Hat, inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
ANSIBLE_METADATA = {
diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/plugin_utils/connection_base.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/plugin_utils/connection_base.py
index a38a775..29faa8b 100644
--- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/plugin_utils/connection_base.py
+++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/plugin_utils/connection_base.py
@@ -2,9 +2,8 @@
# (c) 2015 Toshio Kuratomi <tkuratomi@ansible.com>
# (c) 2017, Peter Sprygada <psprygad@redhat.com>
# (c) 2017 Ansible Project
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import os
diff --git a/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/action/ios.py b/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/action/ios.py
index e3605d0..be70895 100644
--- a/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/action/ios.py
+++ b/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/action/ios.py
@@ -16,9 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import sys
import copy
diff --git a/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py b/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py
index b9cb19d..1b5cb45 100644
--- a/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py
+++ b/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/cliconf/ios.py
@@ -16,9 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
DOCUMENTATION = """
---
diff --git a/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/doc_fragments/ios.py b/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/doc_fragments/ios.py
index ff22d27..1b4ede2 100644
--- a/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/doc_fragments/ios.py
+++ b/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/doc_fragments/ios.py
@@ -2,6 +2,7 @@
# Copyright: (c) 2015, Peter Sprygada <psprygada@ansible.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+from __future__ import annotations
class ModuleDocFragment(object):
diff --git a/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/module_utils/network/ios/ios.py b/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/module_utils/network/ios/ios.py
index c16d84c..a21e047 100644
--- a/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/module_utils/network/ios/ios.py
+++ b/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/module_utils/network/ios/ios.py
@@ -25,6 +25,8 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
+from __future__ import annotations
+
import json
from ansible.module_utils.common.text.converters import to_text
diff --git a/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/modules/ios_command.py b/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/modules/ios_command.py
index 0b3be2a..9486a03 100644
--- a/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/modules/ios_command.py
+++ b/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/modules/ios_command.py
@@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
+from __future__ import annotations
ANSIBLE_METADATA = {
"metadata_version": "1.1",
diff --git a/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/modules/ios_config.py b/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/modules/ios_config.py
index 5048bbb..f9b49a1 100644
--- a/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/modules/ios_config.py
+++ b/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/modules/ios_config.py
@@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
+from __future__ import annotations
ANSIBLE_METADATA = {
"metadata_version": "1.1",
diff --git a/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/terminal/ios.py b/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/terminal/ios.py
index 9716952..7194eb4 100644
--- a/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/terminal/ios.py
+++ b/test/support/network-integration/collections/ansible_collections/cisco/ios/plugins/terminal/ios.py
@@ -16,9 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import json
import re
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/action/vyos.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/action/vyos.py
index b86a0c4..7865916 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/action/vyos.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/action/vyos.py
@@ -16,9 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import sys
import copy
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/cliconf/vyos.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/cliconf/vyos.py
index 1f351dc..ca54c91 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/cliconf/vyos.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/cliconf/vyos.py
@@ -16,9 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
DOCUMENTATION = """
---
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/doc_fragments/vyos.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/doc_fragments/vyos.py
index 094963f..a7f8c12 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/doc_fragments/vyos.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/doc_fragments/vyos.py
@@ -2,6 +2,7 @@
# Copyright: (c) 2015, Peter Sprygada <psprygada@ansible.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+from __future__ import annotations
class ModuleDocFragment(object):
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/facts/facts.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/facts/facts.py
index 46fabaa..afe04ba 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/facts/facts.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/facts/facts.py
@@ -4,9 +4,7 @@
"""
The arg spec for the vyos facts module.
"""
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
class FactsArgs(object): # pylint: disable=R0903
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py
index a018cc0..51822ac 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/firewall_rules/firewall_rules.py
@@ -25,9 +25,7 @@
The arg spec for the vyos_firewall_rules module
"""
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
class Firewall_rulesArgs(object): # pylint: disable=R0903
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py
index 3542cb1..7bf0c22 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/interfaces/interfaces.py
@@ -23,9 +23,7 @@
The arg spec for the vyos_interfaces module
"""
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
class InterfacesArgs(object): # pylint: disable=R0903
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py
index 91434e4..9ce2af5 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/l3_interfaces/l3_interfaces.py
@@ -26,9 +26,7 @@ The arg spec for the vyos_l3_interfaces module
"""
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
class L3_interfacesArgs(object): # pylint: disable=R0903
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py
index 97c5d5a..b68513f 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lag_interfaces/lag_interfaces.py
@@ -23,9 +23,7 @@
"""
The arg spec for the vyos_lag_interfaces module
"""
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
class Lag_interfacesArgs(object): # pylint: disable=R0903
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py
index 84bbc00..d56ff21 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_global/lldp_global.py
@@ -23,9 +23,7 @@
"""
The arg spec for the vyos_lldp_global module
"""
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
class Lldp_globalArgs(object): # pylint: disable=R0903
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py
index 2976fc0..7a639fe 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/lldp_interfaces/lldp_interfaces.py
@@ -25,9 +25,7 @@
The arg spec for the vyos_lldp_interfaces module
"""
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
class Lldp_interfacesArgs(object): # pylint: disable=R0903
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py
index 8ecd955..191dc76 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/argspec/static_routes/static_routes.py
@@ -25,9 +25,7 @@
The arg spec for the vyos_static_routes module
"""
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
class Static_routesArgs(object): # pylint: disable=R0903
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py
index 377fec9..5b61427 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py
@@ -11,9 +11,7 @@ necessary to bring the current configuration to it's desired end-state is
created
"""
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/facts.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/facts.py
index 8f0a3bb..f174849 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/facts.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/facts.py
@@ -6,9 +6,8 @@ The facts class for vyos
this file validates each subset of facts and selectively
calls the appropriate facts gathering function
"""
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.facts.facts import (
FactsBase,
)
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py
index 971ea6f..6e583f6 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/firewall_rules/firewall_rules.py
@@ -9,9 +9,8 @@ It is in this file the configuration is collected from the device
for a given resource, parsed, and the facts tree is populated
based on the configuration.
"""
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
from re import findall, search, M
from copy import deepcopy
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py
index 4b24803..e3bb52c 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/interfaces/interfaces.py
@@ -10,9 +10,7 @@ for a given resource, parsed, and the facts tree is populated
based on the configuration.
"""
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
from re import findall, M
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py
index d1d62c2..944629c 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/l3_interfaces/l3_interfaces.py
@@ -10,9 +10,7 @@ for a given resource, parsed, and the facts tree is populated
based on the configuration.
"""
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
import re
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py
index 9201e5c..b26dfd1 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lag_interfaces/lag_interfaces.py
@@ -9,9 +9,8 @@ It is in this file the configuration is collected from the device
for a given resource, parsed, and the facts tree is populated
based on the configuration.
"""
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
from re import findall, search, M
from copy import deepcopy
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/legacy/base.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/legacy/base.py
index f6b343e..c5294b5 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/legacy/base.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/legacy/base.py
@@ -9,9 +9,8 @@ for a given resource, parsed, and the facts tree is populated
based on the configuration.
"""
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import platform
import re
from ansible_collections.vyos.vyos.plugins.module_utils.network.vyos.vyos import (
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py
index 3c7e2f9..10f239f 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_global/lldp_global.py
@@ -9,9 +9,8 @@ It is in this file the configuration is collected from the device
for a given resource, parsed, and the facts tree is populated
based on the configuration.
"""
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
from re import findall, M
from copy import deepcopy
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py
index dcfbc6e..d9d59b1 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/lldp_interfaces/lldp_interfaces.py
@@ -10,9 +10,7 @@ for a given resource, parsed, and the facts tree is populated
based on the configuration.
"""
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
from re import findall, search, M
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py
index 0004947..7ca7f20 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/facts/static_routes/static_routes.py
@@ -10,9 +10,8 @@ for a given resource, parsed, and the facts tree is populated
based on the configuration.
"""
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
from re import findall, search, M
from copy import deepcopy
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/utils/utils.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/utils/utils.py
index 402adfc..1a6a724 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/utils/utils.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/utils/utils.py
@@ -4,9 +4,8 @@
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# utils
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
from ansible.module_utils.six import iteritems
from ansible_collections.ansible.netcommon.plugins.module_utils.compat import (
ipaddress,
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/vyos.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/vyos.py
index 7e8b204..274a463 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/vyos.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/module_utils/network/vyos/vyos.py
@@ -25,6 +25,8 @@
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
+from __future__ import annotations
+
import json
from ansible.module_utils.common.text.converters import to_text
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_command.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_command.py
index 7f7c30c..ed90aea 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_command.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_command.py
@@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
+from __future__ import annotations
ANSIBLE_METADATA = {
"metadata_version": "1.1",
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_config.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_config.py
index e65f3ff..fdd42f6 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_config.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_config.py
@@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
+from __future__ import annotations
ANSIBLE_METADATA = {
"metadata_version": "1.1",
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_facts.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_facts.py
index 19fb727..d9fb236 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_facts.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_facts.py
@@ -6,6 +6,7 @@
"""
The module file for vyos_facts
"""
+from __future__ import annotations
ANSIBLE_METADATA = {
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp_interfaces.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp_interfaces.py
index 8fe572b..d18f3f7 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp_interfaces.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/modules/vyos_lldp_interfaces.py
@@ -26,9 +26,8 @@
The module file for vyos_lldp_interfaces
"""
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
ANSIBLE_METADATA = {
"metadata_version": "1.1",
diff --git a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/terminal/vyos.py b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/terminal/vyos.py
index fe7712f..77ef3e2 100644
--- a/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/terminal/vyos.py
+++ b/test/support/network-integration/collections/ansible_collections/vyos/vyos/plugins/terminal/vyos.py
@@ -16,9 +16,8 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import os
import re
diff --git a/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/action/win_copy.py b/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/action/win_copy.py
index 79f72ef..f68b2ab 100644
--- a/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/action/win_copy.py
+++ b/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/action/win_copy.py
@@ -3,9 +3,7 @@
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import base64
import json
@@ -155,7 +153,7 @@ def _walk_dirs(topdir, loader, decrypt=True, base_path=None, local_follow=False,
new_parents.add((parent_stat.st_dev, parent_stat.st_ino))
if (dir_stats.st_dev, dir_stats.st_ino) in new_parents:
- # This was a a circular symlink. So add it as
+ # This was a circular symlink. So add it as
# a symlink
r_files['symlinks'].append({"src": os.readlink(dirpath), "dest": dest_dirpath})
else:
diff --git a/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/action/win_reboot.py b/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/action/win_reboot.py
index f1fad4d..8d66737 100644
--- a/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/action/win_reboot.py
+++ b/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/action/win_reboot.py
@@ -1,8 +1,7 @@
# Copyright: (c) 2018, Matt Davis <mdavis@ansible.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.errors import AnsibleError
from ansible.module_utils.common.text.converters import to_native
diff --git a/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/plugin_utils/_quote.py b/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/plugin_utils/_quote.py
index 718a099..d01386e 100644
--- a/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/plugin_utils/_quote.py
+++ b/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/plugin_utils/_quote.py
@@ -14,8 +14,7 @@ not final and could be subject to change.
# See also: https://github.com/ansible/community/issues/539#issuecomment-780839686
# Please open an issue if you have questions about this.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import re
diff --git a/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/plugin_utils/_reboot.py b/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/plugin_utils/_reboot.py
index 2399ee4..ca0adcf 100644
--- a/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/plugin_utils/_reboot.py
+++ b/test/support/windows-integration/collections/ansible_collections/ansible/windows/plugins/plugin_utils/_reboot.py
@@ -13,6 +13,7 @@ interface is not final and count be subject to change.
# and may not remain stable to outside uses. Changes may be made in ANY release, even a bugfix release.
# See also: https://github.com/ansible/community/issues/539#issuecomment-780839686
# Please open an issue if you have questions about this.
+from __future__ import annotations
import datetime
import json
diff --git a/test/support/windows-integration/plugins/action/win_copy.py b/test/support/windows-integration/plugins/action/win_copy.py
index 79f72ef..f68b2ab 100644
--- a/test/support/windows-integration/plugins/action/win_copy.py
+++ b/test/support/windows-integration/plugins/action/win_copy.py
@@ -3,9 +3,7 @@
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import base64
import json
@@ -155,7 +153,7 @@ def _walk_dirs(topdir, loader, decrypt=True, base_path=None, local_follow=False,
new_parents.add((parent_stat.st_dev, parent_stat.st_ino))
if (dir_stats.st_dev, dir_stats.st_ino) in new_parents:
- # This was a a circular symlink. So add it as
+ # This was a circular symlink. So add it as
# a symlink
r_files['symlinks'].append({"src": os.readlink(dirpath), "dest": dest_dirpath})
else:
diff --git a/test/support/windows-integration/plugins/action/win_reboot.py b/test/support/windows-integration/plugins/action/win_reboot.py
index 76f4a66..a2dfe90 100644
--- a/test/support/windows-integration/plugins/action/win_reboot.py
+++ b/test/support/windows-integration/plugins/action/win_reboot.py
@@ -1,8 +1,7 @@
# Copyright: (c) 2018, Matt Davis <mdavis@ansible.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from datetime import datetime, timezone
diff --git a/test/support/windows-integration/plugins/action/win_template.py b/test/support/windows-integration/plugins/action/win_template.py
index 20494b9..dd5c0bc 100644
--- a/test/support/windows-integration/plugins/action/win_template.py
+++ b/test/support/windows-integration/plugins/action/win_template.py
@@ -15,9 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.action import ActionBase
from ansible.plugins.action.template import ActionModule as TemplateActionModule
diff --git a/test/support/windows-integration/plugins/become/runas.py b/test/support/windows-integration/plugins/become/runas.py
index c8ae881..80cbe75 100644
--- a/test/support/windows-integration/plugins/become/runas.py
+++ b/test/support/windows-integration/plugins/become/runas.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright: (c) 2018, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
DOCUMENTATION = """
become: runas
diff --git a/test/units/_vendor/test_vendor.py b/test/units/_vendor/test_vendor.py
index 265f5b2..1cbe745 100644
--- a/test/units/_vendor/test_vendor.py
+++ b/test/units/_vendor/test_vendor.py
@@ -1,5 +1,6 @@
# (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+from __future__ import annotations
import os
import pkgutil
diff --git a/test/units/ansible_test/ci/test_azp.py b/test/units/ansible_test/ci/test_azp.py
index 69c4fa4..66cef83 100644
--- a/test/units/ansible_test/ci/test_azp.py
+++ b/test/units/ansible_test/ci/test_azp.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from .util import common_auth_test
diff --git a/test/units/ansible_test/ci/util.py b/test/units/ansible_test/ci/util.py
index 2273f0a..75ba27c 100644
--- a/test/units/ansible_test/ci/util.py
+++ b/test/units/ansible_test/ci/util.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import base64
import json
diff --git a/test/units/ansible_test/conftest.py b/test/units/ansible_test/conftest.py
index 9ec9a02..20e30ae 100644
--- a/test/units/ansible_test/conftest.py
+++ b/test/units/ansible_test/conftest.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
diff --git a/test/units/ansible_test/test_diff.py b/test/units/ansible_test/test_diff.py
index 26ef522..72d33bf 100644
--- a/test/units/ansible_test/test_diff.py
+++ b/test/units/ansible_test/test_diff.py
@@ -5,7 +5,7 @@ import pathlib
import pytest
import typing as t
-if t.TYPE_CHECKING: # pragma: no cover
+if t.TYPE_CHECKING: # pragma: nocover
# noinspection PyProtectedMember
from ansible_test._internal.diff import FileDiff
diff --git a/test/units/ansible_test/test_validate_modules.py b/test/units/ansible_test/test_validate_modules.py
deleted file mode 100644
index 1b801a5..0000000
--- a/test/units/ansible_test/test_validate_modules.py
+++ /dev/null
@@ -1,63 +0,0 @@
-"""Tests for validate-modules regexes."""
-from __future__ import annotations
-
-import pathlib
-import sys
-from unittest import mock
-
-import pytest
-
-
-@pytest.fixture(autouse=True, scope='session')
-def validate_modules() -> None:
- """Make validate_modules available on sys.path for unit testing."""
- sys.path.insert(0, str(pathlib.Path(__file__).parent.parent.parent / 'lib/ansible_test/_util/controller/sanity/validate-modules'))
-
- # Mock out voluptuous to facilitate testing without it, since tests aren't covering anything that uses it.
-
- sys.modules['voluptuous'] = voluptuous = mock.MagicMock()
- sys.modules['voluptuous.humanize'] = voluptuous.humanize = mock.MagicMock()
-
- # Mock out antsibull_docs_parser to facilitate testing without it, since tests aren't covering anything that uses it.
-
- sys.modules['antsibull_docs_parser'] = antsibull_docs_parser = mock.MagicMock()
- sys.modules['antsibull_docs_parser.parser'] = antsibull_docs_parser.parser = mock.MagicMock()
-
-
-@pytest.mark.parametrize('cstring,cexpected', [
- ['if type(foo) is Bar', True],
- ['if Bar is type(foo)', True],
- ['if type(foo) is not Bar', True],
- ['if Bar is not type(foo)', True],
- ['if type(foo) == Bar', True],
- ['if Bar == type(foo)', True],
- ['if type(foo)==Bar', True],
- ['if Bar==type(foo)', True],
- ['if type(foo) != Bar', True],
- ['if Bar != type(foo)', True],
- ['if type(foo)!=Bar', True],
- ['if Bar!=type(foo)', True],
- ['if foo or type(bar) != Bar', True],
- ['x = type(foo)', False],
- ["error = err.message + ' ' + str(err) + ' - ' + str(type(err))", False],
- # cloud/amazon/ec2_group.py
- ["module.fail_json(msg='Invalid rule parameter type [%s].' % type(rule))", False],
- # files/patch.py
- ["p = type('Params', (), module.params)", False], # files/patch.py
- # system/osx_defaults.py
- ["if self.current_value is not None and not isinstance(self.current_value, type(self.value)):", True],
- # system/osx_defaults.py
- ['raise OSXDefaultsException("Type mismatch. Type in defaults: " + type(self.current_value).__name__)', False],
- # network/nxos/nxos_interface.py
- ["if get_interface_type(interface) == 'svi':", False],
-])
-def test_type_regex(cstring, cexpected): # type: (str, str) -> None
- """Check TYPE_REGEX against various examples to verify it correctly matches or does not match."""
- from validate_modules.main import TYPE_REGEX
-
- match = TYPE_REGEX.match(cstring)
-
- if cexpected:
- assert match, f"should have matched: {cstring}"
- else:
- assert not match, f"should not have matched: {cstring}"
diff --git a/test/units/cli/arguments/test_optparse_helpers.py b/test/units/cli/arguments/test_optparse_helpers.py
index ae8e8d7..3af0672 100644
--- a/test/units/cli/arguments/test_optparse_helpers.py
+++ b/test/units/cli/arguments/test_optparse_helpers.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2018, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import sys
diff --git a/test/units/cli/galaxy/test_collection_extract_tar.py b/test/units/cli/galaxy/test_collection_extract_tar.py
index b84f60b..521a5e7 100644
--- a/test/units/cli/galaxy/test_collection_extract_tar.py
+++ b/test/units/cli/galaxy/test_collection_extract_tar.py
@@ -2,8 +2,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/cli/galaxy/test_display_collection.py b/test/units/cli/galaxy/test_display_collection.py
index c86227b..a7b3753 100644
--- a/test/units/cli/galaxy/test_display_collection.py
+++ b/test/units/cli/galaxy/test_display_collection.py
@@ -2,8 +2,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/cli/galaxy/test_display_header.py b/test/units/cli/galaxy/test_display_header.py
index ae926b0..2b5325f 100644
--- a/test/units/cli/galaxy/test_display_header.py
+++ b/test/units/cli/galaxy/test_display_header.py
@@ -2,8 +2,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.cli.galaxy import _display_header
diff --git a/test/units/cli/galaxy/test_display_role.py b/test/units/cli/galaxy/test_display_role.py
index e23a772..dd454a4 100644
--- a/test/units/cli/galaxy/test_display_role.py
+++ b/test/units/cli/galaxy/test_display_role.py
@@ -2,8 +2,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.cli.galaxy import _display_role
diff --git a/test/units/cli/galaxy/test_execute_list.py b/test/units/cli/galaxy/test_execute_list.py
index 41fee0b..1fde1ca 100644
--- a/test/units/cli/galaxy/test_execute_list.py
+++ b/test/units/cli/galaxy/test_execute_list.py
@@ -3,8 +3,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/cli/galaxy/test_execute_list_collection.py b/test/units/cli/galaxy/test_execute_list_collection.py
index 5641cb8..0ba24e9 100644
--- a/test/units/cli/galaxy/test_execute_list_collection.py
+++ b/test/units/cli/galaxy/test_execute_list_collection.py
@@ -2,8 +2,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pathlib
diff --git a/test/units/cli/galaxy/test_get_collection_widths.py b/test/units/cli/galaxy/test_get_collection_widths.py
index 6e1cbf5..df1f0df 100644
--- a/test/units/cli/galaxy/test_get_collection_widths.py
+++ b/test/units/cli/galaxy/test_get_collection_widths.py
@@ -2,8 +2,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/cli/test_adhoc.py b/test/units/cli/test_adhoc.py
index 7bcca47..9e0a9cd 100644
--- a/test/units/cli/test_adhoc.py
+++ b/test/units/cli/test_adhoc.py
@@ -1,8 +1,7 @@
# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
import re
diff --git a/test/units/cli/test_cli.py b/test/units/cli/test_cli.py
index 79c2b8f..510f5c3 100644
--- a/test/units/cli/test_cli.py
+++ b/test/units/cli/test_cli.py
@@ -15,11 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from unittest.mock import patch, MagicMock
from units.mock.loader import DictDataLoader
@@ -52,14 +50,6 @@ class TestCliBuildVaultIds(unittest.TestCase):
res = cli.CLI.build_vault_ids(['foo@bar'])
self.assertEqual(res, ['foo@bar'])
- def test_create_new_password_no_vault_id(self):
- res = cli.CLI.build_vault_ids([], create_new_password=True)
- self.assertEqual(res, ['default@prompt_ask_vault_pass'])
-
- def test_create_new_password_no_vault_id_no_auto_prompt(self):
- res = cli.CLI.build_vault_ids([], auto_prompt=False, create_new_password=True)
- self.assertEqual(res, [])
-
def test_no_vault_id_no_auto_prompt(self):
# simulate 'ansible-playbook site.yml' with out --ask-vault-pass, should not prompt
res = cli.CLI.build_vault_ids([], auto_prompt=False)
@@ -77,23 +67,12 @@ class TestCliBuildVaultIds(unittest.TestCase):
res = cli.CLI.build_vault_ids([], auto_prompt=True, ask_vault_pass=True)
self.assertEqual(res, ['default@prompt_ask_vault_pass'])
- def test_create_new_password_auto_prompt(self):
- # simulate 'ansible-vault encrypt somefile.yml'
- res = cli.CLI.build_vault_ids([], auto_prompt=True, create_new_password=True)
+ def test_no_vault_id_ask_vault_pass(self):
+ res = cli.CLI.build_vault_ids([], ask_vault_pass=True)
self.assertEqual(res, ['default@prompt_ask_vault_pass'])
- def test_create_new_password_no_vault_id_ask_vault_pass(self):
- res = cli.CLI.build_vault_ids([], ask_vault_pass=True,
- create_new_password=True)
- self.assertEqual(res, ['default@prompt_ask_vault_pass'])
-
- def test_create_new_password_with_vault_ids(self):
- res = cli.CLI.build_vault_ids(['foo@bar'], create_new_password=True)
- self.assertEqual(res, ['foo@bar'])
-
- def test_create_new_password_no_vault_ids_password_files(self):
- res = cli.CLI.build_vault_ids([], vault_password_files=['some-password-file'],
- create_new_password=True)
+ def test_no_vault_ids_password_files(self):
+ res = cli.CLI.build_vault_ids([], vault_password_files=['some-password-file'])
self.assertEqual(res, ['default@some-password-file'])
def test_everything(self):
@@ -102,7 +81,6 @@ class TestCliBuildVaultIds(unittest.TestCase):
vault_password_files=['yet-another-password-file',
'one-more-password-file'],
ask_vault_pass=True,
- create_new_password=True,
auto_prompt=False)
self.assertEqual(set(res), set(['blip@prompt', 'baz@prompt_ask_vault_pass',
diff --git a/test/units/cli/test_console.py b/test/units/cli/test_console.py
index 4fc05dd..ce37572 100644
--- a/test/units/cli/test_console.py
+++ b/test/units/cli/test_console.py
@@ -15,11 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from unittest.mock import patch
from ansible.cli.console import ConsoleCLI
diff --git a/test/units/cli/test_data/role_skeleton/meta/main.yml.j2 b/test/units/cli/test_data/role_skeleton/meta/main.yml.j2
index 2fc53cb..b2d1ee6 100644
--- a/test/units/cli/test_data/role_skeleton/meta/main.yml.j2
+++ b/test/units/cli/test_data/role_skeleton/meta/main.yml.j2
@@ -26,24 +26,6 @@ galaxy_info:
# (usually master) will be used.
#github_branch:
- #
- # Provide a list of supported platforms, and for each platform a list of versions.
- # If you don't wish to enumerate all versions for a particular platform, use 'all'.
- # To view available platforms and versions (or releases), visit:
- # https://galaxy.ansible.com/api/v1/platforms/
- #
- # platforms:
- # - name: Fedora
- # versions:
- # - all
- # - 25
- # - name: SomePlatform
- # versions:
- # - all
- # - 1.0
- # - 7
- # - 99.99
-
galaxy_tags: []
# List tags for your role here, one per line. A tag is
# a keyword that describes and categorizes the role.
diff --git a/test/units/cli/test_doc.py b/test/units/cli/test_doc.py
index 50b714e..caf2bbe 100644
--- a/test/units/cli/test_doc.py
+++ b/test/units/cli/test_doc.py
@@ -1,19 +1,19 @@
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
+from ansible import constants as C
from ansible.cli.doc import DocCLI, RoleMixin
from ansible.plugins.loader import module_loader, init_plugin_loader
+C.ANSIBLE_NOCOLOR = True
TTY_IFY_DATA = {
# No substitutions
'no-op': 'no-op',
'no-op Z(test)': 'no-op Z(test)',
# Simple cases of all substitutions
- 'I(italic)': "`italic'",
+ 'I(italic)': "`italic`",
'B(bold)': '*bold*',
'M(ansible.builtin.module)': '[ansible.builtin.module]',
'U(https://docs.ansible.com)': 'https://docs.ansible.com',
@@ -49,15 +49,17 @@ def test_rolemixin__build_summary():
'main': {'short_description': 'main short description'},
'alternate': {'short_description': 'alternate short description'},
}
+ meta = {}
expected = {
'collection': collection_name,
+ 'description': 'UNDOCUMENTED',
'entry_points': {
'main': argspec['main']['short_description'],
'alternate': argspec['alternate']['short_description'],
}
}
- fqcn, summary = obj._build_summary(role_name, collection_name, argspec)
+ fqcn, summary = obj._build_summary(role_name, collection_name, meta, argspec)
assert fqcn == '.'.join([collection_name, role_name])
assert summary == expected
@@ -67,12 +69,14 @@ def test_rolemixin__build_summary_empty_argspec():
role_name = 'test_role'
collection_name = 'test.units'
argspec = {}
+ meta = {}
expected = {
'collection': collection_name,
+ 'description': 'UNDOCUMENTED',
'entry_points': {}
}
- fqcn, summary = obj._build_summary(role_name, collection_name, argspec)
+ fqcn, summary = obj._build_summary(role_name, collection_name, meta, argspec)
assert fqcn == '.'.join([collection_name, role_name])
assert summary == expected
diff --git a/test/units/cli/test_galaxy.py b/test/units/cli/test_galaxy.py
index 80a2dfa..ece3524 100644
--- a/test/units/cli/test_galaxy.py
+++ b/test/units/cli/test_galaxy.py
@@ -16,9 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import contextlib
@@ -39,10 +37,11 @@ from ansible.cli.galaxy import GalaxyCLI
from ansible.galaxy import collection
from ansible.galaxy.api import GalaxyAPI
from ansible.errors import AnsibleError
+from ansible.module_utils.common.file import S_IRWU_RG_RO, S_IRWXU_RXG_RXO
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
from ansible.utils import context_objects as co
from ansible.utils.display import Display
-from units.compat import unittest
+import unittest
from unittest.mock import patch, MagicMock
@@ -660,9 +659,9 @@ def test_collection_build(collection_artifact):
assert member.uid == 0
assert member.uname == ''
if member.isdir() or member.name == 'runme.sh':
- assert member.mode == 0o0755
+ assert member.mode == S_IRWXU_RXG_RXO
else:
- assert member.mode == 0o0644
+ assert member.mode == S_IRWU_RG_RO
manifest_file = tar.extractfile(tar_members[0])
try:
diff --git a/test/units/cli/test_playbook.py b/test/units/cli/test_playbook.py
index f25e54d..dfa140e 100644
--- a/test/units/cli/test_playbook.py
+++ b/test/units/cli/test_playbook.py
@@ -15,11 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from units.mock.loader import DictDataLoader
from ansible import context
diff --git a/test/units/cli/test_vault.py b/test/units/cli/test_vault.py
index f1399c3..a049610 100644
--- a/test/units/cli/test_vault.py
+++ b/test/units/cli/test_vault.py
@@ -16,14 +16,12 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import pytest
-from units.compat import unittest
+import unittest
from unittest.mock import patch, MagicMock
from units.mock.vault_helper import TextVaultSecret
diff --git a/test/units/compat/mock.py b/test/units/compat/mock.py
deleted file mode 100644
index 0315460..0000000
--- a/test/units/compat/mock.py
+++ /dev/null
@@ -1,23 +0,0 @@
-"""
-Compatibility shim for mock imports in modules and module_utils.
-This can be removed once support for Python 2.7 is dropped.
-"""
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-try:
- from unittest.mock import ( # pylint: disable=unused-import
- call,
- patch,
- mock_open,
- MagicMock,
- Mock,
- )
-except ImportError:
- from mock import (
- call,
- patch,
- mock_open,
- MagicMock,
- Mock,
- )
diff --git a/test/units/compat/unittest.py b/test/units/compat/unittest.py
deleted file mode 100644
index b416774..0000000
--- a/test/units/compat/unittest.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-# Allow wildcard import because we really do want to import all of
-# unittests's symbols into this compat shim
-# pylint: disable=wildcard-import,unused-wildcard-import
-from unittest import *
-
-if not hasattr(TestCase, 'assertRaisesRegex'):
- # added in Python 3.2
- TestCase.assertRaisesRegex = TestCase.assertRaisesRegexp
diff --git a/test/units/config/manager/test_find_ini_config_file.py b/test/units/config/manager/test_find_ini_config_file.py
index e67eecd..2fee915 100644
--- a/test/units/config/manager/test_find_ini_config_file.py
+++ b/test/units/config/manager/test_find_ini_config_file.py
@@ -2,9 +2,7 @@
# Copyright: (c) 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import os.path
diff --git a/test/units/config/test_manager.py b/test/units/config/test_manager.py
index 0848276..6a920f2 100644
--- a/test/units/config/test_manager.py
+++ b/test/units/config/test_manager.py
@@ -2,9 +2,7 @@
# Copyright: (c) 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import os.path
@@ -12,7 +10,6 @@ import pytest
from ansible.config.manager import ConfigManager, ensure_type, resolve_path, get_config_type
from ansible.errors import AnsibleOptionsError, AnsibleError
-from ansible.module_utils.six import integer_types, string_types
from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode
curdir = os.path.dirname(__file__)
@@ -41,38 +38,38 @@ ensure_test_data = [
(0, 'bool', bool),
(0.0, 'bool', bool),
(False, 'bool', bool),
- ('10', 'int', integer_types),
- (20, 'int', integer_types),
+ ('10', 'int', int),
+ (20, 'int', int),
('0.10', 'float', float),
(0.2, 'float', float),
('/tmp/test.yml', 'pathspec', list),
('/tmp/test.yml,/home/test2.yml', 'pathlist', list),
- ('a', 'str', string_types),
- ('a', 'string', string_types),
- ('Café', 'string', string_types),
- ('', 'string', string_types),
- ('29', 'str', string_types),
- ('13.37', 'str', string_types),
- ('123j', 'string', string_types),
- ('0x123', 'string', string_types),
- ('true', 'string', string_types),
- ('True', 'string', string_types),
- (0, 'str', string_types),
- (29, 'str', string_types),
- (13.37, 'str', string_types),
- (123j, 'string', string_types),
- (0x123, 'string', string_types),
- (True, 'string', string_types),
+ ('a', 'str', str),
+ ('a', 'string', str),
+ ('Café', 'string', str),
+ ('', 'string', str),
+ ('29', 'str', str),
+ ('13.37', 'str', str),
+ ('123j', 'string', str),
+ ('0x123', 'string', str),
+ ('true', 'string', str),
+ ('True', 'string', str),
+ (0, 'str', str),
+ (29, 'str', str),
+ (13.37, 'str', str),
+ (123j, 'string', str),
+ (0x123, 'string', str),
+ (True, 'string', str),
('None', 'none', type(None))
]
ensure_unquoting_test_data = [
- ('"value"', '"value"', 'str', 'env'),
- ('"value"', '"value"', 'str', 'yaml'),
- ('"value"', 'value', 'str', 'ini'),
- ('\'value\'', 'value', 'str', 'ini'),
- ('\'\'value\'\'', '\'value\'', 'str', 'ini'),
- ('""value""', '"value"', 'str', 'ini')
+ ('"value"', '"value"', 'str', 'env: ENVVAR', None),
+ ('"value"', '"value"', 'str', os.path.join(curdir, 'test.yml'), 'yaml'),
+ ('"value"', 'value', 'str', cfg_file, 'ini'),
+ ('\'value\'', 'value', 'str', cfg_file, 'ini'),
+ ('\'\'value\'\'', '\'value\'', 'str', cfg_file, 'ini'),
+ ('""value""', '"value"', 'str', cfg_file, 'ini')
]
@@ -89,9 +86,9 @@ class TestConfigManager:
def test_ensure_type(self, value, expected_type, python_type):
assert isinstance(ensure_type(value, expected_type), python_type)
- @pytest.mark.parametrize("value, expected_value, value_type, origin", ensure_unquoting_test_data)
- def test_ensure_type_unquoting(self, value, expected_value, value_type, origin):
- actual_value = ensure_type(value, value_type, origin)
+ @pytest.mark.parametrize("value, expected_value, value_type, origin, origin_ftype", ensure_unquoting_test_data)
+ def test_ensure_type_unquoting(self, value, expected_value, value_type, origin, origin_ftype):
+ actual_value = ensure_type(value, value_type, origin, origin_ftype)
assert actual_value == expected_value
def test_resolve_path(self):
diff --git a/test/units/errors/test_errors.py b/test/units/errors/test_errors.py
index 7a1de3d..94c905b 100644
--- a/test/units/errors/test_errors.py
+++ b/test/units/errors/test_errors.py
@@ -15,12 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from unittest.mock import mock_open, patch
from ansible.errors import AnsibleError
from ansible.parsing.yaml.objects import AnsibleBaseYAMLObject
diff --git a/test/units/executor/module_common/conftest.py b/test/units/executor/module_common/conftest.py
index f0eef12..d1fb888 100644
--- a/test/units/executor/module_common/conftest.py
+++ b/test/units/executor/module_common/conftest.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import pytest
diff --git a/test/units/executor/module_common/test_modify_module.py b/test/units/executor/module_common/test_modify_module.py
index 89e4a16..0ea1918 100644
--- a/test/units/executor/module_common/test_modify_module.py
+++ b/test/units/executor/module_common/test_modify_module.py
@@ -2,8 +2,7 @@
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# -*- coding: utf-8 -*-
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/executor/module_common/test_module_common.py b/test/units/executor/module_common/test_module_common.py
index 6e2a495..c7edce6 100644
--- a/test/units/executor/module_common/test_module_common.py
+++ b/test/units/executor/module_common/test_module_common.py
@@ -15,9 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os.path
diff --git a/test/units/executor/module_common/test_recursive_finder.py b/test/units/executor/module_common/test_recursive_finder.py
index 95b49d3..92d7c20 100644
--- a/test/units/executor/module_common/test_recursive_finder.py
+++ b/test/units/executor/module_common/test_recursive_finder.py
@@ -15,9 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import pytest
@@ -42,7 +40,6 @@ MODULE_UTILS_BASIC_FILES = frozenset(('ansible/__init__.py',
'ansible/module_utils/basic.py',
'ansible/module_utils/six/__init__.py',
'ansible/module_utils/_text.py',
- 'ansible/module_utils/common/_json_compat.py',
'ansible/module_utils/common/collections.py',
'ansible/module_utils/common/parameters.py',
'ansible/module_utils/common/warnings.py',
@@ -59,8 +56,6 @@ MODULE_UTILS_BASIC_FILES = frozenset(('ansible/__init__.py',
'ansible/module_utils/common/_utils.py',
'ansible/module_utils/common/arg_spec.py',
'ansible/module_utils/compat/__init__.py',
- 'ansible/module_utils/compat/_selectors2.py',
- 'ansible/module_utils/compat/selectors.py',
'ansible/module_utils/compat/selinux.py',
'ansible/module_utils/distro/__init__.py',
'ansible/module_utils/distro/_distro.py',
diff --git a/test/units/executor/test_interpreter_discovery.py b/test/units/executor/test_interpreter_discovery.py
index 10fc64b..876c779 100644
--- a/test/units/executor/test_interpreter_discovery.py
+++ b/test/units/executor/test_interpreter_discovery.py
@@ -2,73 +2,73 @@
# (c) 2019, Jordan Borean <jborean@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
+import pytest
from unittest.mock import MagicMock
from ansible.executor.interpreter_discovery import discover_interpreter
from ansible.module_utils.common.text.converters import to_text
+from ansible.errors import AnsibleConnectionFailure
mock_ubuntu_platform_res = to_text(
- r'{"osrelease_content": "NAME=\"Ubuntu\"\nVERSION=\"16.04.5 LTS (Xenial Xerus)\"\nID=ubuntu\nID_LIKE=debian\n'
- r'PRETTY_NAME=\"Ubuntu 16.04.5 LTS\"\nVERSION_ID=\"16.04\"\nHOME_URL=\"http://www.ubuntu.com/\"\n'
- r'SUPPORT_URL=\"http://help.ubuntu.com/\"\nBUG_REPORT_URL=\"http://bugs.launchpad.net/ubuntu/\"\n'
- r'VERSION_CODENAME=xenial\nUBUNTU_CODENAME=xenial\n", "platform_dist_result": ["Ubuntu", "16.04", "xenial"]}'
+ r'{"osrelease_content": "NAME=\"Ansible Test\"\nVERSION=\"100\"\nID=ansible-test\nID_LIKE=debian\n'
+ r'PRETTY_NAME=\"Ansible Test 100\"\nVERSION_ID=\"100\"\nHOME_URL=\"http://ansible.com/\"\n'
+ r'SUPPORT_URL=\"http://github.com/ansible/ansible\"\nBUG_REPORT_URL=\"http://github.com/ansible/ansible/\"\n'
+ r'VERSION_CODENAME=beans\nUBUNTU_CODENAME=beans\n", "platform_dist_result": ["Ansible Test", "100", "beans"]}'
)
def test_discovery_interpreter_linux_auto_legacy():
- res1 = u'PLATFORM\nLinux\nFOUND\n/usr/bin/python\n/usr/bin/python3\nENDFOUND'
+ res1 = u'PLATFORM\nLinux\nFOUND\n/usr/bin/python99\n/usr/bin/python3\nENDFOUND'
mock_action = MagicMock()
mock_action._low_level_execute_command.side_effect = [{'stdout': res1}, {'stdout': mock_ubuntu_platform_res}]
actual = discover_interpreter(mock_action, 'python', 'auto_legacy', {'inventory_hostname': u'host-fóöbär'})
- assert actual == u'/usr/bin/python'
+ assert actual == u'/usr/bin/python3'
assert len(mock_action.method_calls) == 3
assert mock_action.method_calls[2][0] == '_discovery_warnings.append'
- assert u'Distribution Ubuntu 16.04 on host host-fóöbär should use /usr/bin/python3, but is using /usr/bin/python' \
+ assert u'Distribution Ansible Test 100 on host host-fóöbär should use /usr/bin/python99, but is using /usr/bin/python3' \
u' for backward compatibility' in mock_action.method_calls[2][1][0]
def test_discovery_interpreter_linux_auto_legacy_silent():
- res1 = u'PLATFORM\nLinux\nFOUND\n/usr/bin/python\n/usr/bin/python3\nENDFOUND'
+ res1 = u'PLATFORM\nLinux\nFOUND\n/usr/bin/python3.9\n/usr/bin/python3\nENDFOUND'
mock_action = MagicMock()
mock_action._low_level_execute_command.side_effect = [{'stdout': res1}, {'stdout': mock_ubuntu_platform_res}]
actual = discover_interpreter(mock_action, 'python', 'auto_legacy_silent', {'inventory_hostname': u'host-fóöbär'})
- assert actual == u'/usr/bin/python'
+ assert actual == u'/usr/bin/python3'
assert len(mock_action.method_calls) == 2
def test_discovery_interpreter_linux_auto():
- res1 = u'PLATFORM\nLinux\nFOUND\n/usr/bin/python\n/usr/bin/python3\nENDFOUND'
+ res1 = u'PLATFORM\nLinux\nFOUND\n/usr/bin/python99\n/usr/bin/python3\nENDFOUND'
mock_action = MagicMock()
mock_action._low_level_execute_command.side_effect = [{'stdout': res1}, {'stdout': mock_ubuntu_platform_res}]
actual = discover_interpreter(mock_action, 'python', 'auto', {'inventory_hostname': u'host-fóöbär'})
- assert actual == u'/usr/bin/python3'
+ assert actual == u'/usr/bin/python99'
assert len(mock_action.method_calls) == 2
def test_discovery_interpreter_non_linux():
mock_action = MagicMock()
mock_action._low_level_execute_command.return_value = \
- {'stdout': u'PLATFORM\nDarwin\nFOUND\n/usr/bin/python\nENDFOUND'}
+ {'stdout': u'PLATFORM\nDarwin\nFOUND\n/usr/bin/python3\nENDFOUND'}
actual = discover_interpreter(mock_action, 'python', 'auto_legacy', {'inventory_hostname': u'host-fóöbär'})
- assert actual == u'/usr/bin/python'
+ assert actual == u'/usr/bin/python3'
assert len(mock_action.method_calls) == 2
assert mock_action.method_calls[1][0] == '_discovery_warnings.append'
- assert u'Platform darwin on host host-fóöbär is using the discovered Python interpreter at /usr/bin/python, ' \
+ assert u'Platform darwin on host host-fóöbär is using the discovered Python interpreter at /usr/bin/python3, ' \
u'but future installation of another Python interpreter could change the meaning of that path' \
in mock_action.method_calls[1][1][0]
@@ -79,8 +79,18 @@ def test_no_interpreters_found():
actual = discover_interpreter(mock_action, 'python', 'auto_legacy', {'inventory_hostname': u'host-fóöbär'})
- assert actual == u'/usr/bin/python'
+ assert actual == u'/usr/bin/python3'
assert len(mock_action.method_calls) == 2
assert mock_action.method_calls[1][0] == '_discovery_warnings.append'
assert u'No python interpreters found for host host-fóöbär (tried' \
in mock_action.method_calls[1][1][0]
+
+
+def test_ansible_error_exception():
+ mock_action = MagicMock()
+ mock_action._low_level_execute_command.side_effect = AnsibleConnectionFailure("host key mismatch")
+
+ with pytest.raises(AnsibleConnectionFailure) as context:
+ discover_interpreter(mock_action, 'python', 'auto_legacy', {'inventory_hostname': u'host'})
+
+ assert 'host key mismatch' == str(context.value)
diff --git a/test/units/executor/test_play_iterator.py b/test/units/executor/test_play_iterator.py
index 0fc5975..14a9cc4 100644
--- a/test/units/executor/test_play_iterator.py
+++ b/test/units/executor/test_play_iterator.py
@@ -15,11 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from unittest.mock import patch, MagicMock
from ansible.executor.play_iterator import HostState, PlayIterator, IteratingStates, FailedStates
diff --git a/test/units/executor/test_playbook_executor.py b/test/units/executor/test_playbook_executor.py
index 6032dbb..62fa1a3 100644
--- a/test/units/executor/test_playbook_executor.py
+++ b/test/units/executor/test_playbook_executor.py
@@ -15,11 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from unittest.mock import MagicMock
from ansible.executor.playbook_executor import PlaybookExecutor
diff --git a/test/units/executor/test_task_executor.py b/test/units/executor/test_task_executor.py
index 66ab003..f562bfa 100644
--- a/test/units/executor/test_task_executor.py
+++ b/test/units/executor/test_task_executor.py
@@ -15,20 +15,17 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from unittest import mock
-from units.compat import unittest
+import unittest
from unittest.mock import patch, MagicMock
from ansible.errors import AnsibleError
from ansible.executor.task_executor import TaskExecutor, remove_omit
from ansible.plugins.loader import action_loader, lookup_loader
from ansible.parsing.yaml.objects import AnsibleUnicode
from ansible.utils.unsafe_proxy import AnsibleUnsafeText, AnsibleUnsafeBytes
-from ansible.module_utils.six import text_type
from collections import namedtuple
from units.mock.loader import DictDataLoader
@@ -121,8 +118,8 @@ class TestTaskExecutor(unittest.TestCase):
data = res['results'][0]
self.assertIsInstance(data['unsafe_bytes'], AnsibleUnsafeText)
self.assertIsInstance(data['unsafe_text'], AnsibleUnsafeText)
- self.assertIsInstance(data['bytes'], text_type)
- self.assertIsInstance(data['text'], text_type)
+ self.assertIsInstance(data['bytes'], str)
+ self.assertIsInstance(data['text'], str)
self.assertIsInstance(data['int'], int)
def test_task_executor_get_loop_items(self):
diff --git a/test/units/executor/test_task_queue_manager_callbacks.py b/test/units/executor/test_task_queue_manager_callbacks.py
index c63385d..c53a42d 100644
--- a/test/units/executor/test_task_queue_manager_callbacks.py
+++ b/test/units/executor/test_task_queue_manager_callbacks.py
@@ -15,10 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from unittest.mock import MagicMock
from ansible.executor.task_queue_manager import TaskQueueManager
@@ -26,8 +25,6 @@ from ansible.playbook import Playbook
from ansible.plugins.callback import CallbackBase
from ansible.utils import context_objects as co
-__metaclass__ = type
-
class TestTaskQueueManagerCallbacks(unittest.TestCase):
def setUp(self):
diff --git a/test/units/executor/test_task_result.py b/test/units/executor/test_task_result.py
index 8b79571..54b8613 100644
--- a/test/units/executor/test_task_result.py
+++ b/test/units/executor/test_task_result.py
@@ -15,11 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from unittest.mock import patch, MagicMock
from ansible.executor.task_result import TaskResult
diff --git a/test/units/galaxy/test_api.py b/test/units/galaxy/test_api.py
index b019f1a..c7ee165 100644
--- a/test/units/galaxy/test_api.py
+++ b/test/units/galaxy/test_api.py
@@ -2,9 +2,7 @@
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import os
@@ -24,8 +22,9 @@ from ansible.errors import AnsibleError
from ansible.galaxy import api as galaxy_api
from ansible.galaxy.api import CollectionVersionMetadata, GalaxyAPI, GalaxyError
from ansible.galaxy.token import BasicAuthToken, GalaxyToken, KeycloakToken
+from ansible.module_utils.common.file import S_IRWU_RG_RO
from ansible.module_utils.common.text.converters import to_native, to_text
-from ansible.module_utils.six.moves.urllib import error as urllib_error
+import urllib.error
from ansible.utils import context_objects as co
from ansible.utils.display import Display
@@ -49,7 +48,7 @@ def collection_artifact(tmp_path_factory):
b_io = BytesIO(b"\x00\x01\x02\x03")
tar_info = tarfile.TarInfo('test')
tar_info.size = 4
- tar_info.mode = 0o0644
+ tar_info.mode = S_IRWU_RG_RO
tfile.addfile(tarinfo=tar_info, fileobj=b_io)
yield tar_path
@@ -326,8 +325,8 @@ def test_initialise_automation_hub(monkeypatch):
def test_initialise_unknown(monkeypatch):
mock_open = MagicMock()
mock_open.side_effect = [
- urllib_error.HTTPError('https://galaxy.ansible.com/api/', 500, 'msg', {}, StringIO(u'{"msg":"raw error"}')),
- urllib_error.HTTPError('https://galaxy.ansible.com/api/api/', 500, 'msg', {}, StringIO(u'{"msg":"raw error"}')),
+ urllib.error.HTTPError('https://galaxy.ansible.com/api/', 500, 'msg', {}, StringIO(u'{"msg":"raw error"}')),
+ urllib.error.HTTPError('https://galaxy.ansible.com/api/api/', 500, 'msg', {}, StringIO(u'{"msg":"raw error"}')),
]
monkeypatch.setattr(galaxy_api, 'open_url', mock_open)
@@ -444,7 +443,7 @@ def test_publish_failure(api_version, collection_url, response, expected, collec
expected_url = '%s/api/%s/%s' % (api.api_server, api_version, collection_url)
mock_open = MagicMock()
- mock_open.side_effect = urllib_error.HTTPError(expected_url, 500, 'msg', {},
+ mock_open.side_effect = urllib.error.HTTPError(expected_url, 500, 'msg', {},
StringIO(to_text(json.dumps(response))))
monkeypatch.setattr(galaxy_api, 'open_url', mock_open)
@@ -1236,7 +1235,7 @@ def test_cache_flaky_pagination(cache_dir, monkeypatch):
side_effect=[
StringIO(to_text(json.dumps(responses[0]))),
StringIO(to_text(json.dumps(responses[1]))),
- urllib_error.HTTPError(responses[1]['next'], 500, 'Error', {}, StringIO()),
+ urllib.error.HTTPError(responses[1]['next'], 500, 'Error', {}, StringIO()),
StringIO(to_text(json.dumps(responses[3]))),
]
)
diff --git a/test/units/galaxy/test_collection.py b/test/units/galaxy/test_collection.py
index 991184a..10bc0e5 100644
--- a/test/units/galaxy/test_collection.py
+++ b/test/units/galaxy/test_collection.py
@@ -2,9 +2,7 @@
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import os
@@ -25,7 +23,8 @@ from ansible.cli.galaxy import GalaxyCLI
from ansible.errors import AnsibleError
from ansible.galaxy import api, collection, token
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
-from ansible.module_utils.six.moves import builtins
+from ansible.module_utils.common.file import S_IRWU_RG_RO
+import builtins
from ansible.utils import context_objects as co
from ansible.utils.display import Display
from ansible.utils.hashing import secure_hash_s
@@ -39,10 +38,17 @@ def reset_cli_args():
co.GlobalCLIArgs._Singleton__instance = None
-@pytest.fixture()
-def collection_input(tmp_path_factory):
- ''' Creates a collection skeleton directory for build tests '''
- test_dir = to_text(tmp_path_factory.mktemp('test-ÅÑŚÌβÅÈ Collections Input'))
+@pytest.fixture
+def collection_path_suffix(request):
+ """Return test collection path suffix or the default."""
+ return getattr(request, 'param', 'test-ÅÑŚÌβÅÈ Collections Input')
+
+
+@pytest.fixture
+def collection_input(tmp_path_factory, collection_path_suffix):
+ """Create a collection skeleton directory for build tests."""
+ test_dir = to_text(tmp_path_factory.mktemp(collection_path_suffix))
+
namespace = 'ansible_namespace'
collection = 'collection'
skeleton = os.path.join(os.path.dirname(os.path.split(__file__)[0]), 'cli', 'test_data', 'collection_skeleton')
@@ -73,7 +79,7 @@ def collection_artifact(monkeypatch, tmp_path_factory):
b_io = BytesIO(b"\x00\x01\x02\x03")
tar_info = tarfile.TarInfo('test')
tar_info.size = 4
- tar_info.mode = 0o0644
+ tar_info.mode = S_IRWU_RG_RO
tfile.addfile(tarinfo=tar_info, fileobj=b_io)
return input_file, mock_open
@@ -101,14 +107,14 @@ def tmp_tarfile(tmp_path_factory, manifest_info):
b_io = BytesIO(data)
tar_info = tarfile.TarInfo(filename)
tar_info.size = len(data)
- tar_info.mode = 0o0644
+ tar_info.mode = S_IRWU_RG_RO
tfile.addfile(tarinfo=tar_info, fileobj=b_io)
b_data = to_bytes(json.dumps(manifest_info, indent=True), errors='surrogate_or_strict')
b_io = BytesIO(b_data)
tar_info = tarfile.TarInfo('MANIFEST.json')
tar_info.size = len(b_data)
- tar_info.mode = 0o0644
+ tar_info.mode = S_IRWU_RG_RO
tfile.addfile(tarinfo=tar_info, fileobj=b_io)
sha256_hash = sha256()
@@ -467,6 +473,14 @@ def test_build_existing_output_without_force(collection_input):
collection.build_collection(to_text(input_dir, errors='surrogate_or_strict'), to_text(output_dir, errors='surrogate_or_strict'), False)
+@pytest.mark.parametrize(
+ 'collection_path_suffix',
+ (
+ 'test-ÅÑŚÌβÅÈ Collections Input 1 with_slash/',
+ 'test-ÅÑŚÌβÅÈ Collections Input 2 no slash',
+ ),
+ indirect=('collection_path_suffix', ),
+)
def test_build_existing_output_with_force(collection_input):
input_dir, output_dir = collection_input
@@ -949,7 +963,7 @@ def test_extract_tar_file_outside_dir(tmp_path_factory):
b_io = BytesIO(data)
tar_info = tarfile.TarInfo(tar_filename)
tar_info.size = len(data)
- tar_info.mode = 0o0644
+ tar_info.mode = S_IRWU_RG_RO
tfile.addfile(tarinfo=tar_info, fileobj=b_io)
expected = re.escape("Cannot extract tar entry '%s' as it will be placed outside the collection directory"
diff --git a/test/units/galaxy/test_collection_install.py b/test/units/galaxy/test_collection_install.py
index a61ae40..9398c00 100644
--- a/test/units/galaxy/test_collection_install.py
+++ b/test/units/galaxy/test_collection_install.py
@@ -2,9 +2,7 @@
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import copy
import json
@@ -19,13 +17,14 @@ import yaml
from io import BytesIO, StringIO
from unittest.mock import MagicMock, patch
-import ansible.module_utils.six.moves.urllib.error as urllib_error
+import urllib.error
from ansible import context
from ansible.cli.galaxy import GalaxyCLI
from ansible.errors import AnsibleError
from ansible.galaxy import collection, api, dependency_resolution
from ansible.galaxy.dependency_resolution.dataclasses import Candidate, Requirement
+from ansible.module_utils.common.file import S_IRWU_RG_RO, S_IRWXU_RXG_RXO
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
from ansible.module_utils.common.process import get_bin_path
from ansible.utils import context_objects as co
@@ -347,7 +346,7 @@ def test_build_requirement_from_tar_no_manifest(tmp_path_factory):
b_io = BytesIO(json_data)
tar_info = tarfile.TarInfo('FILES.json')
tar_info.size = len(json_data)
- tar_info.mode = 0o0644
+ tar_info.mode = S_IRWU_RG_RO
tfile.addfile(tarinfo=tar_info, fileobj=b_io)
concrete_artifact_cm = collection.concrete_artifact_manager.ConcreteArtifactsManager(test_dir, validate_certs=False)
@@ -371,7 +370,7 @@ def test_build_requirement_from_tar_no_files(tmp_path_factory):
b_io = BytesIO(json_data)
tar_info = tarfile.TarInfo('MANIFEST.json')
tar_info.size = len(json_data)
- tar_info.mode = 0o0644
+ tar_info.mode = S_IRWU_RG_RO
tfile.addfile(tarinfo=tar_info, fileobj=b_io)
concrete_artifact_cm = collection.concrete_artifact_manager.ConcreteArtifactsManager(test_dir, validate_certs=False)
@@ -389,7 +388,7 @@ def test_build_requirement_from_tar_invalid_manifest(tmp_path_factory):
b_io = BytesIO(json_data)
tar_info = tarfile.TarInfo('MANIFEST.json')
tar_info.size = len(json_data)
- tar_info.mode = 0o0644
+ tar_info.mode = S_IRWU_RG_RO
tfile.addfile(tarinfo=tar_info, fileobj=b_io)
concrete_artifact_cm = collection.concrete_artifact_manager.ConcreteArtifactsManager(test_dir, validate_certs=False)
@@ -551,7 +550,7 @@ def test_build_requirement_from_name_missing(galaxy_server, monkeypatch, tmp_pat
def test_build_requirement_from_name_401_unauthorized(galaxy_server, monkeypatch, tmp_path_factory):
mock_open = MagicMock()
- mock_open.side_effect = api.GalaxyError(urllib_error.HTTPError('https://galaxy.server.com', 401, 'msg', {},
+ mock_open.side_effect = api.GalaxyError(urllib.error.HTTPError('https://galaxy.server.com', 401, 'msg', {},
StringIO()), "error")
monkeypatch.setattr(galaxy_server, 'get_collection_versions', mock_open)
@@ -786,9 +785,9 @@ def test_install_collection(collection_artifact, monkeypatch):
assert actual_files == [b'FILES.json', b'MANIFEST.json', b'README.md', b'docs', b'playbooks', b'plugins', b'roles',
b'runme.sh']
- assert stat.S_IMODE(os.stat(os.path.join(collection_path, b'plugins')).st_mode) == 0o0755
- assert stat.S_IMODE(os.stat(os.path.join(collection_path, b'README.md')).st_mode) == 0o0644
- assert stat.S_IMODE(os.stat(os.path.join(collection_path, b'runme.sh')).st_mode) == 0o0755
+ assert stat.S_IMODE(os.stat(os.path.join(collection_path, b'plugins')).st_mode) == S_IRWXU_RXG_RXO
+ assert stat.S_IMODE(os.stat(os.path.join(collection_path, b'README.md')).st_mode) == S_IRWU_RG_RO
+ assert stat.S_IMODE(os.stat(os.path.join(collection_path, b'runme.sh')).st_mode) == S_IRWXU_RXG_RXO
assert mock_display.call_count == 2
assert mock_display.mock_calls[0][1][0] == "Installing 'ansible_namespace.collection:0.1.0' to '%s'" \
diff --git a/test/units/galaxy/test_role_install.py b/test/units/galaxy/test_role_install.py
index 819ed18..25dff80 100644
--- a/test/units/galaxy/test_role_install.py
+++ b/test/units/galaxy/test_role_install.py
@@ -2,9 +2,7 @@
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/units/galaxy/test_role_requirements.py b/test/units/galaxy/test_role_requirements.py
index a84bbb5..6b7011a 100644
--- a/test/units/galaxy/test_role_requirements.py
+++ b/test/units/galaxy/test_role_requirements.py
@@ -2,9 +2,7 @@
# Copyright: (c) 2020, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/galaxy/test_token.py b/test/units/galaxy/test_token.py
index 9fc12d4..a02076e 100644
--- a/test/units/galaxy/test_token.py
+++ b/test/units/galaxy/test_token.py
@@ -2,9 +2,7 @@
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import pytest
diff --git a/test/units/galaxy/test_user_agent.py b/test/units/galaxy/test_user_agent.py
index da0103f..f771324 100644
--- a/test/units/galaxy/test_user_agent.py
+++ b/test/units/galaxy/test_user_agent.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import platform
diff --git a/test/units/inventory/test_group.py b/test/units/inventory/test_group.py
index e8f1c0b..5a9d540 100644
--- a/test/units/inventory/test_group.py
+++ b/test/units/inventory/test_group.py
@@ -15,10 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from ansible.inventory.group import Group
from ansible.inventory.host import Host
diff --git a/test/units/inventory/test_host.py b/test/units/inventory/test_host.py
index 712ed30..34eaaab 100644
--- a/test/units/inventory/test_host.py
+++ b/test/units/inventory/test_host.py
@@ -17,16 +17,14 @@
# for __setstate__/__getstate__ tests
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pickle
-from units.compat import unittest
+import unittest
from ansible.inventory.group import Group
from ansible.inventory.host import Host
-from ansible.module_utils.six import string_types
class TestHost(unittest.TestCase):
@@ -51,7 +49,7 @@ class TestHost(unittest.TestCase):
def test_repr(self):
host_repr = repr(self.hostA)
- self.assertIsInstance(host_repr, string_types)
+ self.assertIsInstance(host_repr, str)
def test_add_group(self):
group = Group('some_group')
diff --git a/test/units/mock/loader.py b/test/units/mock/loader.py
index 9dc32ca..ee52e33 100644
--- a/test/units/mock/loader.py
+++ b/test/units/mock/loader.py
@@ -15,9 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
@@ -37,7 +35,7 @@ class DictDataLoader(DataLoader):
self._build_known_directories()
self._vault_secrets = None
- def load_from_file(self, path, cache=True, unsafe=False):
+ def load_from_file(self, path, cache='all', unsafe=False):
data = None
path = to_text(path)
if path in self._file_mapping:
diff --git a/test/units/mock/path.py b/test/units/mock/path.py
index c24ddf4..09bedae 100644
--- a/test/units/mock/path.py
+++ b/test/units/mock/path.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from unittest.mock import MagicMock
from ansible.utils.path import unfrackpath
diff --git a/test/units/mock/procenv.py b/test/units/mock/procenv.py
index 1570c87..f82f435 100644
--- a/test/units/mock/procenv.py
+++ b/test/units/mock/procenv.py
@@ -16,17 +16,14 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import sys
import json
from contextlib import contextmanager
from io import BytesIO, StringIO
-from units.compat import unittest
-from ansible.module_utils.six import PY3
+import unittest
from ansible.module_utils.common.text.converters import to_bytes
@@ -38,11 +35,8 @@ def swap_stdin_and_argv(stdin_data='', argv_data=tuple()):
real_stdin = sys.stdin
real_argv = sys.argv
- if PY3:
- fake_stream = StringIO(stdin_data)
- fake_stream.buffer = BytesIO(to_bytes(stdin_data))
- else:
- fake_stream = BytesIO(to_bytes(stdin_data))
+ fake_stream = StringIO(stdin_data)
+ fake_stream.buffer = BytesIO(to_bytes(stdin_data))
try:
sys.stdin = fake_stream
diff --git a/test/units/mock/vault_helper.py b/test/units/mock/vault_helper.py
index 5b2fdd2..1b40e38 100644
--- a/test/units/mock/vault_helper.py
+++ b/test/units/mock/vault_helper.py
@@ -11,9 +11,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.common.text.converters import to_bytes
diff --git a/test/units/mock/yaml_helper.py b/test/units/mock/yaml_helper.py
index 9f8b063..0f8b2b9 100644
--- a/test/units/mock/yaml_helper.py
+++ b/test/units/mock/yaml_helper.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import io
import yaml
diff --git a/test/units/module_utils/basic/test__log_invocation.py b/test/units/module_utils/basic/test__log_invocation.py
index 3beda8b..7936833 100644
--- a/test/units/module_utils/basic/test__log_invocation.py
+++ b/test/units/module_utils/basic/test__log_invocation.py
@@ -3,8 +3,7 @@
# (c) 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/basic/test__symbolic_mode_to_octal.py b/test/units/module_utils/basic/test__symbolic_mode_to_octal.py
index b3a73e5..e72f9e1 100644
--- a/test/units/module_utils/basic/test__symbolic_mode_to_octal.py
+++ b/test/units/module_utils/basic/test__symbolic_mode_to_octal.py
@@ -4,9 +4,7 @@
# (c) 2016-2017 Ansible Project
# License: GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/basic/test_argument_spec.py b/test/units/module_utils/basic/test_argument_spec.py
index 5dbaf50..f75883a 100644
--- a/test/units/module_utils/basic/test_argument_spec.py
+++ b/test/units/module_utils/basic/test_argument_spec.py
@@ -4,21 +4,19 @@
# Copyright: Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import json
import os
import pytest
-from units.compat.mock import MagicMock
+from unittest.mock import MagicMock
from ansible.module_utils import basic
from ansible.module_utils.api import basic_auth_argument_spec, rate_limit_argument_spec, retry_argument_spec
from ansible.module_utils.common import warnings
from ansible.module_utils.common.warnings import get_deprecation_messages, get_warning_messages
-from ansible.module_utils.six import integer_types, string_types
-from ansible.module_utils.six.moves import builtins
+import builtins
MOCK_VALIDATOR_FAIL = MagicMock(side_effect=TypeError("bad conversion"))
@@ -67,6 +65,8 @@ VALID_SPECS = (
({'arg': {'type': 'list', 'elements': 'str'}}, {'arg': [42, 32]}, ['42', '32']),
# parameter is required
({'arg': {'required': True}}, {'arg': 42}, '42'),
+ # ignored unknown parameters
+ ({'arg': {'type': 'int'}}, {'arg': 1, 'invalid': True, '_ansible_ignore_unknown_opts': True}, 1),
)
INVALID_SPECS = (
@@ -215,7 +215,7 @@ def test_validator_basic_types(argspec, expected, stdin):
if 'type' in argspec['arg']:
if argspec['arg']['type'] == 'int':
- type_ = integer_types
+ type_ = int
else:
type_ = getattr(builtins, argspec['arg']['type'])
else:
@@ -232,7 +232,7 @@ def test_validator_function(mocker, stdin):
argspec = {'arg': {'type': MOCK_VALIDATOR_SUCCESS}}
am = basic.AnsibleModule(argspec)
- assert isinstance(am.params['arg'], integer_types)
+ assert isinstance(am.params['arg'], int)
assert am.params['arg'] == 27
@@ -242,9 +242,9 @@ def test_validate_basic_auth_arg(mocker, stdin):
argument_spec=basic_auth_argument_spec()
)
am = basic.AnsibleModule(**kwargs)
- assert isinstance(am.params['api_username'], string_types)
- assert isinstance(am.params['api_password'], string_types)
- assert isinstance(am.params['api_url'], string_types)
+ assert isinstance(am.params['api_username'], str)
+ assert isinstance(am.params['api_password'], str)
+ assert isinstance(am.params['api_url'], str)
assert isinstance(am.params['validate_certs'], bool)
@@ -254,8 +254,8 @@ def test_validate_rate_limit_argument_spec(mocker, stdin):
argument_spec=rate_limit_argument_spec()
)
am = basic.AnsibleModule(**kwargs)
- assert isinstance(am.params['rate'], integer_types)
- assert isinstance(am.params['rate_limit'], integer_types)
+ assert isinstance(am.params['rate'], int)
+ assert isinstance(am.params['rate_limit'], int)
@pytest.mark.parametrize('stdin', RETRY_VALID_ARGS, indirect=['stdin'])
@@ -264,7 +264,7 @@ def test_validate_retry_argument_spec(mocker, stdin):
argument_spec=retry_argument_spec()
)
am = basic.AnsibleModule(**kwargs)
- assert isinstance(am.params['retries'], integer_types)
+ assert isinstance(am.params['retries'], int)
assert isinstance(am.params['retry_pause'], float)
@@ -274,7 +274,7 @@ def test_validator_string_type(mocker, stdin):
argspec = {'arg': {'type': str}}
am = basic.AnsibleModule(argspec)
- assert isinstance(am.params['arg'], string_types)
+ assert isinstance(am.params['arg'], str)
assert am.params['arg'] == '123'
@@ -415,8 +415,8 @@ class TestComplexArgSpecs:
"""Test choices with list"""
am = basic.AnsibleModule(**complex_argspec)
assert isinstance(am.params['bar_str'], list)
- assert isinstance(am.params['bar_str'][0], string_types)
- assert isinstance(am.params['bar_str'][1], string_types)
+ assert isinstance(am.params['bar_str'][0], str)
+ assert isinstance(am.params['bar_str'][1], str)
assert am.params['bar_str'][0] == '867'
assert am.params['bar_str'][1] == '5309'
diff --git a/test/units/module_utils/basic/test_atomic_move.py b/test/units/module_utils/basic/test_atomic_move.py
index bbdb051..927ed3e 100644
--- a/test/units/module_utils/basic/test_atomic_move.py
+++ b/test/units/module_utils/basic/test_atomic_move.py
@@ -4,8 +4,7 @@
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import os
import errno
@@ -15,6 +14,7 @@ from itertools import product
import pytest
from ansible.module_utils import basic
+from ansible.module_utils.common.file import S_IRWU_RG_RO
@pytest.fixture
@@ -32,6 +32,7 @@ def atomic_am(am, mocker):
def atomic_mocks(mocker, monkeypatch):
environ = dict()
mocks = {
+ 'copystat': mocker.patch('shutil.copystat'),
'chmod': mocker.patch('os.chmod'),
'chown': mocker.patch('os.chown'),
'close': mocker.patch('os.close'),
@@ -64,7 +65,7 @@ def atomic_mocks(mocker, monkeypatch):
@pytest.fixture
def fake_stat(mocker):
stat1 = mocker.MagicMock()
- stat1.st_mode = 0o0644
+ stat1.st_mode = S_IRWU_RG_RO
stat1.st_uid = 0
stat1.st_gid = 0
stat1.st_flags = 0
@@ -102,7 +103,7 @@ def test_existing_file(atomic_am, atomic_mocks, fake_stat, mocker, selinux):
atomic_am.atomic_move('/path/to/src', '/path/to/dest')
atomic_mocks['rename'].assert_called_with(b'/path/to/src', b'/path/to/dest')
- assert atomic_mocks['chmod'].call_args_list == [mocker.call(b'/path/to/src', basic.DEFAULT_PERM & ~18)]
+ assert atomic_mocks['copystat'].call_args_list == [mocker.call(b'/path/to/dest', b'/path/to/src')]
if selinux:
assert atomic_am.set_context_if_different.call_args_list == [mocker.call('/path/to/dest', mock_context, False)]
@@ -125,7 +126,8 @@ def test_no_tty_fallback(atomic_am, atomic_mocks, fake_stat, mocker):
atomic_am.atomic_move('/path/to/src', '/path/to/dest')
atomic_mocks['rename'].assert_called_with(b'/path/to/src', b'/path/to/dest')
- assert atomic_mocks['chmod'].call_args_list == [mocker.call(b'/path/to/src', basic.DEFAULT_PERM & ~18)]
+ assert atomic_mocks['copystat'].call_args_list == [mocker.call(b'/path/to/dest', b'/path/to/src')]
+ assert atomic_mocks['chmod'].call_args_list == []
assert atomic_am.set_context_if_different.call_args_list == [mocker.call('/path/to/dest', mock_context, False)]
assert atomic_am.selinux_context.call_args_list == [mocker.call('/path/to/dest')]
@@ -134,19 +136,19 @@ def test_no_tty_fallback(atomic_am, atomic_mocks, fake_stat, mocker):
@pytest.mark.parametrize('stdin', [{}], indirect=['stdin'])
def test_existing_file_stat_failure(atomic_am, atomic_mocks, mocker):
"""Failure to stat an existing file in order to copy permissions propogates the error (unless EPERM)"""
- atomic_mocks['stat'].side_effect = OSError()
+ atomic_mocks['copystat'].side_effect = FileNotFoundError('testing os copystat with non EPERM error')
atomic_mocks['path_exists'].return_value = True
- with pytest.raises(OSError):
+ with pytest.raises(FileNotFoundError, match='testing os copystat with non EPERM error'):
atomic_am.atomic_move('/path/to/src', '/path/to/dest')
@pytest.mark.parametrize('stdin', [{}], indirect=['stdin'])
def test_existing_file_stat_perms_failure(atomic_am, atomic_mocks, mocker):
"""Failure to stat an existing file to copy the permissions due to permissions passes fine"""
- # and now have os.stat return EPERM, which should not fail
+ # and now have os.copystat return EPERM, which should not fail
mock_context = atomic_am.selinux_context.return_value
- atomic_mocks['stat'].side_effect = OSError(errno.EPERM, 'testing os stat with EPERM')
+ atomic_mocks['copystat'].side_effect = OSError(errno.EPERM, 'testing os copystat with EPERM')
atomic_mocks['path_exists'].return_value = True
atomic_am.selinux_enabled.return_value = True
@@ -155,7 +157,7 @@ def test_existing_file_stat_perms_failure(atomic_am, atomic_mocks, mocker):
atomic_mocks['rename'].assert_called_with(b'/path/to/src', b'/path/to/dest')
# FIXME: Should atomic_move() set a default permission value when it cannot retrieve the
# existing file's permissions? (Right now it's up to the calling code.
- # assert atomic_mocks['chmod'].call_args_list == [mocker.call(b'/path/to/src', basic.DEFAULT_PERM & ~18)]
+ assert atomic_mocks['copystat'].call_args_list == [mocker.call(b'/path/to/dest', b'/path/to/src')]
assert atomic_am.set_context_if_different.call_args_list == [mocker.call('/path/to/dest', mock_context, False)]
assert atomic_am.selinux_context.call_args_list == [mocker.call('/path/to/dest')]
@@ -203,8 +205,6 @@ def test_rename_perms_fail_temp_succeeds(atomic_am, atomic_mocks, fake_stat, moc
mock_context = atomic_am.selinux_default_context.return_value
atomic_mocks['path_exists'].return_value = False
atomic_mocks['rename'].side_effect = [OSError(errno.EPERM, 'failing with EPERM'), None]
- atomic_mocks['stat'].return_value = fake_stat
- atomic_mocks['stat'].side_effect = None
atomic_mocks['mkstemp'].return_value = (None, '/path/to/tempfile')
atomic_mocks['mkstemp'].side_effect = None
atomic_am.selinux_enabled.return_value = selinux
diff --git a/test/units/module_utils/basic/test_command_nonexisting.py b/test/units/module_utils/basic/test_command_nonexisting.py
index 0dd3bd9..c995745 100644
--- a/test/units/module_utils/basic/test_command_nonexisting.py
+++ b/test/units/module_utils/basic/test_command_nonexisting.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import sys
diff --git a/test/units/module_utils/basic/test_deprecate_warn.py b/test/units/module_utils/basic/test_deprecate_warn.py
index 581ba6d..7a54264 100644
--- a/test/units/module_utils/basic/test_deprecate_warn.py
+++ b/test/units/module_utils/basic/test_deprecate_warn.py
@@ -3,8 +3,7 @@
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/units/module_utils/basic/test_dict_converters.py b/test/units/module_utils/basic/test_dict_converters.py
index f63ed9c..2c32f48 100644
--- a/test/units/module_utils/basic/test_dict_converters.py
+++ b/test/units/module_utils/basic/test_dict_converters.py
@@ -4,12 +4,11 @@
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from units.mock.procenv import ModuleTestCase
-from ansible.module_utils.six.moves import builtins
+import builtins
realimport = builtins.__import__
diff --git a/test/units/module_utils/basic/test_exit_json.py b/test/units/module_utils/basic/test_exit_json.py
index 4afcb27..ef44cec 100644
--- a/test/units/module_utils/basic/test_exit_json.py
+++ b/test/units/module_utils/basic/test_exit_json.py
@@ -2,9 +2,7 @@
# Copyright (c) 2015-2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import sys
@@ -102,9 +100,7 @@ class TestAnsibleModuleExitJson:
with pytest.raises(TypeError) as ctx:
am.fail_json()
- if sys.version_info < (3,):
- error_msg = "fail_json() takes exactly 2 arguments (1 given)"
- elif sys.version_info >= (3, 10):
+ if sys.version_info >= (3, 10):
error_msg = "AnsibleModule.fail_json() missing 1 required positional argument: 'msg'"
else:
error_msg = "fail_json() missing 1 required positional argument: 'msg'"
diff --git a/test/units/module_utils/basic/test_filesystem.py b/test/units/module_utils/basic/test_filesystem.py
index 50e674c..9991b76 100644
--- a/test/units/module_utils/basic/test_filesystem.py
+++ b/test/units/module_utils/basic/test_filesystem.py
@@ -4,13 +4,12 @@
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from units.mock.procenv import ModuleTestCase
-from units.compat.mock import patch, MagicMock
-from ansible.module_utils.six.moves import builtins
+from unittest.mock import patch, MagicMock
+import builtins
realimport = builtins.__import__
@@ -50,8 +49,6 @@ class TestOtherFilesystem(ModuleTestCase):
def _mock_ismount(path):
if path == b'/subdir/mount':
return True
- if path == b'/':
- return True
return False
with patch('os.path.ismount', side_effect=_mock_ismount):
diff --git a/test/units/module_utils/basic/test_get_available_hash_algorithms.py b/test/units/module_utils/basic/test_get_available_hash_algorithms.py
index d60f34c..e7fb76b 100644
--- a/test/units/module_utils/basic/test_get_available_hash_algorithms.py
+++ b/test/units/module_utils/basic/test_get_available_hash_algorithms.py
@@ -1,18 +1,10 @@
"""Unit tests to provide coverage not easily obtained from integration tests."""
-from __future__ import (absolute_import, division, print_function)
-
-__metaclass__ = type
-
-import hashlib
-import sys
-
-import pytest
+from __future__ import annotations
from ansible.module_utils.basic import _get_available_hash_algorithms
-@pytest.mark.skipif(sys.version_info < (2, 7, 9), reason="requires Python 2.7.9 or later")
def test_unavailable_algorithm(mocker):
"""Simulate an available algorithm that isn't."""
expected_algorithms = {'sha256', 'sha512'} # guaranteed to be available
@@ -24,7 +16,6 @@ def test_unavailable_algorithm(mocker):
assert sorted(expected_algorithms) == sorted(available_algorithms)
-@pytest.mark.skipif(sys.version_info < (2, 7, 9), reason="requires Python 2.7.9 or later")
def test_fips_mode(mocker):
"""Simulate running in FIPS mode on Python 2.7.9 or later."""
expected_algorithms = {'sha256', 'sha512'} # guaranteed to be available
@@ -35,26 +26,3 @@ def test_fips_mode(mocker):
available_algorithms = _get_available_hash_algorithms()
assert sorted(expected_algorithms) == sorted(available_algorithms)
-
-
-@pytest.mark.skipif(sys.version_info < (2, 7, 9) or sys.version_info[:2] != (2, 7), reason="requires Python 2.7 (2.7.9 or later)")
-def test_legacy_python(mocker):
- """Simulate behavior on Python 2.7.x earlier than Python 2.7.9."""
- expected_algorithms = {'sha256', 'sha512'} # guaranteed to be available
-
- # This attribute is exclusive to Python 2.7.
- # Since `hashlib.algorithms_available` is used on Python 2.7.9 and later, only Python 2.7.0 through 2.7.8 utilize this attribute.
- mocker.patch('hashlib.algorithms', expected_algorithms)
-
- saved_algorithms = hashlib.algorithms_available
-
- # Make sure that this attribute is unavailable, to simulate running on Python 2.7.0 through 2.7.8.
- # It will be restored immediately after performing the test.
- del hashlib.algorithms_available
-
- try:
- available_algorithms = _get_available_hash_algorithms()
- finally:
- hashlib.algorithms_available = saved_algorithms
-
- assert sorted(expected_algorithms) == sorted(available_algorithms)
diff --git a/test/units/module_utils/basic/test_get_file_attributes.py b/test/units/module_utils/basic/test_get_file_attributes.py
index 836529c..df41af7 100644
--- a/test/units/module_utils/basic/test_get_file_attributes.py
+++ b/test/units/module_utils/basic/test_get_file_attributes.py
@@ -3,9 +3,7 @@
# (c) 2017, Pierre-Louis Bonicoli <pierre-louis@libregerbil.fr>
# License: GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from itertools import product
diff --git a/test/units/module_utils/basic/test_get_module_path.py b/test/units/module_utils/basic/test_get_module_path.py
index 6ff4a3b..4b8fb78 100644
--- a/test/units/module_utils/basic/test_get_module_path.py
+++ b/test/units/module_utils/basic/test_get_module_path.py
@@ -4,13 +4,12 @@
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from units.mock.procenv import ModuleTestCase
-from units.compat.mock import patch
-from ansible.module_utils.six.moves import builtins
+from unittest.mock import patch
+import builtins
realimport = builtins.__import__
diff --git a/test/units/module_utils/basic/test_heuristic_log_sanitize.py b/test/units/module_utils/basic/test_heuristic_log_sanitize.py
index 664b8a5..2c4eefb 100644
--- a/test/units/module_utils/basic/test_heuristic_log_sanitize.py
+++ b/test/units/module_utils/basic/test_heuristic_log_sanitize.py
@@ -16,11 +16,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from ansible.module_utils.basic import heuristic_log_sanitize
diff --git a/test/units/module_utils/basic/test_imports.py b/test/units/module_utils/basic/test_imports.py
index d1a5f37..2e12296 100644
--- a/test/units/module_utils/basic/test_imports.py
+++ b/test/units/module_utils/basic/test_imports.py
@@ -4,16 +4,14 @@
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import sys
from units.mock.procenv import ModuleTestCase
-from units.compat import unittest
-from units.compat.mock import patch
-from ansible.module_utils.six.moves import builtins
+from unittest.mock import patch
+import builtins
realimport = builtins.__import__
@@ -61,20 +59,6 @@ class TestImports(ModuleTestCase):
mod = builtins.__import__('ansible.module_utils.basic')
self.assertFalse(mod.module_utils.basic.HAVE_SELINUX)
- @patch.object(builtins, '__import__')
- def test_module_utils_basic_import_json(self, mock_import):
- def _mock_import(name, *args, **kwargs):
- if name == 'ansible.module_utils.common._json_compat':
- raise ImportError
- return realimport(name, *args, **kwargs)
-
- self.clear_modules(['json', 'ansible.module_utils.basic'])
- builtins.__import__('ansible.module_utils.basic')
- self.clear_modules(['json', 'ansible.module_utils.basic'])
- mock_import.side_effect = _mock_import
- with self.assertRaises(SystemExit):
- builtins.__import__('ansible.module_utils.basic')
-
# FIXME: doesn't work yet
# @patch.object(builtins, 'bytes')
# def test_module_utils_basic_bytes(self, mock_bytes):
@@ -82,32 +66,6 @@ class TestImports(ModuleTestCase):
# from ansible.module_utils import basic
@patch.object(builtins, '__import__')
- @unittest.skipIf(sys.version_info[0] >= 3, "literal_eval is available in every version of Python3")
- def test_module_utils_basic_import_literal_eval(self, mock_import):
- def _mock_import(name, *args, **kwargs):
- try:
- fromlist = kwargs.get('fromlist', args[2])
- except IndexError:
- fromlist = []
- if name == 'ast' and 'literal_eval' in fromlist:
- raise ImportError
- return realimport(name, *args, **kwargs)
-
- mock_import.side_effect = _mock_import
- self.clear_modules(['ast', 'ansible.module_utils.basic'])
- mod = builtins.__import__('ansible.module_utils.basic')
- self.assertEqual(mod.module_utils.basic.literal_eval("'1'"), "1")
- self.assertEqual(mod.module_utils.basic.literal_eval("1"), 1)
- self.assertEqual(mod.module_utils.basic.literal_eval("-1"), -1)
- self.assertEqual(mod.module_utils.basic.literal_eval("(1,2,3)"), (1, 2, 3))
- self.assertEqual(mod.module_utils.basic.literal_eval("[1]"), [1])
- self.assertEqual(mod.module_utils.basic.literal_eval("True"), True)
- self.assertEqual(mod.module_utils.basic.literal_eval("False"), False)
- self.assertEqual(mod.module_utils.basic.literal_eval("None"), None)
- # self.assertEqual(mod.module_utils.basic.literal_eval('{"a": 1}'), dict(a=1))
- self.assertRaises(ValueError, mod.module_utils.basic.literal_eval, "asdfasdfasdf")
-
- @patch.object(builtins, '__import__')
def test_module_utils_basic_import_systemd_journal(self, mock_import):
def _mock_import(name, *args, **kwargs):
try:
diff --git a/test/units/module_utils/basic/test_log.py b/test/units/module_utils/basic/test_log.py
index f3f764f..59fde23 100644
--- a/test/units/module_utils/basic/test_log.py
+++ b/test/units/module_utils/basic/test_log.py
@@ -3,17 +3,13 @@
# (c) 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import syslog
from itertools import product
import pytest
-import ansible.module_utils.basic
-from ansible.module_utils.six import PY3
-
class TestAnsibleModuleLogSmokeTest:
DATA = [u'Text string', u'Toshio ãらã¨ã¿ non-ascii test']
@@ -35,35 +31,11 @@ class TestAnsibleModuleLogSmokeTest:
am.log(u'Toshio ãらã¨ã¿ non-ascii test'.encode('utf-8'))
am.log(b'non-utf8 :\xff: test')
- @pytest.mark.skipif(not ansible.module_utils.basic.has_journal, reason='python systemd bindings not installed')
- # pylint bug: https://github.com/PyCQA/pylint/issues/511
- @pytest.mark.parametrize('msg, stdin', ((m, {}) for m in DATA), indirect=['stdin']) # pylint: disable=undefined-variable
- def test_smoketest_journal(self, am, mocker, msg):
- # These talk to the live daemons on the system. Need to do this to
- # show that what we send doesn't cause an issue once it gets to the
- # daemon. These are just smoketests to test that we don't fail.
- mocker.patch('ansible.module_utils.basic.has_journal', True)
-
- am.log(u'Text string')
- am.log(u'Toshio ãらã¨ã¿ non-ascii test')
-
- am.log(b'Byte string')
- am.log(u'Toshio ãらã¨ã¿ non-ascii test'.encode('utf-8'))
- am.log(b'non-utf8 :\xff: test')
-
class TestAnsibleModuleLogSyslog:
"""Test the AnsibleModule Log Method"""
- PY2_OUTPUT_DATA = [
- (u'Text string', b'Text string'),
- (u'Toshio ãらã¨ã¿ non-ascii test', u'Toshio ãらã¨ã¿ non-ascii test'.encode('utf-8')),
- (b'Byte string', b'Byte string'),
- (u'Toshio ãらã¨ã¿ non-ascii test'.encode('utf-8'), u'Toshio ãらã¨ã¿ non-ascii test'.encode('utf-8')),
- (b'non-utf8 :\xff: test', b'non-utf8 :\xff: test'.decode('utf-8', 'replace').encode('utf-8')),
- ]
-
- PY3_OUTPUT_DATA = [
+ OUTPUT_DATA = [
(u'Text string', u'Text string'),
(u'Toshio ãらã¨ã¿ non-ascii test', u'Toshio ãらã¨ã¿ non-ascii test'),
(b'Byte string', u'Byte string'),
@@ -71,8 +43,6 @@ class TestAnsibleModuleLogSyslog:
(b'non-utf8 :\xff: test', b'non-utf8 :\xff: test'.decode('utf-8', 'replace')),
]
- OUTPUT_DATA = PY3_OUTPUT_DATA if PY3 else PY2_OUTPUT_DATA
-
@pytest.mark.parametrize('no_log, stdin', (product((True, False), [{}])), indirect=['stdin'])
def test_no_log(self, am, mocker, no_log):
"""Test that when no_log is set, logging does not occur"""
@@ -96,57 +66,3 @@ class TestAnsibleModuleLogSyslog:
am.log(msg)
mock_syslog.assert_called_once_with(syslog.LOG_INFO, param)
-
-
-@pytest.mark.skipif(not ansible.module_utils.basic.has_journal, reason='python systemd bindings not installed')
-class TestAnsibleModuleLogJournal:
- """Test the AnsibleModule Log Method"""
-
- OUTPUT_DATA = [
- (u'Text string', u'Text string'),
- (u'Toshio ãらã¨ã¿ non-ascii test', u'Toshio ãらã¨ã¿ non-ascii test'),
- (b'Byte string', u'Byte string'),
- (u'Toshio ãらã¨ã¿ non-ascii test'.encode('utf-8'), u'Toshio ãらã¨ã¿ non-ascii test'),
- (b'non-utf8 :\xff: test', b'non-utf8 :\xff: test'.decode('utf-8', 'replace')),
- ]
-
- @pytest.mark.parametrize('no_log, stdin', (product((True, False), [{}])), indirect=['stdin'])
- def test_no_log(self, am, mocker, no_log):
- journal_send = mocker.patch('systemd.journal.send')
- am.no_log = no_log
- am.log('unittest no_log')
- if no_log:
- assert not journal_send.called
- else:
- assert journal_send.called == 1
- # Message
- # call_args is a 2-tuple of (arg_list, kwarg_dict)
- assert journal_send.call_args[1]['MESSAGE'].endswith('unittest no_log'), 'Message was not sent to log'
- # log adds this journal field
- assert 'MODULE' in journal_send.call_args[1]
- assert 'basic.py' in journal_send.call_args[1]['MODULE']
-
- # pylint bug: https://github.com/PyCQA/pylint/issues/511
- @pytest.mark.parametrize('msg, param, stdin',
- ((m, p, {}) for m, p in OUTPUT_DATA), # pylint: disable=undefined-variable
- indirect=['stdin'])
- def test_output_matches(self, am, mocker, msg, param):
- journal_send = mocker.patch('systemd.journal.send')
- am.log(msg)
- assert journal_send.call_count == 1, 'journal.send not called exactly once'
- assert journal_send.call_args[1]['MESSAGE'].endswith(param)
-
- @pytest.mark.parametrize('stdin', ({},), indirect=['stdin'])
- def test_log_args(self, am, mocker):
- journal_send = mocker.patch('systemd.journal.send')
- am.log('unittest log_args', log_args=dict(TEST='log unittest'))
- assert journal_send.called == 1
- assert journal_send.call_args[1]['MESSAGE'].endswith('unittest log_args'), 'Message was not sent to log'
-
- # log adds this journal field
- assert 'MODULE' in journal_send.call_args[1]
- assert 'basic.py' in journal_send.call_args[1]['MODULE']
-
- # We added this journal field
- assert 'TEST' in journal_send.call_args[1]
- assert 'log unittest' in journal_send.call_args[1]['TEST']
diff --git a/test/units/module_utils/basic/test_no_log.py b/test/units/module_utils/basic/test_no_log.py
index c479702..c8c3ece 100644
--- a/test/units/module_utils/basic/test_no_log.py
+++ b/test/units/module_utils/basic/test_no_log.py
@@ -3,10 +3,9 @@
# (c) 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from ansible.module_utils.basic import remove_values
from ansible.module_utils.common.parameters import _return_datastructure_name
@@ -147,7 +146,7 @@ class TestRemoveValues(unittest.TestCase):
levels = 0
inner_list = actual_data_list
- while inner_list:
+ while True:
if isinstance(inner_list, list):
self.assertEqual(len(inner_list), 1)
else:
diff --git a/test/units/module_utils/basic/test_platform_distribution.py b/test/units/module_utils/basic/test_platform_distribution.py
index 3c1afb7..4ddb2f8 100644
--- a/test/units/module_utils/basic/test_platform_distribution.py
+++ b/test/units/module_utils/basic/test_platform_distribution.py
@@ -4,14 +4,13 @@
# (c) 2017-2018 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
-from units.compat.mock import patch
+from unittest.mock import patch
-from ansible.module_utils.six.moves import builtins
+import builtins
# Functions being tested
from ansible.module_utils.basic import get_platform
diff --git a/test/units/module_utils/basic/test_run_command.py b/test/units/module_utils/basic/test_run_command.py
index 259ac6c..2f77d5f 100644
--- a/test/units/module_utils/basic/test_run_command.py
+++ b/test/units/module_utils/basic/test_run_command.py
@@ -2,19 +2,15 @@
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-import errno
+import selectors
from itertools import product
from io import BytesIO
import pytest
from ansible.module_utils.common.text.converters import to_native
-from ansible.module_utils.six import PY2
-from ansible.module_utils.compat import selectors
class OpenBytesIO(BytesIO):
@@ -29,10 +25,6 @@ class OpenBytesIO(BytesIO):
@pytest.fixture
def mock_os(mocker):
- def mock_os_chdir(path):
- if path == '/inaccessible':
- raise OSError(errno.EPERM, "Permission denied: '/inaccessible'")
-
def mock_os_abspath(path):
if path.startswith('/'):
return path
@@ -46,17 +38,11 @@ def mock_os(mocker):
os.environ = {'PATH': '/bin'}
os.getcwd.return_value = '/home/foo'
os.path.isdir.return_value = True
- os.chdir.side_effect = mock_os_chdir
os.path.abspath.side_effect = mock_os_abspath
yield os
-class DummyFileObj():
- def __init__(self, fileobj):
- self.fileobj = fileobj
-
-
class SpecialBytesIO(BytesIO):
def __init__(self, *args, **kwargs):
fh = kwargs.pop('fh', None)
@@ -269,10 +255,5 @@ def test_run_command_fds(mocker, rc_am):
except SystemExit:
pass
- if PY2:
- assert subprocess_mock.Popen.call_args[1]['close_fds'] is False
- assert 'pass_fds' not in subprocess_mock.Popen.call_args[1]
-
- else:
- assert subprocess_mock.Popen.call_args[1]['pass_fds'] == (101, 42)
- assert subprocess_mock.Popen.call_args[1]['close_fds'] is True
+ assert subprocess_mock.Popen.call_args[1]['pass_fds'] == (101, 42)
+ assert subprocess_mock.Popen.call_args[1]['close_fds'] is True
diff --git a/test/units/module_utils/basic/test_safe_eval.py b/test/units/module_utils/basic/test_safe_eval.py
index fdaab18..62403e8 100644
--- a/test/units/module_utils/basic/test_safe_eval.py
+++ b/test/units/module_utils/basic/test_safe_eval.py
@@ -2,9 +2,7 @@
# (c) 2015-2017, Toshio Kuratomi <tkuratomi@ansible.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from itertools import chain
import pytest
diff --git a/test/units/module_utils/basic/test_sanitize_keys.py b/test/units/module_utils/basic/test_sanitize_keys.py
index 3edb216..3b66f83 100644
--- a/test/units/module_utils/basic/test_sanitize_keys.py
+++ b/test/units/module_utils/basic/test_sanitize_keys.py
@@ -2,9 +2,7 @@
# (c) 2020, Red Hat
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.basic import sanitize_keys
diff --git a/test/units/module_utils/basic/test_selinux.py b/test/units/module_utils/basic/test_selinux.py
index bdb6b9d..7d9e9bb 100644
--- a/test/units/module_utils/basic/test_selinux.py
+++ b/test/units/module_utils/basic/test_selinux.py
@@ -4,18 +4,17 @@
# (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import errno
import json
import pytest
-from units.compat.mock import mock_open, patch
+from unittest.mock import mock_open, patch
from ansible.module_utils import basic
from ansible.module_utils.common.text.converters import to_bytes
-from ansible.module_utils.six.moves import builtins
+import builtins
@pytest.fixture
diff --git a/test/units/module_utils/basic/test_set_cwd.py b/test/units/module_utils/basic/test_set_cwd.py
index c094c62..b060b50 100644
--- a/test/units/module_utils/basic/test_set_cwd.py
+++ b/test/units/module_utils/basic/test_set_cwd.py
@@ -2,15 +2,13 @@
# Copyright (c) 2018 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import os
import tempfile
-from units.compat.mock import patch
+from unittest.mock import patch
from ansible.module_utils.common.text.converters import to_bytes
from ansible.module_utils import basic
diff --git a/test/units/module_utils/basic/test_set_mode_if_different.py b/test/units/module_utils/basic/test_set_mode_if_different.py
index 5fec331..4566660 100644
--- a/test/units/module_utils/basic/test_set_mode_if_different.py
+++ b/test/units/module_utils/basic/test_set_mode_if_different.py
@@ -3,20 +3,14 @@
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
+import builtins
import errno
import os
from itertools import product
-try:
- import builtins
-except ImportError:
- import __builtin__ as builtins
-
import pytest
diff --git a/test/units/module_utils/basic/test_tmpdir.py b/test/units/module_utils/basic/test_tmpdir.py
index ec12508..65d6801 100644
--- a/test/units/module_utils/basic/test_tmpdir.py
+++ b/test/units/module_utils/basic/test_tmpdir.py
@@ -2,18 +2,15 @@
# Copyright (c) 2018 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import os
-import shutil
import tempfile
import pytest
-from units.compat.mock import patch, MagicMock
+from unittest.mock import patch, MagicMock
from ansible.module_utils.common.text.converters import to_bytes
from ansible.module_utils import basic
@@ -78,7 +75,6 @@ class TestAnsibleModuleTmpDir:
monkeypatch.setattr(tempfile, 'mkdtemp', mock_mkdtemp)
monkeypatch.setattr(os.path, 'exists', lambda x: stat_exists)
monkeypatch.setattr(os, 'makedirs', mock_makedirs)
- monkeypatch.setattr(shutil, 'rmtree', lambda x: None)
monkeypatch.setattr(basic, '_ANSIBLE_ARGS', to_bytes(json.dumps({'ANSIBLE_MODULE_ARGS': args})))
with patch('time.time', return_value=42):
diff --git a/test/units/module_utils/common/arg_spec/test_aliases.py b/test/units/module_utils/common/arg_spec/test_aliases.py
index 7522c76..a7c82b0 100644
--- a/test/units/module_utils/common/arg_spec/test_aliases.py
+++ b/test/units/module_utils/common/arg_spec/test_aliases.py
@@ -2,8 +2,7 @@
# Copyright (c) 2021 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/arg_spec/test_module_validate.py b/test/units/module_utils/common/arg_spec/test_module_validate.py
index 2c2211c..e4af5a2 100644
--- a/test/units/module_utils/common/arg_spec/test_module_validate.py
+++ b/test/units/module_utils/common/arg_spec/test_module_validate.py
@@ -2,8 +2,7 @@
# Copyright (c) 2021 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.common import warnings
diff --git a/test/units/module_utils/common/arg_spec/test_sub_spec.py b/test/units/module_utils/common/arg_spec/test_sub_spec.py
index a6e7575..90b4c37 100644
--- a/test/units/module_utils/common/arg_spec/test_sub_spec.py
+++ b/test/units/module_utils/common/arg_spec/test_sub_spec.py
@@ -2,8 +2,7 @@
# Copyright (c) 2021 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.common.arg_spec import ArgumentSpecValidator, ValidationResult
diff --git a/test/units/module_utils/common/arg_spec/test_validate_invalid.py b/test/units/module_utils/common/arg_spec/test_validate_invalid.py
index 7302e8a..2e90584 100644
--- a/test/units/module_utils/common/arg_spec/test_validate_invalid.py
+++ b/test/units/module_utils/common/arg_spec/test_validate_invalid.py
@@ -2,14 +2,12 @@
# Copyright (c) 2021 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
from ansible.module_utils.common.arg_spec import ArgumentSpecValidator, ValidationResult
from ansible.module_utils.errors import AnsibleValidationErrorMultiple
-from ansible.module_utils.six import PY2
# Each item is id, argument_spec, parameters, expected, unsupported parameters, error test string
@@ -124,9 +122,6 @@ def test_invalid_spec(arg_spec, parameters, expected, unsupported, error):
with pytest.raises(AnsibleValidationErrorMultiple) as exc_info:
raise result.errors
- if PY2:
- error = error.replace('class', 'type')
-
assert isinstance(result, ValidationResult)
assert error in exc_info.value.msg
assert error in result.error_messages[0]
diff --git a/test/units/module_utils/common/arg_spec/test_validate_valid.py b/test/units/module_utils/common/arg_spec/test_validate_valid.py
index 7e41127..1cad3f1 100644
--- a/test/units/module_utils/common/arg_spec/test_validate_valid.py
+++ b/test/units/module_utils/common/arg_spec/test_validate_valid.py
@@ -2,8 +2,7 @@
# Copyright (c) 2021 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/parameters/test_check_arguments.py b/test/units/module_utils/common/parameters/test_check_arguments.py
index 5311217..855eb67 100644
--- a/test/units/module_utils/common/parameters/test_check_arguments.py
+++ b/test/units/module_utils/common/parameters/test_check_arguments.py
@@ -2,13 +2,16 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
-from ansible.module_utils.common.parameters import _get_unsupported_parameters
+from ansible.module_utils.common.parameters import (
+ _get_unsupported_parameters,
+ _validate_argument_values,
+)
+from ansible.module_utils.errors import AnsibleValidationErrorMultiple
@pytest.fixture
@@ -36,3 +39,13 @@ def test_check_arguments(argument_spec, module_parameters, legal_inputs, expecte
result = _get_unsupported_parameters(argument_spec, module_parameters, legal_inputs)
assert result == expected
+
+
+def test_validate_argument_values(mocker):
+ argument_spec = {
+ "foo": {"type": "list", "elements": "int", "choices": [1]},
+ }
+ module_parameters = {"foo": [2]}
+ errors = AnsibleValidationErrorMultiple()
+ result = _validate_argument_values(argument_spec, module_parameters, errors=errors)
+ assert "value of foo must be one" in errors[0].msg
diff --git a/test/units/module_utils/common/parameters/test_handle_aliases.py b/test/units/module_utils/common/parameters/test_handle_aliases.py
index 6a8c2b2..550d10f 100644
--- a/test/units/module_utils/common/parameters/test_handle_aliases.py
+++ b/test/units/module_utils/common/parameters/test_handle_aliases.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/parameters/test_list_deprecations.py b/test/units/module_utils/common/parameters/test_list_deprecations.py
index d667a2f..90bed67 100644
--- a/test/units/module_utils/common/parameters/test_list_deprecations.py
+++ b/test/units/module_utils/common/parameters/test_list_deprecations.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.common.parameters import _list_deprecations
diff --git a/test/units/module_utils/common/parameters/test_list_no_log_values.py b/test/units/module_utils/common/parameters/test_list_no_log_values.py
index ac0e735..555e07b 100644
--- a/test/units/module_utils/common/parameters/test_list_no_log_values.py
+++ b/test/units/module_utils/common/parameters/test_list_no_log_values.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
@@ -79,7 +78,7 @@ def test_list_no_log_values_invalid_suboptions(argument_spec, module_parameters,
}
}
- with pytest.raises(TypeError, match=r"(Value '.*?' in the sub parameter field '.*?' must by a dict, not '.*?')"
+ with pytest.raises(TypeError, match=r"(Value '.*?' in the sub parameter field '.*?' must be a dict, not '.*?')"
r"|(dictionary requested, could not parse JSON or key=value)"):
_list_no_log_values(argument_spec(extra_opts), module_parameters(extra_params))
diff --git a/test/units/module_utils/common/process/test_get_bin_path.py b/test/units/module_utils/common/process/test_get_bin_path.py
index 7c0bd0a..4be95a9 100644
--- a/test/units/module_utils/common/process/test_get_bin_path.py
+++ b/test/units/module_utils/common/process/test_get_bin_path.py
@@ -2,8 +2,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/test_collections.py b/test/units/module_utils/common/test_collections.py
index 8424502..93cf324 100644
--- a/test/units/module_utils/common/test_collections.py
+++ b/test/units/module_utils/common/test_collections.py
@@ -3,12 +3,11 @@
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
"""Test low-level utility functions from ``module_utils.common.collections``."""
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
-from ansible.module_utils.six.moves.collections_abc import Sequence
+from collections.abc import Sequence
from ansible.module_utils.common.collections import ImmutableDict, is_iterable, is_sequence
diff --git a/test/units/module_utils/common/test_dict_transformations.py b/test/units/module_utils/common/test_dict_transformations.py
index ba55299..7e7c0d3 100644
--- a/test/units/module_utils/common/test_dict_transformations.py
+++ b/test/units/module_utils/common/test_dict_transformations.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2017, Will Thames <will.thames@xvt.com.au>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/test_locale.py b/test/units/module_utils/common/test_locale.py
index 9d95986..80e28de 100644
--- a/test/units/module_utils/common/test_locale.py
+++ b/test/units/module_utils/common/test_locale.py
@@ -2,10 +2,9 @@
# (c) Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
-from units.compat.mock import MagicMock
+from unittest.mock import MagicMock
from ansible.module_utils.common.locale import get_best_parsable_locale
diff --git a/test/units/module_utils/common/test_network.py b/test/units/module_utils/common/test_network.py
index 27d9503..012693b 100644
--- a/test/units/module_utils/common/test_network.py
+++ b/test/units/module_utils/common/test_network.py
@@ -2,9 +2,7 @@
# (c) 2017 Red Hat, Inc.
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/test_sys_info.py b/test/units/module_utils/common/test_sys_info.py
index 18aafe5..4a0c3ef 100644
--- a/test/units/module_utils/common/test_sys_info.py
+++ b/test/units/module_utils/common/test_sys_info.py
@@ -4,14 +4,13 @@
# (c) 2017-2018 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
-from units.compat.mock import patch
+from unittest.mock import patch
-from ansible.module_utils.six.moves import builtins
+import builtins
# Functions being tested
from ansible.module_utils.common.sys_info import get_distribution
diff --git a/test/units/module_utils/common/test_utils.py b/test/units/module_utils/common/test_utils.py
index ef95239..9fe56c9 100644
--- a/test/units/module_utils/common/test_utils.py
+++ b/test/units/module_utils/common/test_utils.py
@@ -2,8 +2,7 @@
# (c) 2018 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.common.sys_info import get_all_subclasses
diff --git a/test/units/module_utils/common/text/converters/test_container_to_bytes.py b/test/units/module_utils/common/text/converters/test_container_to_bytes.py
index 091545e..64baaed 100644
--- a/test/units/module_utils/common/text/converters/test_container_to_bytes.py
+++ b/test/units/module_utils/common/text/converters/test_container_to_bytes.py
@@ -2,8 +2,7 @@
# Copyright 2019, Andrew Klychkov @Andersson007 <aaklychkov@mail.ru>
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/text/converters/test_container_to_text.py b/test/units/module_utils/common/text/converters/test_container_to_text.py
index 39038f5..4639f34 100644
--- a/test/units/module_utils/common/text/converters/test_container_to_text.py
+++ b/test/units/module_utils/common/text/converters/test_container_to_text.py
@@ -2,8 +2,7 @@
# Copyright 2019, Andrew Klychkov @Andersson007 <aaklychkov@mail.ru>
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/text/converters/test_json_encode_fallback.py b/test/units/module_utils/common/text/converters/test_json_encode_fallback.py
index 808bf41..bab6083 100644
--- a/test/units/module_utils/common/text/converters/test_json_encode_fallback.py
+++ b/test/units/module_utils/common/text/converters/test_json_encode_fallback.py
@@ -2,8 +2,7 @@
# Copyright 2019, Andrew Klychkov @Andersson007 <aaklychkov@mail.ru>
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/text/converters/test_jsonify.py b/test/units/module_utils/common/text/converters/test_jsonify.py
index a341531..76545b2 100644
--- a/test/units/module_utils/common/text/converters/test_jsonify.py
+++ b/test/units/module_utils/common/text/converters/test_jsonify.py
@@ -2,8 +2,7 @@
# Copyright 2019, Andrew Klychkov @Andersson007 <aaklychkov@mail.ru>
# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/text/converters/test_to_str.py b/test/units/module_utils/common/text/converters/test_to_str.py
index 712ed85..4c2f63a 100644
--- a/test/units/module_utils/common/text/converters/test_to_str.py
+++ b/test/units/module_utils/common/text/converters/test_to_str.py
@@ -3,15 +3,12 @@
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import itertools
import pytest
-from ansible.module_utils.six import PY3
-
from ansible.module_utils.common.text.converters import to_text, to_bytes, to_native
@@ -43,8 +40,8 @@ def test_to_bytes(in_string, encoding, expected):
@pytest.mark.parametrize('in_string, encoding, expected',
- itertools.chain(((d[0], d[2], d[1] if PY3 else d[0]) for d in VALID_STRINGS),
- ((d[1], d[2], d[1] if PY3 else d[0]) for d in VALID_STRINGS)))
+ itertools.chain(((d[0], d[2], d[1]) for d in VALID_STRINGS),
+ ((d[1], d[2], d[1]) for d in VALID_STRINGS)))
def test_to_native(in_string, encoding, expected):
"""test happy path of encoding to native strings"""
assert to_native(in_string, encoding) == expected
diff --git a/test/units/module_utils/common/text/formatters/test_bytes_to_human.py b/test/units/module_utils/common/text/formatters/test_bytes_to_human.py
index 41475f5..488c33a 100644
--- a/test/units/module_utils/common/text/formatters/test_bytes_to_human.py
+++ b/test/units/module_utils/common/text/formatters/test_bytes_to_human.py
@@ -2,8 +2,7 @@
# Copyright 2019, Andrew Klychkov @Andersson007 <aaklychkov@mail.ru>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/text/formatters/test_human_to_bytes.py b/test/units/module_utils/common/text/formatters/test_human_to_bytes.py
index d02699a..c0d7b00 100644
--- a/test/units/module_utils/common/text/formatters/test_human_to_bytes.py
+++ b/test/units/module_utils/common/text/formatters/test_human_to_bytes.py
@@ -3,8 +3,7 @@
# Copyright 2019, Sviatoslav Sydorenko <webknjaz@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/text/formatters/test_lenient_lowercase.py b/test/units/module_utils/common/text/formatters/test_lenient_lowercase.py
index 1ecc013..99a6058 100644
--- a/test/units/module_utils/common/text/formatters/test_lenient_lowercase.py
+++ b/test/units/module_utils/common/text/formatters/test_lenient_lowercase.py
@@ -2,8 +2,7 @@
# Copyright 2019, Andrew Klychkov @Andersson007 <aaklychkov@mail.ru>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from datetime import datetime
diff --git a/test/units/module_utils/common/validation/test_check_missing_parameters.py b/test/units/module_utils/common/validation/test_check_missing_parameters.py
index 364f943..490696b 100644
--- a/test/units/module_utils/common/validation/test_check_missing_parameters.py
+++ b/test/units/module_utils/common/validation/test_check_missing_parameters.py
@@ -2,9 +2,8 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_mutually_exclusive.py b/test/units/module_utils/common/validation/test_check_mutually_exclusive.py
index acc67be..dc0f027 100644
--- a/test/units/module_utils/common/validation/test_check_mutually_exclusive.py
+++ b/test/units/module_utils/common/validation/test_check_mutually_exclusive.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_required_arguments.py b/test/units/module_utils/common/validation/test_check_required_arguments.py
index eb3d52e..16e79fe 100644
--- a/test/units/module_utils/common/validation/test_check_required_arguments.py
+++ b/test/units/module_utils/common/validation/test_check_required_arguments.py
@@ -2,8 +2,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_required_by.py b/test/units/module_utils/common/validation/test_check_required_by.py
index fcba0c1..053c30a 100644
--- a/test/units/module_utils/common/validation/test_check_required_by.py
+++ b/test/units/module_utils/common/validation/test_check_required_by.py
@@ -2,9 +2,8 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_required_if.py b/test/units/module_utils/common/validation/test_check_required_if.py
index 4590b05..7934ad7 100644
--- a/test/units/module_utils/common/validation/test_check_required_if.py
+++ b/test/units/module_utils/common/validation/test_check_required_if.py
@@ -2,9 +2,8 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_required_one_of.py b/test/units/module_utils/common/validation/test_check_required_one_of.py
index efdba53..d187713 100644
--- a/test/units/module_utils/common/validation/test_check_required_one_of.py
+++ b/test/units/module_utils/common/validation/test_check_required_one_of.py
@@ -2,9 +2,8 @@
# Copyright: (c) 2021, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_required_together.py b/test/units/module_utils/common/validation/test_check_required_together.py
index cf4626a..475b491 100644
--- a/test/units/module_utils/common/validation/test_check_required_together.py
+++ b/test/units/module_utils/common/validation/test_check_required_together.py
@@ -2,8 +2,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_type_bits.py b/test/units/module_utils/common/validation/test_check_type_bits.py
index aa91da9..fa9a60e 100644
--- a/test/units/module_utils/common/validation/test_check_type_bits.py
+++ b/test/units/module_utils/common/validation/test_check_type_bits.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_type_bool.py b/test/units/module_utils/common/validation/test_check_type_bool.py
index 00b785f..32d65fe 100644
--- a/test/units/module_utils/common/validation/test_check_type_bool.py
+++ b/test/units/module_utils/common/validation/test_check_type_bool.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_type_bytes.py b/test/units/module_utils/common/validation/test_check_type_bytes.py
index c29e42f..5d43f7f 100644
--- a/test/units/module_utils/common/validation/test_check_type_bytes.py
+++ b/test/units/module_utils/common/validation/test_check_type_bytes.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_type_dict.py b/test/units/module_utils/common/validation/test_check_type_dict.py
index 75638c5..665224e 100644
--- a/test/units/module_utils/common/validation/test_check_type_dict.py
+++ b/test/units/module_utils/common/validation/test_check_type_dict.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_type_float.py b/test/units/module_utils/common/validation/test_check_type_float.py
index a021887..d7e12e1 100644
--- a/test/units/module_utils/common/validation/test_check_type_float.py
+++ b/test/units/module_utils/common/validation/test_check_type_float.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_type_int.py b/test/units/module_utils/common/validation/test_check_type_int.py
index 6f4dc6a..e943482 100644
--- a/test/units/module_utils/common/validation/test_check_type_int.py
+++ b/test/units/module_utils/common/validation/test_check_type_int.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_type_jsonarg.py b/test/units/module_utils/common/validation/test_check_type_jsonarg.py
index d43bb03..2c229fa 100644
--- a/test/units/module_utils/common/validation/test_check_type_jsonarg.py
+++ b/test/units/module_utils/common/validation/test_check_type_jsonarg.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_type_list.py b/test/units/module_utils/common/validation/test_check_type_list.py
index 3f7a9ee..5e9a0cd 100644
--- a/test/units/module_utils/common/validation/test_check_type_list.py
+++ b/test/units/module_utils/common/validation/test_check_type_list.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/validation/test_check_type_path.py b/test/units/module_utils/common/validation/test_check_type_path.py
index d6ff433..e923c88 100644
--- a/test/units/module_utils/common/validation/test_check_type_path.py
+++ b/test/units/module_utils/common/validation/test_check_type_path.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import re
diff --git a/test/units/module_utils/common/validation/test_check_type_raw.py b/test/units/module_utils/common/validation/test_check_type_raw.py
index 988e554..94ad7fc 100644
--- a/test/units/module_utils/common/validation/test_check_type_raw.py
+++ b/test/units/module_utils/common/validation/test_check_type_raw.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.common.validation import check_type_raw
diff --git a/test/units/module_utils/common/validation/test_check_type_str.py b/test/units/module_utils/common/validation/test_check_type_str.py
index 71af2a0..e8dbbe2 100644
--- a/test/units/module_utils/common/validation/test_check_type_str.py
+++ b/test/units/module_utils/common/validation/test_check_type_str.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/validation/test_count_terms.py b/test/units/module_utils/common/validation/test_count_terms.py
index f41dc40..bf94266 100644
--- a/test/units/module_utils/common/validation/test_count_terms.py
+++ b/test/units/module_utils/common/validation/test_count_terms.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/common/warnings/test_deprecate.py b/test/units/module_utils/common/warnings/test_deprecate.py
index 08c1b35..4ccf4f1 100644
--- a/test/units/module_utils/common/warnings/test_deprecate.py
+++ b/test/units/module_utils/common/warnings/test_deprecate.py
@@ -2,15 +2,13 @@
# (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
from ansible.module_utils.common import warnings
from ansible.module_utils.common.warnings import deprecate, get_deprecation_messages
-from ansible.module_utils.six import PY3
@pytest.fixture
@@ -92,7 +90,7 @@ def test_get_deprecation_messages(deprecation_messages, reset):
{'k1': 'v1'},
(1, 2),
6.62607004,
- b'bytestr' if PY3 else None,
+ b'bytestr',
None,
)
)
diff --git a/test/units/module_utils/common/warnings/test_warn.py b/test/units/module_utils/common/warnings/test_warn.py
index 41e1a7b..ebb21c4 100644
--- a/test/units/module_utils/common/warnings/test_warn.py
+++ b/test/units/module_utils/common/warnings/test_warn.py
@@ -2,15 +2,13 @@
# (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
from ansible.module_utils.common import warnings
from ansible.module_utils.common.warnings import warn, get_warning_messages
-from ansible.module_utils.six import PY3
@pytest.fixture
@@ -52,7 +50,7 @@ def test_get_warning_messages(warning_messages):
{'k1': 'v1'},
(1, 2),
6.62607004,
- b'bytestr' if PY3 else None,
+ b'bytestr',
None,
)
)
diff --git a/test/units/module_utils/compat/test_datetime.py b/test/units/module_utils/compat/test_datetime.py
index 66a0ad0..5bcb8f7 100644
--- a/test/units/module_utils/compat/test_datetime.py
+++ b/test/units/module_utils/compat/test_datetime.py
@@ -1,20 +1,14 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import datetime
from ansible.module_utils.compat.datetime import utcnow, utcfromtimestamp, UTC
-from ansible.module_utils.six import PY3
def test_utc():
assert UTC.tzname(None) == 'UTC'
assert UTC.utcoffset(None) == datetime.timedelta(0)
-
- if PY3:
- assert UTC.dst(None) is None
- else:
- assert UTC.dst(None) == datetime.timedelta(0)
+ assert UTC.dst(None) is None
def test_utcnow():
diff --git a/test/units/module_utils/conftest.py b/test/units/module_utils/conftest.py
index 8e82bf2..41921f1 100644
--- a/test/units/module_utils/conftest.py
+++ b/test/units/module_utils/conftest.py
@@ -1,8 +1,7 @@
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import sys
@@ -11,9 +10,8 @@ from io import BytesIO
import pytest
import ansible.module_utils.basic
-from ansible.module_utils.six import PY3, string_types
from ansible.module_utils.common.text.converters import to_bytes
-from ansible.module_utils.six.moves.collections_abc import MutableMapping
+from collections.abc import MutableMapping
@pytest.fixture
@@ -23,7 +21,7 @@ def stdin(mocker, request):
old_argv = sys.argv
sys.argv = ['ansible_unittest']
- if isinstance(request.param, string_types):
+ if isinstance(request.param, str):
args = request.param
elif isinstance(request.param, MutableMapping):
if 'ANSIBLE_MODULE_ARGS' not in request.param:
@@ -37,11 +35,9 @@ def stdin(mocker, request):
raise Exception('Malformed data to the stdin pytest fixture')
fake_stdin = BytesIO(to_bytes(args, errors='surrogate_or_strict'))
- if PY3:
- mocker.patch('ansible.module_utils.basic.sys.stdin', mocker.MagicMock())
- mocker.patch('ansible.module_utils.basic.sys.stdin.buffer', fake_stdin)
- else:
- mocker.patch('ansible.module_utils.basic.sys.stdin', fake_stdin)
+
+ mocker.patch('ansible.module_utils.basic.sys.stdin', mocker.MagicMock())
+ mocker.patch('ansible.module_utils.basic.sys.stdin.buffer', fake_stdin)
yield fake_stdin
diff --git a/test/units/module_utils/facts/base.py b/test/units/module_utils/facts/base.py
index 3cada8f..4a19e67 100644
--- a/test/units/module_utils/facts/base.py
+++ b/test/units/module_utils/facts/base.py
@@ -15,12 +15,10 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
-from units.compat.mock import Mock, patch
+import unittest
+from unittest.mock import Mock, patch
class BaseFactsTest(unittest.TestCase):
diff --git a/test/units/module_utils/facts/hardware/aix_data.py b/test/units/module_utils/facts/hardware/aix_data.py
index d1a6c9a..16563c9 100644
--- a/test/units/module_utils/facts/hardware/aix_data.py
+++ b/test/units/module_utils/facts/hardware/aix_data.py
@@ -13,8 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
AIX_PROCESSOR_TEST_SCENARIOS = [
diff --git a/test/units/module_utils/facts/hardware/linux_data.py b/test/units/module_utils/facts/hardware/linux_data.py
index f92f14e..1598e34 100644
--- a/test/units/module_utils/facts/hardware/linux_data.py
+++ b/test/units/module_utils/facts/hardware/linux_data.py
@@ -13,8 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
diff --git a/test/units/module_utils/facts/hardware/test_aix_processor.py b/test/units/module_utils/facts/hardware/test_aix_processor.py
index 94d9b9e..bf0b61b 100644
--- a/test/units/module_utils/facts/hardware/test_aix_processor.py
+++ b/test/units/module_utils/facts/hardware/test_aix_processor.py
@@ -2,8 +2,7 @@
# Copyright (c) 2022 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.facts.hardware import aix
import pytest
diff --git a/test/units/module_utils/facts/hardware/test_linux.py b/test/units/module_utils/facts/hardware/test_linux.py
index e3e07e7..0a546f1 100644
--- a/test/units/module_utils/facts/hardware/test_linux.py
+++ b/test/units/module_utils/facts/hardware/test_linux.py
@@ -13,13 +13,12 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
-from units.compat import unittest
-from units.compat.mock import Mock, patch
+import unittest
+from unittest.mock import Mock, patch
from ansible.module_utils.facts import timeout
@@ -73,12 +72,14 @@ class TestFactsLinuxHardwareGetMountFacts(unittest.TestCase):
'block_total': 105871006,
'block_used': 5713133,
'device': '/dev/mapper/fedora_dhcp129--186-home',
+ 'dump': 0,
'fstype': 'ext4',
'inode_available': 26860880,
'inode_total': 26902528,
'inode_used': 41648,
'mount': '/home',
'options': 'rw,seclabel,relatime,data=ordered',
+ 'passno': 0,
'size_available': 410246647808,
'size_total': 433647640576,
'uuid': 'N/A'}
diff --git a/test/units/module_utils/facts/hardware/test_linux_get_cpu_info.py b/test/units/module_utils/facts/hardware/test_linux_get_cpu_info.py
index 4167434..e0d350b 100644
--- a/test/units/module_utils/facts/hardware/test_linux_get_cpu_info.py
+++ b/test/units/module_utils/facts/hardware/test_linux_get_cpu_info.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.facts.hardware import linux
diff --git a/test/units/module_utils/facts/hardware/test_sunos_get_uptime_facts.py b/test/units/module_utils/facts/hardware/test_sunos_get_uptime_facts.py
index e14a2da..c49ac91 100644
--- a/test/units/module_utils/facts/hardware/test_sunos_get_uptime_facts.py
+++ b/test/units/module_utils/facts/hardware/test_sunos_get_uptime_facts.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import time
from ansible.module_utils.facts.hardware import sunos
diff --git a/test/units/module_utils/facts/network/test_fc_wwn.py b/test/units/module_utils/facts/network/test_fc_wwn.py
index 32a3a43..3f91654 100644
--- a/test/units/module_utils/facts/network/test_fc_wwn.py
+++ b/test/units/module_utils/facts/network/test_fc_wwn.py
@@ -2,11 +2,10 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.facts.network import fc_wwn
-from units.compat.mock import Mock
+from unittest.mock import Mock
# AIX lsdev
diff --git a/test/units/module_utils/facts/network/test_generic_bsd.py b/test/units/module_utils/facts/network/test_generic_bsd.py
index f061f04..4e4061d 100644
--- a/test/units/module_utils/facts/network/test_generic_bsd.py
+++ b/test/units/module_utils/facts/network/test_generic_bsd.py
@@ -14,12 +14,10 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat.mock import Mock
-from units.compat import unittest
+from unittest.mock import Mock
+import unittest
from ansible.module_utils.facts.network import generic_bsd
diff --git a/test/units/module_utils/facts/network/test_iscsi_get_initiator.py b/test/units/module_utils/facts/network/test_iscsi_get_initiator.py
index 2048ba2..48f97b3 100644
--- a/test/units/module_utils/facts/network/test_iscsi_get_initiator.py
+++ b/test/units/module_utils/facts/network/test_iscsi_get_initiator.py
@@ -2,11 +2,10 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.facts.network import iscsi
-from units.compat.mock import Mock
+from unittest.mock import Mock
# AIX # lsattr -E -l iscsi0
diff --git a/test/units/module_utils/facts/network/test_locally_reachable_ips.py b/test/units/module_utils/facts/network/test_locally_reachable_ips.py
index 7eac790..4c3643a 100644
--- a/test/units/module_utils/facts/network/test_locally_reachable_ips.py
+++ b/test/units/module_utils/facts/network/test_locally_reachable_ips.py
@@ -16,12 +16,10 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat.mock import Mock
-from units.compat import unittest
+from unittest.mock import Mock
+import unittest
from ansible.module_utils.facts.network import linux
# ip -4 route show table local
diff --git a/test/units/module_utils/facts/other/test_facter.py b/test/units/module_utils/facts/other/test_facter.py
index 7466338..62ff519 100644
--- a/test/units/module_utils/facts/other/test_facter.py
+++ b/test/units/module_utils/facts/other/test_facter.py
@@ -15,11 +15,9 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat.mock import Mock, patch
+from unittest.mock import Mock, patch
from .. base import BaseFactsTest
diff --git a/test/units/module_utils/facts/other/test_ohai.py b/test/units/module_utils/facts/other/test_ohai.py
index 42a72d9..f5084c5 100644
--- a/test/units/module_utils/facts/other/test_ohai.py
+++ b/test/units/module_utils/facts/other/test_ohai.py
@@ -15,11 +15,9 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat.mock import Mock, patch
+from unittest.mock import Mock, patch
from .. base import BaseFactsTest
diff --git a/test/units/module_utils/facts/system/distribution/conftest.py b/test/units/module_utils/facts/system/distribution/conftest.py
index d27b97f..9f84822 100644
--- a/test/units/module_utils/facts/system/distribution/conftest.py
+++ b/test/units/module_utils/facts/system/distribution/conftest.py
@@ -2,13 +2,12 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
-from units.compat.mock import Mock
+from unittest.mock import Mock
@pytest.fixture
diff --git a/test/units/module_utils/facts/system/distribution/fixtures/alp-dolomite.json b/test/units/module_utils/facts/system/distribution/fixtures/alp-dolomite.json
new file mode 100644
index 0000000..04855dd
--- /dev/null
+++ b/test/units/module_utils/facts/system/distribution/fixtures/alp-dolomite.json
@@ -0,0 +1,23 @@
+{
+ "platform.dist": ["", "", ""],
+ "distro": {
+ "codename": "",
+ "id": "alp-dolomite",
+ "name": "SUSE ALP Dolomite",
+ "version": "1.0",
+ "version_best": "1.0",
+ "os_release_info": {},
+ "lsb_release_info": {}
+ },
+ "input": {
+ "/etc/os-release": "NAME=\"ALP-Dolomite\"\nVERSION=\"1.0\"\nID=alp-dolomite\nID_LIKE=\"suse\"\nVERSION_ID=\"1.0\"\nPRETTY_NAME=\"SUSE ALP Dolomite 1.0\"\nANSI_COLOR=\"0;32\"\nCPE_NAME=\"cpe:/o:suse:alp-dolomite:1.0\"\nHOME_URL=\"https://susealp.io/\"\nDOCUMENTATION_URL=\"https://documentation.suse.com/#alp\"\nLOGO=\"distributor-logo\"\n"
+ },
+ "name": "SUSE ALP Dolomite 1.0",
+ "result": {
+ "distribution_release": "NA",
+ "distribution": "ALP-Dolomite",
+ "distribution_major_version": "1",
+ "os_family": "Suse",
+ "distribution_version": "1.0"
+ }
+} \ No newline at end of file
diff --git a/test/units/module_utils/facts/system/distribution/fixtures/miracle_linux_9.json b/test/units/module_utils/facts/system/distribution/fixtures/miracle_linux_9.json
new file mode 100644
index 0000000..e402dfe
--- /dev/null
+++ b/test/units/module_utils/facts/system/distribution/fixtures/miracle_linux_9.json
@@ -0,0 +1,39 @@
+{
+ "name": "MIRACLE LINUX 9.2",
+ "distro": {
+ "codename": "Feige",
+ "id": "miraclelinux",
+ "name": "MIRACLE LINUX",
+ "version": "9.2",
+ "version_best": "9.2",
+ "lsb_release_info": {},
+ "os_release_info": {
+ "name": "MIRACLE LINUX",
+ "version": "9.2 (Feige)",
+ "id": "miraclelinux",
+ "version_id": "9.2",
+ "pretty_name": "MIRACLE LINUX 9.2 (Feige)",
+ "ansi_color": "0;32",
+ "codename": "Feige"
+ }
+ },
+ "input": {
+ "/etc/miraclelinux-release": "MIRACLE LINUX release 9.2 (Feige)\n",
+ "/etc/redhat-release": "MIRACLE LINUX release 9.2 (Feige)\n",
+ "/etc/system-release": "MIRACLE LINUX release 9.2 (Feige)\n",
+ "/etc/os-release": "NAME=\"MIRACLE LINUX\"\nVERSION=\"9.2 (Feige)\"\nID=\"miraclelinux\"\nID_LIKE=\"rhel fedora\"\nVERSION_ID=\"9.2\"\nPLATFORM_ID=\"platform:el9\"\nPRETTY_NAME=\"MIRACLE LINUX 9.2 (Feige)\"\nANSI_COLOR=\"0;32\"\nLOGO=\"fedora-logo-icon\"\nCPE_NAME=\"cpe:/o:cybertrust_japan:miracle_linux:9\"\nHOME_URL=\"https://www.cybertrust.co.jp/miracle-linux/\"\nDOCUMENTATION_URL=\"https://www.miraclelinux.com/support/miraclelinux9\"\nBUG_REPORT_URL=\"https://bugzilla.asianux.com/\"\n\nMIRACLELINUX_SUPPORT_PRODUCT=\"MIRACLE LINUX\"\nMIRACLELINUX_SUPPORT_PRODUCT_VERSION=\"9\""
+ },
+ "platform.dist": [
+ "miraclelinux",
+ "9.2",
+ "Feige"
+ ],
+ "result": {
+ "distribution": "MIRACLE",
+ "distribution_version": "9.2",
+ "distribution_release": "Feige",
+ "distribution_major_version": "9",
+ "os_family": "RedHat"
+ },
+ "platform.release": "5.14.0-284.25.1.el9_2.x86_64"
+}
diff --git a/test/units/module_utils/facts/system/distribution/test_distribution_sles4sap.py b/test/units/module_utils/facts/system/distribution/test_distribution_sles4sap.py
index ab465ea..cc4978e 100644
--- a/test/units/module_utils/facts/system/distribution/test_distribution_sles4sap.py
+++ b/test/units/module_utils/facts/system/distribution/test_distribution_sles4sap.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/facts/system/distribution/test_distribution_version.py b/test/units/module_utils/facts/system/distribution/test_distribution_version.py
index a990274..5ba5f8a 100644
--- a/test/units/module_utils/facts/system/distribution/test_distribution_version.py
+++ b/test/units/module_utils/facts/system/distribution/test_distribution_version.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import glob
import json
@@ -11,7 +10,7 @@ import os
import pytest
from itertools import product
-from ansible.module_utils.six.moves import builtins
+import builtins
# the module we are actually testing (sort of)
from ansible.module_utils.facts.system.distribution import DistributionFactCollector
diff --git a/test/units/module_utils/facts/system/distribution/test_parse_distribution_file_ClearLinux.py b/test/units/module_utils/facts/system/distribution/test_parse_distribution_file_ClearLinux.py
index 6667ada..fc30677 100644
--- a/test/units/module_utils/facts/system/distribution/test_parse_distribution_file_ClearLinux.py
+++ b/test/units/module_utils/facts/system/distribution/test_parse_distribution_file_ClearLinux.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import os
import pytest
diff --git a/test/units/module_utils/facts/system/distribution/test_parse_distribution_file_Slackware.py b/test/units/module_utils/facts/system/distribution/test_parse_distribution_file_Slackware.py
index efb937e..d887172 100644
--- a/test/units/module_utils/facts/system/distribution/test_parse_distribution_file_Slackware.py
+++ b/test/units/module_utils/facts/system/distribution/test_parse_distribution_file_Slackware.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import os
import pytest
diff --git a/test/units/module_utils/facts/system/test_cmdline.py b/test/units/module_utils/facts/system/test_cmdline.py
index 59cfd11..2cda884 100644
--- a/test/units/module_utils/facts/system/test_cmdline.py
+++ b/test/units/module_utils/facts/system/test_cmdline.py
@@ -3,8 +3,7 @@
# Copyright: (c) 2018, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
from ansible.module_utils.facts.system.cmdline import CmdLineFactCollector
diff --git a/test/units/module_utils/facts/system/test_lsb.py b/test/units/module_utils/facts/system/test_lsb.py
index e2ed2ec..385a754 100644
--- a/test/units/module_utils/facts/system/test_lsb.py
+++ b/test/units/module_utils/facts/system/test_lsb.py
@@ -15,11 +15,9 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat.mock import Mock, patch
+from unittest.mock import Mock, patch
from .. base import BaseFactsTest
diff --git a/test/units/module_utils/facts/system/test_pkg_mgr.py b/test/units/module_utils/facts/system/test_pkg_mgr.py
index 8dc1a3b..2053d27 100644
--- a/test/units/module_utils/facts/system/test_pkg_mgr.py
+++ b/test/units/module_utils/facts/system/test_pkg_mgr.py
@@ -2,49 +2,33 @@
# Copyright: (c) 2023, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.facts.system.pkg_mgr import PkgMgrFactCollector
-_FEDORA_FACTS = {
- "ansible_distribution": "Fedora",
- "ansible_distribution_major_version": 38, # any version where yum isn't default
- "ansible_os_family": "RedHat"
-}
+_FACTS = {"ansible_os_family": "RedHat"}
-_KYLIN_FACTS = {
- "ansible_distribution": "Kylin Linux Advanced Server",
- "ansible_distribution_major_version": "V10",
- "ansible_os_family": "RedHat"
-}
# NOTE pkg_mgr == "dnf" means the dnf module for the dnf 4 or below
-def test_default_dnf_version_detection_kylin_dnf4(mocker):
- mocker.patch("os.path.exists", lambda p: p in ("/usr/bin/dnf", "/usr/bin/dnf-3"))
- mocker.patch("os.path.realpath", lambda p: {"/usr/bin/dnf": "/usr/bin/dnf-3"}.get(p, p))
- assert PkgMgrFactCollector().collect(collected_facts=_KYLIN_FACTS).get("pkg_mgr") == "dnf"
-
-
def test_default_dnf_version_detection_fedora_dnf4(mocker):
mocker.patch("os.path.exists", lambda p: p in ("/usr/bin/dnf", "/usr/bin/dnf-3"))
mocker.patch("os.path.realpath", lambda p: {"/usr/bin/dnf": "/usr/bin/dnf-3"}.get(p, p))
- assert PkgMgrFactCollector().collect(collected_facts=_FEDORA_FACTS).get("pkg_mgr") == "dnf"
+ assert PkgMgrFactCollector().collect(collected_facts=_FACTS).get("pkg_mgr") == "dnf"
def test_default_dnf_version_detection_fedora_dnf5(mocker):
mocker.patch("os.path.exists", lambda p: p in ("/usr/bin/dnf", "/usr/bin/dnf5"))
mocker.patch("os.path.realpath", lambda p: {"/usr/bin/dnf": "/usr/bin/dnf5"}.get(p, p))
- assert PkgMgrFactCollector().collect(collected_facts=_FEDORA_FACTS).get("pkg_mgr") == "dnf5"
+ assert PkgMgrFactCollector().collect(collected_facts=_FACTS).get("pkg_mgr") == "dnf5"
def test_default_dnf_version_detection_fedora_dnf4_both_installed(mocker):
mocker.patch("os.path.exists", lambda p: p in ("/usr/bin/dnf", "/usr/bin/dnf-3", "/usr/bin/dnf5"))
mocker.patch("os.path.realpath", lambda p: {"/usr/bin/dnf": "/usr/bin/dnf-3"}.get(p, p))
- assert PkgMgrFactCollector().collect(collected_facts=_FEDORA_FACTS).get("pkg_mgr") == "dnf"
+ assert PkgMgrFactCollector().collect(collected_facts=_FACTS).get("pkg_mgr") == "dnf"
def test_default_dnf_version_detection_fedora_dnf4_microdnf5_installed(mocker):
@@ -56,20 +40,20 @@ def test_default_dnf_version_detection_fedora_dnf4_microdnf5_installed(mocker):
"os.path.realpath",
lambda p: {"/usr/bin/dnf": "/usr/bin/dnf-3", "/usr/bin/microdnf": "/usr/bin/dnf5"}.get(p, p)
)
- assert PkgMgrFactCollector().collect(collected_facts=_FEDORA_FACTS).get("pkg_mgr") == "dnf"
+ assert PkgMgrFactCollector().collect(collected_facts=_FACTS).get("pkg_mgr") == "dnf"
def test_default_dnf_version_detection_fedora_dnf4_microdnf(mocker):
mocker.patch("os.path.exists", lambda p: p == "/usr/bin/microdnf")
- assert PkgMgrFactCollector().collect(collected_facts=_FEDORA_FACTS).get("pkg_mgr") == "dnf"
+ assert PkgMgrFactCollector().collect(collected_facts=_FACTS).get("pkg_mgr") == "dnf"
def test_default_dnf_version_detection_fedora_dnf5_microdnf(mocker):
mocker.patch("os.path.exists", lambda p: p in ("/usr/bin/microdnf", "/usr/bin/dnf5"))
mocker.patch("os.path.realpath", lambda p: {"/usr/bin/microdnf": "/usr/bin/dnf5"}.get(p, p))
- assert PkgMgrFactCollector().collect(collected_facts=_FEDORA_FACTS).get("pkg_mgr") == "dnf5"
+ assert PkgMgrFactCollector().collect(collected_facts=_FACTS).get("pkg_mgr") == "dnf5"
def test_default_dnf_version_detection_fedora_no_default(mocker):
mocker.patch("os.path.exists", lambda p: p in ("/usr/bin/dnf-3", "/usr/bin/dnf5"))
- assert PkgMgrFactCollector().collect(collected_facts=_FEDORA_FACTS).get("pkg_mgr") == "unknown"
+ assert PkgMgrFactCollector().collect(collected_facts=_FACTS).get("pkg_mgr") == "unknown"
diff --git a/test/units/module_utils/facts/system/test_user.py b/test/units/module_utils/facts/system/test_user.py
index 5edfe14..af9c09e 100644
--- a/test/units/module_utils/facts/system/test_user.py
+++ b/test/units/module_utils/facts/system/test_user.py
@@ -15,9 +15,7 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.facts.system.user import UserFactCollector
diff --git a/test/units/module_utils/facts/test_ansible_collector.py b/test/units/module_utils/facts/test_ansible_collector.py
index 47d88df..3316464 100644
--- a/test/units/module_utils/facts/test_ansible_collector.py
+++ b/test/units/module_utils/facts/test_ansible_collector.py
@@ -15,13 +15,11 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
# for testing
-from units.compat import unittest
-from units.compat.mock import Mock, patch
+import unittest
+from unittest.mock import Mock, patch
from ansible.module_utils.facts import collector
from ansible.module_utils.facts import ansible_collector
diff --git a/test/units/module_utils/facts/test_collector.py b/test/units/module_utils/facts/test_collector.py
index 4fc4bc5..852273c 100644
--- a/test/units/module_utils/facts/test_collector.py
+++ b/test/units/module_utils/facts/test_collector.py
@@ -16,15 +16,13 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from collections import defaultdict
import pprint
# for testing
-from units.compat import unittest
+import unittest
from ansible.module_utils.facts import collector
diff --git a/test/units/module_utils/facts/test_collectors.py b/test/units/module_utils/facts/test_collectors.py
index 984b585..4066d9d 100644
--- a/test/units/module_utils/facts/test_collectors.py
+++ b/test/units/module_utils/facts/test_collectors.py
@@ -15,13 +15,9 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-import pytest
-
-from units.compat.mock import Mock, patch
+from unittest.mock import Mock, patch
from . base import BaseFactsTest
@@ -367,21 +363,6 @@ class TestServiceMgrFacts(BaseFactsTest):
# TODO: dedupe some of this test code
@patch('ansible.module_utils.facts.system.service_mgr.get_file_content', return_value=None)
- @patch('ansible.module_utils.facts.system.service_mgr.ServiceMgrFactCollector.is_systemd_managed', return_value=False)
- @patch('ansible.module_utils.facts.system.service_mgr.ServiceMgrFactCollector.is_systemd_managed_offline', return_value=False)
- @patch('ansible.module_utils.facts.system.service_mgr.os.path.exists', return_value=False)
- @pytest.mark.skip(reason='faulty test')
- def test_service_mgr_runit_one(self, mock_gfc, mock_ism, mock_ismo, mock_ope):
- # no /proc/1/comm, ps returns non-0
- # should fallback to 'service'
- module = self._mock_module()
- module.run_command = Mock(return_value=(1, '', 'wat'))
- fact_collector = self.collector_class()
- facts_dict = fact_collector.collect(module=module)
- self.assertIsInstance(facts_dict, dict)
- self.assertEqual(facts_dict['service_mgr'], 'service')
-
- @patch('ansible.module_utils.facts.system.service_mgr.get_file_content', return_value=None)
def test_no_proc1_ps_random_init(self, mock_gfc):
# no /proc/1/comm, ps returns '/sbin/sys11' which we dont know
# should end up return 'sys11'
@@ -392,28 +373,8 @@ class TestServiceMgrFacts(BaseFactsTest):
self.assertIsInstance(facts_dict, dict)
self.assertEqual(facts_dict['service_mgr'], 'sys11')
- @patch('ansible.module_utils.facts.system.service_mgr.get_file_content', return_value=None)
- @patch('ansible.module_utils.facts.system.service_mgr.ServiceMgrFactCollector.is_systemd_managed', return_value=False)
- @patch('ansible.module_utils.facts.system.service_mgr.ServiceMgrFactCollector.is_systemd_managed_offline', return_value=False)
- @patch('ansible.module_utils.facts.system.service_mgr.os.path.exists', return_value=False)
- @pytest.mark.skip(reason='faulty test')
- def test_service_mgr_runit_two(self, mock_gfc, mock_ism, mock_ismo, mock_ope):
- # no /proc/1/comm, ps fails, distro and system are clowncar
- # should end up return 'sys11'
- module = self._mock_module()
- module.run_command = Mock(return_value=(1, '', ''))
- collected_facts = {'distribution': 'clowncar',
- 'system': 'ClownCarOS'}
- fact_collector = self.collector_class()
- facts_dict = fact_collector.collect(module=module,
- collected_facts=collected_facts)
- self.assertIsInstance(facts_dict, dict)
- self.assertEqual(facts_dict['service_mgr'], 'service')
-
@patch('ansible.module_utils.facts.system.service_mgr.get_file_content', return_value='runit-init')
- @patch('ansible.module_utils.facts.system.service_mgr.os.path.islink', side_effect=lambda x: x == '/sbin/init')
- @patch('ansible.module_utils.facts.system.service_mgr.os.readlink', side_effect=lambda x: '/sbin/runit-init' if x == '/sbin/init' else '/bin/false')
- def test_service_mgr_runit(self, mock_gfc, mock_opl, mock_orl):
+ def test_service_mgr_runit(self, mock_gfc):
# /proc/1/comm contains 'runit-init', ps fails, service manager is runit
# should end up return 'runit'
module = self._mock_module()
@@ -440,50 +401,6 @@ class TestServiceMgrFacts(BaseFactsTest):
self.assertIsInstance(facts_dict, dict)
self.assertEqual(facts_dict['service_mgr'], 'runit')
- # TODO: reenable these tests when we can mock more easily
-
-# @patch('ansible.module_utils.facts.system.service_mgr.get_file_content', return_value=None)
-# def test_sunos_fallback(self, mock_gfc):
-# # no /proc/1/comm, ps fails, 'system' is SunOS
-# # should end up return 'smf'?
-# module = self._mock_module()
-# # FIXME: the result here is a kluge to at least cover more of service_mgr.collect
-# # TODO: remove
-# # FIXME: have to force a pid for results here to get into any of the system/distro checks
-# module.run_command = Mock(return_value=(1, ' 37 ', ''))
-# collected_facts = {'system': 'SunOS'}
-# fact_collector = self.collector_class(module=module)
-# facts_dict = fact_collector.collect(collected_facts=collected_facts)
-# print('facts_dict: %s' % facts_dict)
-# self.assertIsInstance(facts_dict, dict)
-# self.assertEqual(facts_dict['service_mgr'], 'smf')
-
-# @patch('ansible.module_utils.facts.system.service_mgr.get_file_content', return_value=None)
-# def test_aix_fallback(self, mock_gfc):
-# # no /proc/1/comm, ps fails, 'system' is SunOS
-# # should end up return 'smf'?
-# module = self._mock_module()
-# module.run_command = Mock(return_value=(1, '', ''))
-# collected_facts = {'system': 'AIX'}
-# fact_collector = self.collector_class(module=module)
-# facts_dict = fact_collector.collect(collected_facts=collected_facts)
-# print('facts_dict: %s' % facts_dict)
-# self.assertIsInstance(facts_dict, dict)
-# self.assertEqual(facts_dict['service_mgr'], 'src')
-
-# @patch('ansible.module_utils.facts.system.service_mgr.get_file_content', return_value=None)
-# def test_linux_fallback(self, mock_gfc):
-# # no /proc/1/comm, ps fails, 'system' is SunOS
-# # should end up return 'smf'?
-# module = self._mock_module()
-# module.run_command = Mock(return_value=(1, ' 37 ', ''))
-# collected_facts = {'system': 'Linux'}
-# fact_collector = self.collector_class(module=module)
-# facts_dict = fact_collector.collect(collected_facts=collected_facts)
-# print('facts_dict: %s' % facts_dict)
-# self.assertIsInstance(facts_dict, dict)
-# self.assertEqual(facts_dict['service_mgr'], 'sdfadf')
-
class TestSshPubKeyFactCollector(BaseFactsTest):
__test__ = True
diff --git a/test/units/module_utils/facts/test_date_time.py b/test/units/module_utils/facts/test_date_time.py
index 6cc05f9..0a17d47 100644
--- a/test/units/module_utils/facts/test_date_time.py
+++ b/test/units/module_utils/facts/test_date_time.py
@@ -2,8 +2,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
import datetime
diff --git a/test/units/module_utils/facts/test_facts.py b/test/units/module_utils/facts/test_facts.py
index c794f03..d0381a1 100644
--- a/test/units/module_utils/facts/test_facts.py
+++ b/test/units/module_utils/facts/test_facts.py
@@ -16,17 +16,15 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import pytest
# for testing
-from units.compat import unittest
-from units.compat.mock import Mock, patch
+import unittest
+from unittest.mock import Mock, patch
from ansible.module_utils import facts
from ansible.module_utils.facts import hardware
diff --git a/test/units/module_utils/facts/test_sysctl.py b/test/units/module_utils/facts/test_sysctl.py
index 0f1632b..4fed2db 100644
--- a/test/units/module_utils/facts/test_sysctl.py
+++ b/test/units/module_utils/facts/test_sysctl.py
@@ -16,13 +16,11 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
#
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
# for testing
-from units.compat import unittest
-from units.compat.mock import MagicMock
+import unittest
+from unittest.mock import MagicMock
from ansible.module_utils.facts.sysctl import get_sysctl
diff --git a/test/units/module_utils/facts/test_timeout.py b/test/units/module_utils/facts/test_timeout.py
index 6ba7c39..d187ced 100644
--- a/test/units/module_utils/facts/test_timeout.py
+++ b/test/units/module_utils/facts/test_timeout.py
@@ -16,9 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import sys
import time
diff --git a/test/units/module_utils/facts/test_utils.py b/test/units/module_utils/facts/test_utils.py
index 28cb5d3..5accfe9 100644
--- a/test/units/module_utils/facts/test_utils.py
+++ b/test/units/module_utils/facts/test_utils.py
@@ -13,12 +13,10 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
-from units.compat.mock import patch
+import unittest
+from unittest.mock import patch
from ansible.module_utils.facts import utils
diff --git a/test/units/module_utils/facts/virtual/test_linux.py b/test/units/module_utils/facts/virtual/test_linux.py
index 7c13299..b5d67e7 100644
--- a/test/units/module_utils/facts/virtual/test_linux.py
+++ b/test/units/module_utils/facts/virtual/test_linux.py
@@ -2,8 +2,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.facts.virtual import linux
diff --git a/test/units/module_utils/json_utils/test_filter_non_json_lines.py b/test/units/module_utils/json_utils/test_filter_non_json_lines.py
index b5b9499..53582cc 100644
--- a/test/units/module_utils/json_utils/test_filter_non_json_lines.py
+++ b/test/units/module_utils/json_utils/test_filter_non_json_lines.py
@@ -16,11 +16,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from ansible.module_utils.json_utils import _filter_non_json_lines
diff --git a/test/units/module_utils/parsing/test_convert_bool.py b/test/units/module_utils/parsing/test_convert_bool.py
index 2c5f812..d0ade8b 100644
--- a/test/units/module_utils/parsing/test_convert_bool.py
+++ b/test/units/module_utils/parsing/test_convert_bool.py
@@ -2,9 +2,7 @@
# Copyright: (c) 2017 Ansible Project
# License: GNU General Public License v3 or later (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt )
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/test_api.py b/test/units/module_utils/test_api.py
index f7e768a..c0d1def 100644
--- a/test/units/module_utils/test_api.py
+++ b/test/units/module_utils/test_api.py
@@ -3,8 +3,7 @@
# Copyright: (c) 2020, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.api import rate_limit, retry, retry_with_delays_and_condition
diff --git a/test/units/module_utils/test_connection.py b/test/units/module_utils/test_connection.py
index bd0285b..fe7e99c 100644
--- a/test/units/module_utils/test_connection.py
+++ b/test/units/module_utils/test_connection.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2021, Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils import connection
diff --git a/test/units/module_utils/test_distro.py b/test/units/module_utils/test_distro.py
index bec127a..462651c 100644
--- a/test/units/module_utils/test_distro.py
+++ b/test/units/module_utils/test_distro.py
@@ -12,11 +12,9 @@
# Note that nir0s/distro has many more tests in it's test suite. The tests here are
# primarily for testing the vendoring.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils import distro
-from ansible.module_utils.six import string_types
# Generic test case with minimal assertions about specific returned values.
@@ -30,10 +28,4 @@ class TestDistro():
def test_id(self):
id = distro.id()
- assert isinstance(id, string_types), 'distro.id() returned %s (%s) which is not a string' % (id, type(id))
-
- def test_opensuse_leap_id(self):
- name = distro.name()
- if name == 'openSUSE Leap':
- id = distro.id()
- assert id == 'opensuse', "OpenSUSE Leap did not return 'opensuse' as id"
+ assert isinstance(id, str), 'distro.id() returned %s (%s) which is not a string' % (id, type(id))
diff --git a/test/units/module_utils/test_text.py b/test/units/module_utils/test_text.py
index 72ef2ab..90269ff 100644
--- a/test/units/module_utils/test_text.py
+++ b/test/units/module_utils/test_text.py
@@ -1,10 +1,8 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import codecs
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
-from ansible.module_utils.six import PY3, text_type, binary_type
def test_exports():
@@ -13,9 +11,9 @@ def test_exports():
from ansible.module_utils import _text
assert _text.codecs == codecs
- assert _text.PY3 == PY3
- assert _text.text_type == text_type
- assert _text.binary_type == binary_type
+ assert _text.PY3 is True
+ assert _text.text_type is str
+ assert _text.binary_type is bytes
assert _text.to_bytes == to_bytes
assert _text.to_native == to_native
assert _text.to_text == to_text
diff --git a/test/units/module_utils/urls/test_RedirectHandlerFactory.py b/test/units/module_utils/urls/test_RedirectHandlerFactory.py
index 7bbe4b5..50f126d 100644
--- a/test/units/module_utils/urls/test_RedirectHandlerFactory.py
+++ b/test/units/module_utils/urls/test_RedirectHandlerFactory.py
@@ -2,19 +2,21 @@
# (c) 2018 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
-from ansible.module_utils.urls import HAS_SSLCONTEXT, RedirectHandlerFactory, urllib_request, urllib_error
-from ansible.module_utils.six import StringIO
+import io
+import urllib.request
+import urllib.error
+
+from ansible.module_utils.urls import HTTPRedirectHandler
import pytest
@pytest.fixture
def urllib_req():
- req = urllib_request.Request(
+ req = urllib.request.Request(
'https://ansible.com/'
)
return req
@@ -22,20 +24,20 @@ def urllib_req():
@pytest.fixture
def request_body():
- return StringIO('TESTS')
+ return io.StringIO('TESTS')
def test_no_redirs(urllib_req, request_body):
- handler = RedirectHandlerFactory('none', False)
+ handler = HTTPRedirectHandler('none')
inst = handler()
- with pytest.raises(urllib_error.HTTPError):
+ with pytest.raises(urllib.error.HTTPError):
inst.redirect_request(urllib_req, request_body, 301, '301 Moved Permanently', {}, 'https://docs.ansible.com/')
def test_urllib2_redir(urllib_req, request_body, mocker):
- redir_request_mock = mocker.patch('ansible.module_utils.urls.urllib_request.HTTPRedirectHandler.redirect_request')
+ redir_request_mock = mocker.patch('ansible.module_utils.urls.urllib.request.HTTPRedirectHandler.redirect_request')
- handler = RedirectHandlerFactory('urllib2', False)
+ handler = HTTPRedirectHandler('urllib2')
inst = handler()
inst.redirect_request(urllib_req, request_body, 301, '301 Moved Permanently', {}, 'https://docs.ansible.com/')
@@ -43,30 +45,30 @@ def test_urllib2_redir(urllib_req, request_body, mocker):
def test_all_redir(urllib_req, request_body, mocker):
- req_mock = mocker.patch('ansible.module_utils.urls.RequestWithMethod')
- handler = RedirectHandlerFactory('all', False)
+ req_mock = mocker.patch('ansible.module_utils.urls.urllib.request.Request')
+ handler = HTTPRedirectHandler('all')
inst = handler()
inst.redirect_request(urllib_req, request_body, 301, '301 Moved Permanently', {}, 'https://docs.ansible.com/')
req_mock.assert_called_once_with('https://docs.ansible.com/', data=None, headers={}, method='GET', origin_req_host='ansible.com', unverifiable=True)
def test_all_redir_post(request_body, mocker):
- handler = RedirectHandlerFactory('all', False)
+ handler = HTTPRedirectHandler('all')
inst = handler()
- req = urllib_request.Request(
+ req = urllib.request.Request(
'https://ansible.com/',
'POST'
)
- req_mock = mocker.patch('ansible.module_utils.urls.RequestWithMethod')
+ req_mock = mocker.patch('ansible.module_utils.urls.urllib.request.Request')
inst.redirect_request(req, request_body, 301, '301 Moved Permanently', {}, 'https://docs.ansible.com/')
req_mock.assert_called_once_with('https://docs.ansible.com/', data=None, headers={}, method='GET', origin_req_host='ansible.com', unverifiable=True)
def test_redir_headers_removal(urllib_req, request_body, mocker):
- req_mock = mocker.patch('ansible.module_utils.urls.RequestWithMethod')
- handler = RedirectHandlerFactory('all', False)
+ req_mock = mocker.patch('ansible.module_utils.urls.urllib.request.Request')
+ handler = HTTPRedirectHandler('all')
inst = handler()
urllib_req.headers = {
@@ -81,8 +83,8 @@ def test_redir_headers_removal(urllib_req, request_body, mocker):
def test_redir_url_spaces(urllib_req, request_body, mocker):
- req_mock = mocker.patch('ansible.module_utils.urls.RequestWithMethod')
- handler = RedirectHandlerFactory('all', False)
+ req_mock = mocker.patch('ansible.module_utils.urls.urllib.request.Request')
+ handler = HTTPRedirectHandler('all')
inst = handler()
inst.redirect_request(urllib_req, request_body, 301, '301 Moved Permanently', {}, 'https://docs.ansible.com/foo bar')
@@ -92,8 +94,8 @@ def test_redir_url_spaces(urllib_req, request_body, mocker):
def test_redir_safe(urllib_req, request_body, mocker):
- req_mock = mocker.patch('ansible.module_utils.urls.RequestWithMethod')
- handler = RedirectHandlerFactory('safe', False)
+ req_mock = mocker.patch('ansible.module_utils.urls.urllib.request.Request')
+ handler = HTTPRedirectHandler('safe')
inst = handler()
inst.redirect_request(urllib_req, request_body, 301, '301 Moved Permanently', {}, 'https://docs.ansible.com/')
@@ -101,38 +103,29 @@ def test_redir_safe(urllib_req, request_body, mocker):
def test_redir_safe_not_safe(request_body):
- handler = RedirectHandlerFactory('safe', False)
+ handler = HTTPRedirectHandler('safe')
inst = handler()
- req = urllib_request.Request(
+ req = urllib.request.Request(
'https://ansible.com/',
'POST'
)
- with pytest.raises(urllib_error.HTTPError):
+ with pytest.raises(urllib.error.HTTPError):
inst.redirect_request(req, request_body, 301, '301 Moved Permanently', {}, 'https://docs.ansible.com/')
def test_redir_no_error_on_invalid(urllib_req, request_body):
- handler = RedirectHandlerFactory('invalid', False)
+ handler = HTTPRedirectHandler('invalid')
inst = handler()
- with pytest.raises(urllib_error.HTTPError):
+ with pytest.raises(urllib.error.HTTPError):
inst.redirect_request(urllib_req, request_body, 301, '301 Moved Permanently', {}, 'https://docs.ansible.com/')
-def test_redir_validate_certs(urllib_req, request_body, mocker):
- opener_mock = mocker.patch('ansible.module_utils.urls.urllib_request._opener')
- handler = RedirectHandlerFactory('all', True)
- inst = handler()
- inst.redirect_request(urllib_req, request_body, 301, '301 Moved Permanently', {}, 'https://docs.ansible.com/')
-
- assert opener_mock.add_handler.call_count == int(not HAS_SSLCONTEXT)
-
-
def test_redir_http_error_308_urllib2(urllib_req, request_body, mocker):
- redir_mock = mocker.patch.object(urllib_request.HTTPRedirectHandler, 'redirect_request')
- handler = RedirectHandlerFactory('urllib2', False)
+ redir_mock = mocker.patch.object(urllib.request.HTTPRedirectHandler, 'redirect_request')
+ handler = HTTPRedirectHandler('urllib2')
inst = handler()
inst.redirect_request(urllib_req, request_body, 308, '308 Permanent Redirect', {}, 'https://docs.ansible.com/')
diff --git a/test/units/module_utils/urls/test_Request.py b/test/units/module_utils/urls/test_Request.py
index a8bc3a0..f5f0ede 100644
--- a/test/units/module_utils/urls/test_Request.py
+++ b/test/units/module_utils/urls/test_Request.py
@@ -2,32 +2,32 @@
# (c) 2018 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import datetime
import os
+import urllib.request
+import http.client
-from ansible.module_utils.urls import (Request, open_url, urllib_request, HAS_SSLCONTEXT, cookiejar, RequestWithMethod,
- UnixHTTPHandler, UnixHTTPSConnection, httplib)
-from ansible.module_utils.urls import SSLValidationHandler, HTTPSClientAuthHandler, RedirectHandlerFactory
+from ansible.module_utils.urls import (Request, open_url, cookiejar,
+ UnixHTTPHandler, UnixHTTPSConnection)
+from ansible.module_utils.urls import HTTPRedirectHandler
import pytest
-from units.compat.mock import call
+from unittest.mock import call
-if HAS_SSLCONTEXT:
- import ssl
+import ssl
@pytest.fixture
def urlopen_mock(mocker):
- return mocker.patch('ansible.module_utils.urls.urllib_request.urlopen')
+ return mocker.patch('ansible.module_utils.urls.urllib.request.urlopen')
@pytest.fixture
def install_opener_mock(mocker):
- return mocker.patch('ansible.module_utils.urls.urllib_request.install_opener')
+ return mocker.patch('ansible.module_utils.urls.urllib.request.install_opener')
def test_Request_fallback(urlopen_mock, install_opener_mock, mocker):
@@ -78,10 +78,11 @@ def test_Request_fallback(urlopen_mock, install_opener_mock, mocker):
call(None, True), # auto_decompress
call(None, ['ECDHE-RSA-AES128-SHA256']), # ciphers
call(None, True), # use_netrc
+ call(None, None), # context
]
fallback_mock.assert_has_calls(calls)
- assert fallback_mock.call_count == 18 # All but headers use fallback
+ assert fallback_mock.call_count == 19 # All but headers use fallback
args = urlopen_mock.call_args[0]
assert args[1] is None # data, this is handled in the Request not urlopen
@@ -112,39 +113,18 @@ def test_Request_open(urlopen_mock, install_opener_mock):
opener = install_opener_mock.call_args[0][0]
handlers = opener.handlers
- if not HAS_SSLCONTEXT:
- expected_handlers = (
- SSLValidationHandler,
- RedirectHandlerFactory(), # factory, get handler
- )
- else:
- expected_handlers = (
- RedirectHandlerFactory(), # factory, get handler
- )
+ expected_handlers = (
+ HTTPRedirectHandler(),
+ )
found_handlers = []
for handler in handlers:
- if isinstance(handler, SSLValidationHandler) or handler.__class__.__name__ == 'RedirectHandler':
+ if handler.__class__.__name__ == 'HTTPRedirectHandler':
found_handlers.append(handler)
assert len(found_handlers) == len(expected_handlers)
-def test_Request_open_http(urlopen_mock, install_opener_mock):
- r = Request().open('GET', 'http://ansible.com/')
- args = urlopen_mock.call_args[0]
-
- opener = install_opener_mock.call_args[0][0]
- handlers = opener.handlers
-
- found_handlers = []
- for handler in handlers:
- if isinstance(handler, SSLValidationHandler):
- found_handlers.append(handler)
-
- assert len(found_handlers) == 0
-
-
def test_Request_open_unix_socket(urlopen_mock, install_opener_mock):
r = Request().open('GET', 'http://ansible.com/', unix_socket='/foo/bar/baz.sock')
args = urlopen_mock.call_args[0]
@@ -160,7 +140,9 @@ def test_Request_open_unix_socket(urlopen_mock, install_opener_mock):
assert len(found_handlers) == 1
-def test_Request_open_https_unix_socket(urlopen_mock, install_opener_mock):
+def test_Request_open_https_unix_socket(urlopen_mock, install_opener_mock, mocker):
+ do_open = mocker.patch.object(urllib.request.HTTPSHandler, 'do_open')
+
r = Request().open('GET', 'https://ansible.com/', unix_socket='/foo/bar/baz.sock')
args = urlopen_mock.call_args[0]
@@ -169,13 +151,15 @@ def test_Request_open_https_unix_socket(urlopen_mock, install_opener_mock):
found_handlers = []
for handler in handlers:
- if isinstance(handler, HTTPSClientAuthHandler):
+ if isinstance(handler, urllib.request.HTTPSHandler):
found_handlers.append(handler)
assert len(found_handlers) == 1
- inst = found_handlers[0]._build_https_connection('foo')
- assert isinstance(inst, UnixHTTPSConnection)
+ found_handlers[0].https_open(None)
+ args = do_open.call_args[0]
+ cls = args[0]
+ assert isinstance(cls, UnixHTTPSConnection)
def test_Request_open_ftp(urlopen_mock, install_opener_mock, mocker):
@@ -199,8 +183,8 @@ def test_Request_open_username(urlopen_mock, install_opener_mock):
handlers = opener.handlers
expected_handlers = (
- urllib_request.HTTPBasicAuthHandler,
- urllib_request.HTTPDigestAuthHandler,
+ urllib.request.HTTPBasicAuthHandler,
+ urllib.request.HTTPDigestAuthHandler,
)
found_handlers = []
@@ -211,22 +195,27 @@ def test_Request_open_username(urlopen_mock, install_opener_mock):
assert found_handlers[0].passwd.passwd[None] == {(('ansible.com', '/'),): ('user', None)}
-def test_Request_open_username_in_url(urlopen_mock, install_opener_mock):
- r = Request().open('GET', 'http://user2@ansible.com/')
+@pytest.mark.parametrize('url, expected', (
+ ('user2@ansible.com', ('user2', '')),
+ ('user2%40@ansible.com', ('user2@', '')),
+ ('user2%40:%40@ansible.com', ('user2@', '@')),
+))
+def test_Request_open_username_in_url(url, expected, urlopen_mock, install_opener_mock):
+ r = Request().open('GET', f'http://{url}/')
opener = install_opener_mock.call_args[0][0]
handlers = opener.handlers
expected_handlers = (
- urllib_request.HTTPBasicAuthHandler,
- urllib_request.HTTPDigestAuthHandler,
+ urllib.request.HTTPBasicAuthHandler,
+ urllib.request.HTTPDigestAuthHandler,
)
found_handlers = []
for handler in handlers:
if isinstance(handler, expected_handlers):
found_handlers.append(handler)
- assert found_handlers[0].passwd.passwd[None] == {(('ansible.com', '/'),): ('user2', '')}
+ assert found_handlers[0].passwd.passwd[None] == {(('ansible.com', '/'),): expected}
def test_Request_open_username_force_basic(urlopen_mock, install_opener_mock):
@@ -236,8 +225,8 @@ def test_Request_open_username_force_basic(urlopen_mock, install_opener_mock):
handlers = opener.handlers
expected_handlers = (
- urllib_request.HTTPBasicAuthHandler,
- urllib_request.HTTPDigestAuthHandler,
+ urllib.request.HTTPBasicAuthHandler,
+ urllib.request.HTTPDigestAuthHandler,
)
found_handlers = []
@@ -262,8 +251,8 @@ def test_Request_open_auth_in_netloc(urlopen_mock, install_opener_mock):
handlers = opener.handlers
expected_handlers = (
- urllib_request.HTTPBasicAuthHandler,
- urllib_request.HTTPDigestAuthHandler,
+ urllib.request.HTTPBasicAuthHandler,
+ urllib.request.HTTPDigestAuthHandler,
)
found_handlers = []
@@ -296,21 +285,22 @@ def test_Request_open_netrc(urlopen_mock, install_opener_mock, monkeypatch):
def test_Request_open_no_proxy(urlopen_mock, install_opener_mock, mocker):
- build_opener_mock = mocker.patch('ansible.module_utils.urls.urllib_request.build_opener')
+ build_opener_mock = mocker.patch('ansible.module_utils.urls.urllib.request.build_opener')
r = Request().open('GET', 'http://ansible.com/', use_proxy=False)
handlers = build_opener_mock.call_args[0]
found_handlers = []
for handler in handlers:
- if isinstance(handler, urllib_request.ProxyHandler):
+ if isinstance(handler, urllib.request.ProxyHandler):
found_handlers.append(handler)
assert len(found_handlers) == 1
-@pytest.mark.skipif(not HAS_SSLCONTEXT, reason="requires SSLContext")
-def test_Request_open_no_validate_certs(urlopen_mock, install_opener_mock):
+def test_Request_open_no_validate_certs(urlopen_mock, install_opener_mock, mocker):
+ do_open = mocker.patch.object(urllib.request.HTTPSHandler, 'do_open')
+
r = Request().open('GET', 'https://ansible.com/', validate_certs=False)
opener = install_opener_mock.call_args[0][0]
@@ -318,14 +308,16 @@ def test_Request_open_no_validate_certs(urlopen_mock, install_opener_mock):
ssl_handler = None
for handler in handlers:
- if isinstance(handler, HTTPSClientAuthHandler):
+ if isinstance(handler, urllib.request.HTTPSHandler):
ssl_handler = handler
break
assert ssl_handler is not None
- inst = ssl_handler._build_https_connection('foo')
- assert isinstance(inst, httplib.HTTPSConnection)
+ ssl_handler.https_open(None)
+ args = do_open.call_args[0]
+ cls = args[0]
+ assert cls is http.client.HTTPSConnection
context = ssl_handler._context
# Differs by Python version
@@ -337,7 +329,9 @@ def test_Request_open_no_validate_certs(urlopen_mock, install_opener_mock):
assert context.check_hostname is False
-def test_Request_open_client_cert(urlopen_mock, install_opener_mock):
+def test_Request_open_client_cert(urlopen_mock, install_opener_mock, mocker):
+ load_cert_chain = mocker.patch.object(ssl.SSLContext, 'load_cert_chain')
+
here = os.path.dirname(__file__)
client_cert = os.path.join(here, 'fixtures/client.pem')
@@ -350,16 +344,13 @@ def test_Request_open_client_cert(urlopen_mock, install_opener_mock):
ssl_handler = None
for handler in handlers:
- if isinstance(handler, HTTPSClientAuthHandler):
+ if isinstance(handler, urllib.request.HTTPSHandler):
ssl_handler = handler
break
assert ssl_handler is not None
- assert ssl_handler.client_cert == client_cert
- assert ssl_handler.client_key == client_key
-
- ssl_handler._build_https_connection('ansible.com')
+ load_cert_chain.assert_called_once_with(client_cert, keyfile=client_key)
def test_Request_open_cookies(urlopen_mock, install_opener_mock):
@@ -370,7 +361,7 @@ def test_Request_open_cookies(urlopen_mock, install_opener_mock):
cookies_handler = None
for handler in handlers:
- if isinstance(handler, urllib_request.HTTPCookieProcessor):
+ if isinstance(handler, urllib.request.HTTPCookieProcessor):
cookies_handler = handler
break
@@ -388,15 +379,6 @@ def test_Request_open_invalid_method(urlopen_mock, install_opener_mock):
# assert r.status == 504
-def test_Request_open_custom_method(urlopen_mock, install_opener_mock):
- r = Request().open('DELETE', 'https://ansible.com/')
-
- args = urlopen_mock.call_args[0]
- req = args[0]
-
- assert isinstance(req, RequestWithMethod)
-
-
def test_Request_open_user_agent(urlopen_mock, install_opener_mock):
r = Request().open('GET', 'https://ansible.com/', http_agent='ansible-tests')
diff --git a/test/units/module_utils/urls/test_RequestWithMethod.py b/test/units/module_utils/urls/test_RequestWithMethod.py
deleted file mode 100644
index 0510519..0000000
--- a/test/units/module_utils/urls/test_RequestWithMethod.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- coding: utf-8 -*-
-# (c) 2018 Matt Martz <matt@sivel.net>
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
-
-from ansible.module_utils.urls import RequestWithMethod
-
-
-def test_RequestWithMethod():
- get = RequestWithMethod('https://ansible.com/', 'GET')
- assert get.get_method() == 'GET'
-
- post = RequestWithMethod('https://ansible.com/', 'POST', data='foo', headers={'Bar': 'baz'})
- assert post.get_method() == 'POST'
- assert post.get_full_url() == 'https://ansible.com/'
- assert post.data == 'foo'
- assert post.headers == {'Bar': 'baz'}
-
- none = RequestWithMethod('https://ansible.com/', '')
- assert none.get_method() == 'GET'
diff --git a/test/units/module_utils/urls/test_channel_binding.py b/test/units/module_utils/urls/test_channel_binding.py
index a08e9e4..308fe36 100644
--- a/test/units/module_utils/urls/test_channel_binding.py
+++ b/test/units/module_utils/urls/test_channel_binding.py
@@ -2,8 +2,7 @@
# (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import base64
import os.path
diff --git a/test/units/module_utils/urls/test_fetch_file.py b/test/units/module_utils/urls/test_fetch_file.py
index ecb6b9f..6d6dc8c 100644
--- a/test/units/module_utils/urls/test_fetch_file.py
+++ b/test/units/module_utils/urls/test_fetch_file.py
@@ -2,8 +2,7 @@
# Copyright: Contributors to the Ansible project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import os
diff --git a/test/units/module_utils/urls/test_fetch_url.py b/test/units/module_utils/urls/test_fetch_url.py
index 5bfd66a..9df4102 100644
--- a/test/units/module_utils/urls/test_fetch_url.py
+++ b/test/units/module_utils/urls/test_fetch_url.py
@@ -2,19 +2,19 @@
# (c) 2018 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
+import io
import socket
import sys
+import http.client
+import urllib.error
+from http.cookiejar import Cookie
-from ansible.module_utils.six import StringIO
-from ansible.module_utils.six.moves.http_cookiejar import Cookie
-from ansible.module_utils.six.moves.http_client import HTTPMessage
-from ansible.module_utils.urls import fetch_url, urllib_error, ConnectionError, NoSSLError, httplib
+from ansible.module_utils.urls import fetch_url, ConnectionError
import pytest
-from units.compat.mock import MagicMock
+from unittest.mock import MagicMock
class AnsibleModuleExit(Exception):
@@ -53,13 +53,6 @@ class FakeAnsibleModule:
raise FailJson(*args, **kwargs)
-def test_fetch_url_no_urlparse(mocker, fake_ansible_module):
- mocker.patch('ansible.module_utils.urls.HAS_URLPARSE', new=False)
-
- with pytest.raises(FailJson):
- fetch_url(fake_ansible_module, 'http://ansible.com/')
-
-
def test_fetch_url(open_url_mock, fake_ansible_module):
r, info = fetch_url(fake_ansible_module, 'http://ansible.com/')
@@ -99,13 +92,8 @@ def test_fetch_url_cookies(mocker, fake_ansible_module):
def make_cookies(*args, **kwargs):
cookies = kwargs['cookies']
r = MagicMock()
- try:
- r.headers = HTTPMessage()
- add_header = r.headers.add_header
- except TypeError:
- # PY2
- r.headers = HTTPMessage(StringIO())
- add_header = r.headers.addheader
+ r.headers = http.client.HTTPMessage()
+ add_header = r.headers.add_header
r.info.return_value = r.headers
for name, value in (('Foo', 'bar'), ('Baz', 'qux')):
cookie = Cookie(
@@ -151,26 +139,6 @@ def test_fetch_url_cookies(mocker, fake_ansible_module):
assert info['set-cookie'] == 'Foo=bar, Baz=qux'
-def test_fetch_url_nossl(open_url_mock, fake_ansible_module, mocker):
- mocker.patch('ansible.module_utils.urls.get_distribution', return_value='notredhat')
-
- open_url_mock.side_effect = NoSSLError
- with pytest.raises(FailJson) as excinfo:
- fetch_url(fake_ansible_module, 'http://ansible.com/')
-
- assert 'python-ssl' not in excinfo.value.kwargs['msg']
-
- mocker.patch('ansible.module_utils.urls.get_distribution', return_value='redhat')
-
- open_url_mock.side_effect = NoSSLError
- with pytest.raises(FailJson) as excinfo:
- fetch_url(fake_ansible_module, 'http://ansible.com/')
-
- assert 'python-ssl' in excinfo.value.kwargs['msg']
- assert 'http://ansible.com/' == excinfo.value.kwargs['url']
- assert excinfo.value.kwargs['status'] == -1
-
-
def test_fetch_url_connectionerror(open_url_mock, fake_ansible_module):
open_url_mock.side_effect = ConnectionError('TESTS')
with pytest.raises(FailJson) as excinfo:
@@ -190,12 +158,12 @@ def test_fetch_url_connectionerror(open_url_mock, fake_ansible_module):
def test_fetch_url_httperror(open_url_mock, fake_ansible_module):
- open_url_mock.side_effect = urllib_error.HTTPError(
+ open_url_mock.side_effect = urllib.error.HTTPError(
'http://ansible.com/',
500,
'Internal Server Error',
{'Content-Type': 'application/json'},
- StringIO('TESTS')
+ io.StringIO('TESTS')
)
r, info = fetch_url(fake_ansible_module, 'http://ansible.com/')
@@ -205,7 +173,7 @@ def test_fetch_url_httperror(open_url_mock, fake_ansible_module):
def test_fetch_url_urlerror(open_url_mock, fake_ansible_module):
- open_url_mock.side_effect = urllib_error.URLError('TESTS')
+ open_url_mock.side_effect = urllib.error.URLError('TESTS')
r, info = fetch_url(fake_ansible_module, 'http://ansible.com/')
assert info == {'msg': 'Request failed: <urlopen error TESTS>', 'status': -1, 'url': 'http://ansible.com/'}
@@ -225,6 +193,6 @@ def test_fetch_url_exception(open_url_mock, fake_ansible_module):
def test_fetch_url_badstatusline(open_url_mock, fake_ansible_module):
- open_url_mock.side_effect = httplib.BadStatusLine('TESTS')
+ open_url_mock.side_effect = http.client.BadStatusLine('TESTS')
r, info = fetch_url(fake_ansible_module, 'http://ansible.com/')
assert info == {'msg': 'Connection failure: connection was closed before a valid response was received: TESTS', 'status': -1, 'url': 'http://ansible.com/'}
diff --git a/test/units/module_utils/urls/test_generic_urlparse.py b/test/units/module_utils/urls/test_generic_urlparse.py
index 7753726..67d4ef7 100644
--- a/test/units/module_utils/urls/test_generic_urlparse.py
+++ b/test/units/module_utils/urls/test_generic_urlparse.py
@@ -2,11 +2,10 @@
# (c) 2018 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.urls import generic_urlparse
-from ansible.module_utils.six.moves.urllib.parse import urlparse, urlunparse
+from urllib.parse import urlparse, urlunparse
def test_generic_urlparse():
@@ -26,32 +25,3 @@ def test_generic_urlparse_netloc():
assert generic_parts.hostname == 'ansible.com'
assert generic_parts.port == 443
assert urlunparse(generic_parts.as_list()) == url
-
-
-def test_generic_urlparse_no_netloc():
- url = 'https://user:passwd@ansible.com:443/blog'
- parts = list(urlparse(url))
- generic_parts = generic_urlparse(parts)
- assert generic_parts.hostname == 'ansible.com'
- assert generic_parts.port == 443
- assert generic_parts.username == 'user'
- assert generic_parts.password == 'passwd'
- assert urlunparse(generic_parts.as_list()) == url
-
-
-def test_generic_urlparse_no_netloc_no_auth():
- url = 'https://ansible.com:443/blog'
- parts = list(urlparse(url))
- generic_parts = generic_urlparse(parts)
- assert generic_parts.username is None
- assert generic_parts.password is None
-
-
-def test_generic_urlparse_no_netloc_no_host():
- url = '/blog'
- parts = list(urlparse(url))
- generic_parts = generic_urlparse(parts)
- assert generic_parts.username is None
- assert generic_parts.password is None
- assert generic_parts.port is None
- assert generic_parts.hostname == ''
diff --git a/test/units/module_utils/urls/test_gzip.py b/test/units/module_utils/urls/test_gzip.py
index c684032..8d850f2 100644
--- a/test/units/module_utils/urls/test_gzip.py
+++ b/test/units/module_utils/urls/test_gzip.py
@@ -2,20 +2,13 @@
# (c) 2021 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import gzip
import io
import sys
+import http.client
-try:
- from urllib.response import addinfourl
-except ImportError:
- from urllib import addinfourl
-
-from ansible.module_utils.six import PY3
-from ansible.module_utils.six.moves import http_client
from ansible.module_utils.urls import GzipDecodedReader, Request
import pytest
@@ -38,7 +31,7 @@ class Sock(io.BytesIO):
@pytest.fixture
def urlopen_mock(mocker):
- return mocker.patch('ansible.module_utils.urls.urllib_request.urlopen')
+ return mocker.patch('ansible.module_utils.urls.urllib.request.urlopen')
JSON_DATA = b'{"foo": "bar", "baz": "qux", "sandwich": "ham", "tech_level": "pickle", "pop": "corn", "ansible": "awesome"}'
@@ -63,22 +56,13 @@ Content-Length: 100
def test_Request_open_gzip(urlopen_mock):
- h = http_client.HTTPResponse(
+ h = http.client.HTTPResponse(
Sock(GZIP_RESP),
method='GET',
)
h.begin()
- if PY3:
- urlopen_mock.return_value = h
- else:
- urlopen_mock.return_value = addinfourl(
- h.fp,
- h.msg,
- 'http://ansible.com/',
- h.status,
- )
- urlopen_mock.return_value.msg = h.reason
+ urlopen_mock.return_value = h
r = Request().open('GET', 'https://ansible.com/')
assert isinstance(r.fp, GzipDecodedReader)
@@ -86,22 +70,13 @@ def test_Request_open_gzip(urlopen_mock):
def test_Request_open_not_gzip(urlopen_mock):
- h = http_client.HTTPResponse(
+ h = http.client.HTTPResponse(
Sock(RESP),
method='GET',
)
h.begin()
- if PY3:
- urlopen_mock.return_value = h
- else:
- urlopen_mock.return_value = addinfourl(
- h.fp,
- h.msg,
- 'http://ansible.com/',
- h.status,
- )
- urlopen_mock.return_value.msg = h.reason
+ urlopen_mock.return_value = h
r = Request().open('GET', 'https://ansible.com/')
assert not isinstance(r.fp, GzipDecodedReader)
@@ -109,22 +84,13 @@ def test_Request_open_not_gzip(urlopen_mock):
def test_Request_open_decompress_false(urlopen_mock):
- h = http_client.HTTPResponse(
+ h = http.client.HTTPResponse(
Sock(RESP),
method='GET',
)
h.begin()
- if PY3:
- urlopen_mock.return_value = h
- else:
- urlopen_mock.return_value = addinfourl(
- h.fp,
- h.msg,
- 'http://ansible.com/',
- h.status,
- )
- urlopen_mock.return_value.msg = h.reason
+ urlopen_mock.return_value = h
r = Request().open('GET', 'https://ansible.com/', decompress=False)
assert not isinstance(r.fp, GzipDecodedReader)
@@ -142,10 +108,7 @@ def test_GzipDecodedReader_no_gzip(monkeypatch, mocker):
raise ImportError
return orig_import(*args)
- if PY3:
- mocker.patch('builtins.__import__', _import)
- else:
- mocker.patch('__builtin__.__import__', _import)
+ mocker.patch('builtins.__import__', _import)
mod = __import__('ansible.module_utils.urls').module_utils.urls
assert mod.HAS_GZIP is False
diff --git a/test/units/module_utils/urls/test_prepare_multipart.py b/test/units/module_utils/urls/test_prepare_multipart.py
index ee32047..5b81c39 100644
--- a/test/units/module_utils/urls/test_prepare_multipart.py
+++ b/test/units/module_utils/urls/test_prepare_multipart.py
@@ -2,8 +2,7 @@
# (c) 2020 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import os
diff --git a/test/units/module_utils/urls/test_split.py b/test/units/module_utils/urls/test_split.py
index 7fd5fc1..99deb73 100644
--- a/test/units/module_utils/urls/test_split.py
+++ b/test/units/module_utils/urls/test_split.py
@@ -2,8 +2,7 @@
# Copyright: Contributors to the Ansible project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/module_utils/urls/test_urls.py b/test/units/module_utils/urls/test_urls.py
index f0e5e9e..b427f40 100644
--- a/test/units/module_utils/urls/test_urls.py
+++ b/test/units/module_utils/urls/test_urls.py
@@ -2,89 +2,9 @@
# (c) 2018 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils import urls
-from ansible.module_utils.common.text.converters import to_native
-
-import pytest
-
-
-def test_build_ssl_validation_error(mocker):
- mocker.patch.object(urls, 'HAS_SSLCONTEXT', new=False)
- mocker.patch.object(urls, 'HAS_URLLIB3_PYOPENSSLCONTEXT', new=False)
- mocker.patch.object(urls, 'HAS_URLLIB3_SSL_WRAP_SOCKET', new=False)
- with pytest.raises(urls.SSLValidationError) as excinfo:
- urls.build_ssl_validation_error('hostname', 'port', 'paths', exc=None)
-
- assert 'python >= 2.7.9' in to_native(excinfo.value)
- assert 'the python executable used' in to_native(excinfo.value)
- assert 'urllib3' in to_native(excinfo.value)
- assert 'python >= 2.6' in to_native(excinfo.value)
- assert 'validate_certs=False' in to_native(excinfo.value)
-
- mocker.patch.object(urls, 'HAS_SSLCONTEXT', new=True)
- with pytest.raises(urls.SSLValidationError) as excinfo:
- urls.build_ssl_validation_error('hostname', 'port', 'paths', exc=None)
-
- assert 'validate_certs=False' in to_native(excinfo.value)
-
- mocker.patch.object(urls, 'HAS_SSLCONTEXT', new=False)
- mocker.patch.object(urls, 'HAS_URLLIB3_PYOPENSSLCONTEXT', new=True)
- mocker.patch.object(urls, 'HAS_URLLIB3_SSL_WRAP_SOCKET', new=True)
-
- mocker.patch.object(urls, 'HAS_SSLCONTEXT', new=True)
- with pytest.raises(urls.SSLValidationError) as excinfo:
- urls.build_ssl_validation_error('hostname', 'port', 'paths', exc=None)
-
- assert 'urllib3' not in to_native(excinfo.value)
-
- with pytest.raises(urls.SSLValidationError) as excinfo:
- urls.build_ssl_validation_error('hostname', 'port', 'paths', exc='BOOM')
-
- assert 'BOOM' in to_native(excinfo.value)
-
-
-def test_maybe_add_ssl_handler(mocker):
- mocker.patch.object(urls, 'HAS_SSL', new=False)
- with pytest.raises(urls.NoSSLError):
- urls.maybe_add_ssl_handler('https://ansible.com/', True)
-
- mocker.patch.object(urls, 'HAS_SSL', new=True)
- url = 'https://user:passwd@ansible.com/'
- handler = urls.maybe_add_ssl_handler(url, True)
- assert handler.hostname == 'ansible.com'
- assert handler.port == 443
-
- url = 'https://ansible.com:4433/'
- handler = urls.maybe_add_ssl_handler(url, True)
- assert handler.hostname == 'ansible.com'
- assert handler.port == 4433
-
- url = 'https://user:passwd@ansible.com:4433/'
- handler = urls.maybe_add_ssl_handler(url, True)
- assert handler.hostname == 'ansible.com'
- assert handler.port == 4433
-
- url = 'https://ansible.com/'
- handler = urls.maybe_add_ssl_handler(url, True)
- assert handler.hostname == 'ansible.com'
- assert handler.port == 443
-
- url = 'http://ansible.com/'
- handler = urls.maybe_add_ssl_handler(url, True)
- assert handler is None
-
- url = 'https://[2a00:16d8:0:7::205]:4443/'
- handler = urls.maybe_add_ssl_handler(url, True)
- assert handler.hostname == '2a00:16d8:0:7::205'
- assert handler.port == 4443
-
- url = 'https://[2a00:16d8:0:7::205]/'
- handler = urls.maybe_add_ssl_handler(url, True)
- assert handler.hostname == '2a00:16d8:0:7::205'
- assert handler.port == 443
def test_basic_auth_header():
@@ -103,7 +23,7 @@ def test_ParseResultDottedDict():
def test_unix_socket_patch_httpconnection_connect(mocker):
unix_conn = mocker.patch.object(urls.UnixHTTPConnection, 'connect')
- conn = urls.httplib.HTTPConnection('ansible.com')
+ conn = urls.http.client.HTTPConnection('ansible.com')
with urls.unix_socket_patch_httpconnection_connect():
conn.connect()
assert unix_conn.call_count == 1
diff --git a/test/units/modules/conftest.py b/test/units/modules/conftest.py
index c60c586..f94b236 100644
--- a/test/units/modules/conftest.py
+++ b/test/units/modules/conftest.py
@@ -1,8 +1,7 @@
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/units/modules/test_apt.py b/test/units/modules/test_apt.py
index a5aa4a9..d207320 100644
--- a/test/units/modules/test_apt.py
+++ b/test/units/modules/test_apt.py
@@ -1,46 +1,45 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+# Copyright: Contributors to the Ansible project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+from __future__ import annotations
import collections
-from units.compat.mock import Mock
-from units.compat import unittest
-
-from ansible.modules.apt import (
- expand_pkgspec_from_fnmatches,
+from ansible.modules.apt import expand_pkgspec_from_fnmatches
+import pytest
+
+FakePackage = collections.namedtuple("Package", ("name",))
+fake_cache = [
+ FakePackage("apt"),
+ FakePackage("apt-utils"),
+ FakePackage("not-selected"),
+]
+
+
+@pytest.mark.parametrize(
+ ("test_input", "expected"),
+ [
+ pytest.param(
+ ["apt"],
+ ["apt"],
+ id="trivial",
+ ),
+ pytest.param(
+ ["apt=1.0*"],
+ ["apt=1.0*"],
+ id="version-wildcard",
+ ),
+ pytest.param(
+ ["apt*=1.0*"],
+ ["apt", "apt-utils"],
+ id="pkgname-wildcard-version",
+ ),
+ pytest.param(
+ ["apt*"],
+ ["apt", "apt-utils"],
+ id="pkgname-expands",
+ ),
+ ],
)
-
-
-class AptExpandPkgspecTestCase(unittest.TestCase):
-
- def setUp(self):
- FakePackage = collections.namedtuple("Package", ("name",))
- self.fake_cache = [
- FakePackage("apt"),
- FakePackage("apt-utils"),
- FakePackage("not-selected"),
- ]
-
- def test_trivial(self):
- pkg = ["apt"]
- self.assertEqual(
- expand_pkgspec_from_fnmatches(None, pkg, self.fake_cache), pkg)
-
- def test_version_wildcard(self):
- pkg = ["apt=1.0*"]
- self.assertEqual(
- expand_pkgspec_from_fnmatches(None, pkg, self.fake_cache), pkg)
-
- def test_pkgname_wildcard_version_wildcard(self):
- pkg = ["apt*=1.0*"]
- m_mock = Mock()
- self.assertEqual(
- expand_pkgspec_from_fnmatches(m_mock, pkg, self.fake_cache),
- ['apt', 'apt-utils'])
-
- def test_pkgname_expands(self):
- pkg = ["apt*"]
- m_mock = Mock()
- self.assertEqual(
- expand_pkgspec_from_fnmatches(m_mock, pkg, self.fake_cache),
- ["apt", "apt-utils"])
+def test_expand_pkgspec_from_fnmatches(test_input, expected):
+ """Test positive cases of ``expand_pkgspec_from_fnmatches``."""
+ assert expand_pkgspec_from_fnmatches(None, test_input, fake_cache) == expected
diff --git a/test/units/modules/test_apt_key.py b/test/units/modules/test_apt_key.py
index 37cd53b..051dc2e 100644
--- a/test/units/modules/test_apt_key.py
+++ b/test/units/modules/test_apt_key.py
@@ -1,10 +1,9 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
-from units.compat.mock import patch, Mock
-from units.compat import unittest
+from unittest.mock import patch, Mock
+import unittest
from ansible.modules import apt_key
diff --git a/test/units/modules/test_async_wrapper.py b/test/units/modules/test_async_wrapper.py
index dbaf683..1e3b02f 100644
--- a/test/units/modules/test_async_wrapper.py
+++ b/test/units/modules/test_async_wrapper.py
@@ -1,7 +1,6 @@
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
diff --git a/test/units/modules/test_copy.py b/test/units/modules/test_copy.py
index beeef6d..49e3324 100644
--- a/test/units/modules/test_copy.py
+++ b/test/units/modules/test_copy.py
@@ -3,9 +3,7 @@
# (c) 2018 Ansible Project
# License: GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/modules/test_hostname.py b/test/units/modules/test_hostname.py
index 1aa4a57..20b8336 100644
--- a/test/units/modules/test_hostname.py
+++ b/test/units/modules/test_hostname.py
@@ -1,15 +1,13 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import shutil
import tempfile
-from units.compat.mock import patch, MagicMock, mock_open
+from unittest.mock import patch, MagicMock, mock_open
from ansible.module_utils.common._utils import get_all_subclasses
from ansible.modules import hostname
from units.modules.utils import ModuleTestCase, set_module_args
-from ansible.module_utils.six import PY2
class TestHostname(ModuleTestCase):
@@ -28,8 +26,6 @@ class TestHostname(ModuleTestCase):
m = mock_open()
builtins = 'builtins'
- if PY2:
- builtins = '__builtin__'
with patch('%s.open' % builtins, m):
instance.get_permanent_hostname()
instance.get_current_hostname()
diff --git a/test/units/modules/test_iptables.py b/test/units/modules/test_iptables.py
index 2459cf7..67e3909 100644
--- a/test/units/modules/test_iptables.py
+++ b/test/units/modules/test_iptables.py
@@ -1,1170 +1,1430 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+# Copyright: Contributors to the Ansible project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+from __future__ import annotations
+
+from units.modules.utils import AnsibleExitJson, AnsibleFailJson, set_module_args, fail_json, exit_json
+import pytest
-from units.compat.mock import patch
-from ansible.module_utils import basic
from ansible.modules import iptables
-from units.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args
-
-
-def get_bin_path(*args, **kwargs):
- return "/sbin/iptables"
-
-
-def get_iptables_version(iptables_path, module):
- return "1.8.2"
-
-
-class TestIptables(ModuleTestCase):
-
- def setUp(self):
- super(TestIptables, self).setUp()
- self.mock_get_bin_path = patch.object(basic.AnsibleModule, 'get_bin_path', get_bin_path)
- self.mock_get_bin_path.start()
- self.addCleanup(self.mock_get_bin_path.stop) # ensure that the patching is 'undone'
- self.mock_get_iptables_version = patch.object(iptables, 'get_iptables_version', get_iptables_version)
- self.mock_get_iptables_version.start()
- self.addCleanup(self.mock_get_iptables_version.stop) # ensure that the patching is 'undone'
-
- def test_without_required_parameters(self):
- """Failure must occurs when all parameters are missing"""
- with self.assertRaises(AnsibleFailJson):
- set_module_args({})
- iptables.main()
-
- def test_flush_table_without_chain(self):
- """Test flush without chain, flush the table"""
- set_module_args({
- 'flush': True,
- })
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.return_value = 0, '', '' # successful execution, no output
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args[0][0][0], '/sbin/iptables')
- self.assertEqual(run_command.call_args[0][0][1], '-t')
- self.assertEqual(run_command.call_args[0][0][2], 'filter')
- self.assertEqual(run_command.call_args[0][0][3], '-F')
-
- def test_flush_table_check_true(self):
- """Test flush without parameters and check == true"""
- set_module_args({
- 'flush': True,
- '_ansible_check_mode': True,
- })
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.return_value = 0, '', '' # successful execution, no output
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 0)
-
-# TODO ADD test flush table nat
-# TODO ADD test flush with chain
-# TODO ADD test flush with chain and table nat
-
- def test_policy_table(self):
- """Test change policy of a chain"""
- set_module_args({
- 'policy': 'ACCEPT',
- 'chain': 'INPUT',
- })
- commands_results = [
- (0, 'Chain INPUT (policy DROP)\n', ''),
- (0, '', '')
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 2)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-L',
- 'INPUT',
- ])
- self.assertEqual(run_command.call_args_list[1][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-P',
- 'INPUT',
- 'ACCEPT',
- ])
-
- def test_policy_table_no_change(self):
- """Test don't change policy of a chain if the policy is right"""
- set_module_args({
- 'policy': 'ACCEPT',
- 'chain': 'INPUT',
- })
- commands_results = [
- (0, 'Chain INPUT (policy ACCEPT)\n', ''),
- (0, '', '')
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertFalse(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-L',
- 'INPUT',
- ])
-
- def test_policy_table_changed_false(self):
- """Test flush without parameters and change == false"""
- set_module_args({
- 'policy': 'ACCEPT',
- 'chain': 'INPUT',
- '_ansible_check_mode': True,
- })
- commands_results = [
- (0, 'Chain INPUT (policy DROP)\n', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-L',
- 'INPUT',
- ])
+
+IPTABLES_CMD = "/sbin/iptables"
+IPTABLES_VERSION = "1.8.2"
+CONST_INPUT_FILTER = [IPTABLES_CMD, "-t", "filter", "-L", "INPUT",]
+
+
+@pytest.fixture
+def _mock_basic_commands(mocker):
+ """Mock basic commands like get_bin_path and get_iptables_version."""
+ mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.get_bin_path",
+ return_value=IPTABLES_CMD,
+ )
+ mocker.patch("ansible.modules.iptables.get_iptables_version", return_value=IPTABLES_VERSION)
+
+
+def test_without_required_parameters(mocker):
+ """Test module without any parameters."""
+ mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.fail_json",
+ side_effect=fail_json,
+ )
+ set_module_args({})
+ with pytest.raises(AnsibleFailJson) as exc:
+ iptables.main()
+
+ assert exc.value.args[0]["failed"]
+ assert "Failed to find required executable" in exc.value.args[0]["msg"]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_flush_table_without_chain(mocker):
+ """Test flush without chain, flush the table."""
+ set_module_args(
+ {
+ "flush": True,
+ }
+ )
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command", return_value=(0, "", "")
+ )
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args[0][0]
+ assert first_cmd_args_list[0], IPTABLES_CMD
+ assert first_cmd_args_list[1], "-t"
+ assert first_cmd_args_list[2], "filter"
+ assert first_cmd_args_list[3], "-F"
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_flush_table_check_true(mocker):
+ """Test flush without parameters and check == true."""
+ set_module_args(
+ {
+ "flush": True,
+ "_ansible_check_mode": True,
+ }
+ )
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command", return_value=(0, "", "")
+ )
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 0
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_policy_table(mocker):
+ """Test change policy of a chain."""
+ set_module_args(
+ {
+ "policy": "ACCEPT",
+ "chain": "INPUT",
+ }
+ )
+ commands_results = [(0, "Chain INPUT (policy DROP)\n", ""), (0, "", "")]
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 2
+ first_cmd_args_list = run_command.call_args_list[0]
+ second_cmd_args_list = run_command.call_args_list[1]
+ assert first_cmd_args_list[0][0] == CONST_INPUT_FILTER
+ assert second_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-P",
+ "INPUT",
+ "ACCEPT",
+ ]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+@pytest.mark.parametrize(
+ ("test_input", "commands_results"),
+ [
+ pytest.param(
+ {
+ "policy": "ACCEPT",
+ "chain": "INPUT",
+ "_ansible_check_mode": True,
+ },
+ [
+ (0, "Chain INPUT (policy DROP)\n", ""),
+ ],
+ id="policy-table-no-change",
+ ),
+ pytest.param(
+ {
+ "policy": "ACCEPT",
+ "chain": "INPUT",
+ },
+ [
+ (0, "Chain INPUT (policy ACCEPT)\n", ""),
+ (0, "", ""),
+ ],
+ id="policy-table-change-false",
+ )
+ ]
+)
+def test_policy_table_flush(mocker, test_input, commands_results):
+ """Test flush without parameters and change == false."""
+ set_module_args(test_input)
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == CONST_INPUT_FILTER
+
# TODO ADD test policy without chain fail
# TODO ADD test policy with chain don't exists
# TODO ADD test policy with wrong choice fail
- def test_insert_rule_change_false(self):
- """Test flush without parameters"""
- set_module_args({
- 'chain': 'OUTPUT',
- 'source': '1.2.3.4/32',
- 'destination': '7.8.9.10/42',
- 'jump': 'ACCEPT',
- 'action': 'insert',
- '_ansible_check_mode': True,
- })
-
- commands_results = [
- (1, '', ''), # check_rule_present
- (0, '', ''), # check_chain_present
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-C',
- 'OUTPUT',
- '-s',
- '1.2.3.4/32',
- '-d',
- '7.8.9.10/42',
- '-j',
- 'ACCEPT'
- ])
-
- def test_insert_rule(self):
- """Test flush without parameters"""
- set_module_args({
- 'chain': 'OUTPUT',
- 'source': '1.2.3.4/32',
- 'destination': '7.8.9.10/42',
- 'jump': 'ACCEPT',
- 'action': 'insert'
- })
-
- commands_results = [
- (1, '', ''), # check_rule_present
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 2)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-C',
- 'OUTPUT',
- '-s',
- '1.2.3.4/32',
- '-d',
- '7.8.9.10/42',
- '-j',
- 'ACCEPT'
- ])
- self.assertEqual(run_command.call_args_list[1][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-I',
- 'OUTPUT',
- '-s',
- '1.2.3.4/32',
- '-d',
- '7.8.9.10/42',
- '-j',
- 'ACCEPT'
- ])
-
- def test_append_rule_check_mode(self):
- """Test append a redirection rule in check mode"""
- set_module_args({
- 'chain': 'PREROUTING',
- 'source': '1.2.3.4/32',
- 'destination': '7.8.9.10/42',
- 'jump': 'REDIRECT',
- 'table': 'nat',
- 'to_destination': '5.5.5.5/32',
- 'protocol': 'udp',
- 'destination_port': '22',
- 'to_ports': '8600',
- '_ansible_check_mode': True,
- })
-
- commands_results = [
- (1, '', ''), # check_rule_present
- (0, '', ''), # check_chain_present
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'nat',
- '-C',
- 'PREROUTING',
- '-p',
- 'udp',
- '-s',
- '1.2.3.4/32',
- '-d',
- '7.8.9.10/42',
- '-j',
- 'REDIRECT',
- '--to-destination',
- '5.5.5.5/32',
- '--destination-port',
- '22',
- '--to-ports',
- '8600'
- ])
-
- def test_append_rule(self):
- """Test append a redirection rule"""
- set_module_args({
- 'chain': 'PREROUTING',
- 'source': '1.2.3.4/32',
- 'destination': '7.8.9.10/42',
- 'jump': 'REDIRECT',
- 'table': 'nat',
- 'to_destination': '5.5.5.5/32',
- 'protocol': 'udp',
- 'destination_port': '22',
- 'to_ports': '8600'
- })
-
- commands_results = [
- (1, '', ''), # check_rule_present
- (0, '', ''), # check_chain_present
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 2)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'nat',
- '-C',
- 'PREROUTING',
- '-p',
- 'udp',
- '-s',
- '1.2.3.4/32',
- '-d',
- '7.8.9.10/42',
- '-j',
- 'REDIRECT',
- '--to-destination',
- '5.5.5.5/32',
- '--destination-port',
- '22',
- '--to-ports',
- '8600'
- ])
- self.assertEqual(run_command.call_args_list[1][0][0], [
- '/sbin/iptables',
- '-t',
- 'nat',
- '-A',
- 'PREROUTING',
- '-p',
- 'udp',
- '-s',
- '1.2.3.4/32',
- '-d',
- '7.8.9.10/42',
- '-j',
- 'REDIRECT',
- '--to-destination',
- '5.5.5.5/32',
- '--destination-port',
- '22',
- '--to-ports',
- '8600'
- ])
-
- def test_remove_rule(self):
- """Test flush without parameters"""
- set_module_args({
- 'chain': 'PREROUTING',
- 'source': '1.2.3.4/32',
- 'destination': '7.8.9.10/42',
- 'jump': 'SNAT',
- 'table': 'nat',
- 'to_source': '5.5.5.5/32',
- 'protocol': 'udp',
- 'source_port': '22',
- 'to_ports': '8600',
- 'state': 'absent',
- 'in_interface': 'eth0',
- 'out_interface': 'eth1',
- 'comment': 'this is a comment'
- })
-
- commands_results = [
- (0, '', ''),
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 2)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'nat',
- '-C',
- 'PREROUTING',
- '-p',
- 'udp',
- '-s',
- '1.2.3.4/32',
- '-d',
- '7.8.9.10/42',
- '-j',
- 'SNAT',
- '--to-source',
- '5.5.5.5/32',
- '-i',
- 'eth0',
- '-o',
- 'eth1',
- '--source-port',
- '22',
- '--to-ports',
- '8600',
- '-m',
- 'comment',
- '--comment',
- 'this is a comment'
- ])
- self.assertEqual(run_command.call_args_list[1][0][0], [
- '/sbin/iptables',
- '-t',
- 'nat',
- '-D',
- 'PREROUTING',
- '-p',
- 'udp',
- '-s',
- '1.2.3.4/32',
- '-d',
- '7.8.9.10/42',
- '-j',
- 'SNAT',
- '--to-source',
- '5.5.5.5/32',
- '-i',
- 'eth0',
- '-o',
- 'eth1',
- '--source-port',
- '22',
- '--to-ports',
- '8600',
- '-m',
- 'comment',
- '--comment',
- 'this is a comment'
- ])
-
- def test_remove_rule_check_mode(self):
- """Test flush without parameters check mode"""
- set_module_args({
- 'chain': 'PREROUTING',
- 'source': '1.2.3.4/32',
- 'destination': '7.8.9.10/42',
- 'jump': 'SNAT',
- 'table': 'nat',
- 'to_source': '5.5.5.5/32',
- 'protocol': 'udp',
- 'source_port': '22',
- 'to_ports': '8600',
- 'state': 'absent',
- 'in_interface': 'eth0',
- 'out_interface': 'eth1',
- 'comment': 'this is a comment',
- '_ansible_check_mode': True,
- })
-
- commands_results = [
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'nat',
- '-C',
- 'PREROUTING',
- '-p',
- 'udp',
- '-s',
- '1.2.3.4/32',
- '-d',
- '7.8.9.10/42',
- '-j',
- 'SNAT',
- '--to-source',
- '5.5.5.5/32',
- '-i',
- 'eth0',
- '-o',
- 'eth1',
- '--source-port',
- '22',
- '--to-ports',
- '8600',
- '-m',
- 'comment',
- '--comment',
- 'this is a comment'
- ])
-
- def test_insert_with_reject(self):
- """ Using reject_with with a previously defined jump: REJECT results in two Jump statements #18988 """
- set_module_args({
- 'chain': 'INPUT',
- 'protocol': 'tcp',
- 'reject_with': 'tcp-reset',
- 'ip_version': 'ipv4',
- })
- commands_results = [
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-C',
- 'INPUT',
- '-p',
- 'tcp',
- '-j',
- 'REJECT',
- '--reject-with',
- 'tcp-reset',
- ])
-
- def test_insert_jump_reject_with_reject(self):
- """ Using reject_with with a previously defined jump: REJECT results in two Jump statements #18988 """
- set_module_args({
- 'chain': 'INPUT',
- 'protocol': 'tcp',
- 'jump': 'REJECT',
- 'reject_with': 'tcp-reset',
- 'ip_version': 'ipv4',
- })
- commands_results = [
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-C',
- 'INPUT',
- '-p',
- 'tcp',
- '-j',
- 'REJECT',
- '--reject-with',
- 'tcp-reset',
- ])
-
- def test_jump_tee_gateway_negative(self):
- """ Missing gateway when JUMP is set to TEE """
- set_module_args({
- 'table': 'mangle',
- 'chain': 'PREROUTING',
- 'in_interface': 'eth0',
- 'protocol': 'udp',
- 'match': 'state',
- 'jump': 'TEE',
- 'ctstate': ['NEW'],
- 'destination_port': '9521',
- 'destination': '127.0.0.1'
- })
-
- with self.assertRaises(AnsibleFailJson) as e:
- iptables.main()
- self.assertTrue(e.exception.args[0]['failed'])
- self.assertEqual(e.exception.args[0]['msg'], 'jump is TEE but all of the following are missing: gateway')
-
- def test_jump_tee_gateway(self):
- """ Using gateway when JUMP is set to TEE """
- set_module_args({
- 'table': 'mangle',
- 'chain': 'PREROUTING',
- 'in_interface': 'eth0',
- 'protocol': 'udp',
- 'match': 'state',
- 'jump': 'TEE',
- 'ctstate': ['NEW'],
- 'destination_port': '9521',
- 'gateway': '192.168.10.1',
- 'destination': '127.0.0.1'
- })
- commands_results = [
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t', 'mangle',
- '-C', 'PREROUTING',
- '-p', 'udp',
- '-d', '127.0.0.1',
- '-m', 'state',
- '-j', 'TEE',
- '--gateway', '192.168.10.1',
- '-i', 'eth0',
- '--destination-port', '9521',
- '--state', 'NEW'
- ])
-
- def test_tcp_flags(self):
- """ Test various ways of inputting tcp_flags """
- args = [
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_insert_rule_change_false(mocker):
+ """Test flush without parameters."""
+ set_module_args(
+ {
+ "chain": "OUTPUT",
+ "source": "1.2.3.4/32",
+ "destination": "7.8.9.10/42",
+ "jump": "ACCEPT",
+ "action": "insert",
+ "_ansible_check_mode": True,
+ }
+ )
+ commands_results = [
+ (1, "", ""), # check_rule_present
+ (0, "", ""), # check_chain_present
+ ]
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "OUTPUT",
+ "-s",
+ "1.2.3.4/32",
+ "-d",
+ "7.8.9.10/42",
+ "-j",
+ "ACCEPT",
+ ]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_insert_rule(mocker):
+ """Test flush without parameters."""
+ set_module_args(
+ {
+ "chain": "OUTPUT",
+ "source": "1.2.3.4/32",
+ "destination": "7.8.9.10/42",
+ "jump": "ACCEPT",
+ "action": "insert",
+ }
+ )
+ commands_results = [
+ (1, "", ""), # check_rule_present
+ (0, "", ""),
+ ]
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 2
+ first_cmd_args_list = run_command.call_args_list[0]
+ second_cmd_args_list = run_command.call_args_list[1]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "OUTPUT",
+ "-s",
+ "1.2.3.4/32",
+ "-d",
+ "7.8.9.10/42",
+ "-j",
+ "ACCEPT",
+ ]
+ assert second_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-I",
+ "OUTPUT",
+ "-s",
+ "1.2.3.4/32",
+ "-d",
+ "7.8.9.10/42",
+ "-j",
+ "ACCEPT",
+ ]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_append_rule_check_mode(mocker):
+ """Test append a redirection rule in check mode."""
+ set_module_args(
+ {
+ "chain": "PREROUTING",
+ "source": "1.2.3.4/32",
+ "destination": "7.8.9.10/42",
+ "jump": "REDIRECT",
+ "table": "nat",
+ "to_destination": "5.5.5.5/32",
+ "protocol": "udp",
+ "destination_port": "22",
+ "to_ports": "8600",
+ "_ansible_check_mode": True,
+ }
+ )
+
+ commands_results = [
+ (1, "", ""), # check_rule_present
+ (0, "", ""), # check_chain_present
+ ]
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "nat",
+ "-C",
+ "PREROUTING",
+ "-p",
+ "udp",
+ "-s",
+ "1.2.3.4/32",
+ "-d",
+ "7.8.9.10/42",
+ "-j",
+ "REDIRECT",
+ "--to-destination",
+ "5.5.5.5/32",
+ "--destination-port",
+ "22",
+ "--to-ports",
+ "8600",
+ ]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_append_rule(mocker):
+ """Test append a redirection rule."""
+ set_module_args(
+ {
+ "chain": "PREROUTING",
+ "source": "1.2.3.4/32",
+ "destination": "7.8.9.10/42",
+ "jump": "REDIRECT",
+ "table": "nat",
+ "to_destination": "5.5.5.5/32",
+ "protocol": "udp",
+ "destination_port": "22",
+ "to_ports": "8600",
+ }
+ )
+
+ commands_results = [
+ (1, "", ""), # check_rule_present
+ (0, "", ""), # check_chain_present
+ (0, "", ""),
+ ]
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 2
+ first_cmd_args_list = run_command.call_args_list[0]
+ second_cmd_args_list = run_command.call_args_list[1]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "nat",
+ "-C",
+ "PREROUTING",
+ "-p",
+ "udp",
+ "-s",
+ "1.2.3.4/32",
+ "-d",
+ "7.8.9.10/42",
+ "-j",
+ "REDIRECT",
+ "--to-destination",
+ "5.5.5.5/32",
+ "--destination-port",
+ "22",
+ "--to-ports",
+ "8600",
+ ]
+ assert second_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "nat",
+ "-A",
+ "PREROUTING",
+ "-p",
+ "udp",
+ "-s",
+ "1.2.3.4/32",
+ "-d",
+ "7.8.9.10/42",
+ "-j",
+ "REDIRECT",
+ "--to-destination",
+ "5.5.5.5/32",
+ "--destination-port",
+ "22",
+ "--to-ports",
+ "8600",
+ ]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_remove_rule(mocker):
+ """Test flush without parameters."""
+ set_module_args(
+ {
+ "chain": "PREROUTING",
+ "source": "1.2.3.4/32",
+ "destination": "7.8.9.10/42",
+ "jump": "SNAT",
+ "table": "nat",
+ "to_source": "5.5.5.5/32",
+ "protocol": "udp",
+ "source_port": "22",
+ "to_ports": "8600",
+ "state": "absent",
+ "in_interface": "eth0",
+ "out_interface": "eth1",
+ "comment": "this is a comment",
+ }
+ )
+
+ commands_results = [
+ (0, "", ""),
+ (0, "", ""),
+ ]
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 2
+ first_cmd_args_list = run_command.call_args_list[0]
+ second_cmd_args_list = run_command.call_args_list[1]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "nat",
+ "-C",
+ "PREROUTING",
+ "-p",
+ "udp",
+ "-s",
+ "1.2.3.4/32",
+ "-d",
+ "7.8.9.10/42",
+ "-j",
+ "SNAT",
+ "--to-source",
+ "5.5.5.5/32",
+ "-i",
+ "eth0",
+ "-o",
+ "eth1",
+ "--source-port",
+ "22",
+ "--to-ports",
+ "8600",
+ "-m",
+ "comment",
+ "--comment",
+ "this is a comment",
+ ]
+ assert second_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "nat",
+ "-D",
+ "PREROUTING",
+ "-p",
+ "udp",
+ "-s",
+ "1.2.3.4/32",
+ "-d",
+ "7.8.9.10/42",
+ "-j",
+ "SNAT",
+ "--to-source",
+ "5.5.5.5/32",
+ "-i",
+ "eth0",
+ "-o",
+ "eth1",
+ "--source-port",
+ "22",
+ "--to-ports",
+ "8600",
+ "-m",
+ "comment",
+ "--comment",
+ "this is a comment",
+ ]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_remove_rule_check_mode(mocker):
+ """Test flush without parameters check mode."""
+ set_module_args(
+ {
+ "chain": "PREROUTING",
+ "source": "1.2.3.4/32",
+ "destination": "7.8.9.10/42",
+ "jump": "SNAT",
+ "table": "nat",
+ "to_source": "5.5.5.5/32",
+ "protocol": "udp",
+ "source_port": "22",
+ "to_ports": "8600",
+ "state": "absent",
+ "in_interface": "eth0",
+ "out_interface": "eth1",
+ "comment": "this is a comment",
+ "_ansible_check_mode": True,
+ }
+ )
+
+ commands_results = [
+ (0, "", ""),
+ ]
+
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "nat",
+ "-C",
+ "PREROUTING",
+ "-p",
+ "udp",
+ "-s",
+ "1.2.3.4/32",
+ "-d",
+ "7.8.9.10/42",
+ "-j",
+ "SNAT",
+ "--to-source",
+ "5.5.5.5/32",
+ "-i",
+ "eth0",
+ "-o",
+ "eth1",
+ "--source-port",
+ "22",
+ "--to-ports",
+ "8600",
+ "-m",
+ "comment",
+ "--comment",
+ "this is a comment",
+ ]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+@pytest.mark.parametrize(
+ ("test_input", "expected"),
+ [
+ pytest.param(
{
- 'chain': 'OUTPUT',
- 'protocol': 'tcp',
- 'jump': 'DROP',
- 'tcp_flags': 'flags=ALL flags_set="ACK,RST,SYN,FIN"'
+ "chain": "INPUT",
+ "protocol": "tcp",
+ "reject_with": "tcp-reset",
+ "ip_version": "ipv4",
},
+ [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "INPUT",
+ "-p",
+ "tcp",
+ "-j",
+ "REJECT",
+ "--reject-with",
+ "tcp-reset",
+ ],
+ id="insert-reject-with",
+ ),
+ pytest.param(
{
- 'chain': 'OUTPUT',
- 'protocol': 'tcp',
- 'jump': 'DROP',
- 'tcp_flags': {
- 'flags': 'ALL',
- 'flags_set': 'ACK,RST,SYN,FIN'
- }
+ "chain": "INPUT",
+ "protocol": "tcp",
+ "jump": "REJECT",
+ "reject_with": "tcp-reset",
+ "ip_version": "ipv4",
},
+ [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "INPUT",
+ "-p",
+ "tcp",
+ "-j",
+ "REJECT",
+ "--reject-with",
+ "tcp-reset",
+ ],
+ id="update-reject-with",
+ ),
+ ]
+)
+def test_insert_with_reject(mocker, test_input, expected):
+ """Using reject_with with a previously defined jump: REJECT results in two Jump statements #18988."""
+ set_module_args(test_input)
+ commands_results = [
+ (0, "", ""),
+ ]
+
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == expected
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_jump_tee_gateway_negative(mocker):
+ """Missing gateway when JUMP is set to TEE."""
+ set_module_args(
+ {
+ "table": "mangle",
+ "chain": "PREROUTING",
+ "in_interface": "eth0",
+ "protocol": "udp",
+ "match": "state",
+ "jump": "TEE",
+ "ctstate": ["NEW"],
+ "destination_port": "9521",
+ "destination": "127.0.0.1",
+ }
+ )
+ mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.fail_json",
+ side_effect=fail_json,
+ )
+ jump_err_msg = "jump is TEE but all of the following are missing: gateway"
+ with pytest.raises(AnsibleFailJson, match=jump_err_msg) as exc:
+ iptables.main()
+ assert exc.value.args[0]["failed"]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_jump_tee_gateway(mocker):
+ """Using gateway when JUMP is set to TEE."""
+ set_module_args(
+ {
+ "table": "mangle",
+ "chain": "PREROUTING",
+ "in_interface": "eth0",
+ "protocol": "udp",
+ "match": "state",
+ "jump": "TEE",
+ "ctstate": ["NEW"],
+ "destination_port": "9521",
+ "gateway": "192.168.10.1",
+ "destination": "127.0.0.1",
+ }
+ )
+ commands_results = [
+ (0, "", ""),
+ ]
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "mangle",
+ "-C",
+ "PREROUTING",
+ "-p",
+ "udp",
+ "-d",
+ "127.0.0.1",
+ "-m",
+ "state",
+ "-j",
+ "TEE",
+ "--gateway",
+ "192.168.10.1",
+ "-i",
+ "eth0",
+ "--destination-port",
+ "9521",
+ "--state",
+ "NEW",
+ ]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+@pytest.mark.parametrize(
+ ("test_input"),
+ [
+ pytest.param(
+ 'flags=ALL flags_set="ACK,RST,SYN,FIN"',
+ id="tcp-flags-str"
+ ),
+ pytest.param(
{
- 'chain': 'OUTPUT',
- 'protocol': 'tcp',
- 'jump': 'DROP',
- 'tcp_flags': {
- 'flags': ['ALL'],
- 'flags_set': ['ACK', 'RST', 'SYN', 'FIN']
- }
+ "flags": "ALL", "flags_set": "ACK,RST,SYN,FIN"
},
-
- ]
-
- for item in args:
- set_module_args(item)
-
- commands_results = [
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-C',
- 'OUTPUT',
- '-p',
- 'tcp',
- '--tcp-flags',
- 'ALL',
- 'ACK,RST,SYN,FIN',
- '-j',
- 'DROP'
- ])
-
- def test_log_level(self):
- """ Test various ways of log level flag """
-
- log_levels = ['0', '1', '2', '3', '4', '5', '6', '7',
- 'emerg', 'alert', 'crit', 'error', 'warning', 'notice', 'info', 'debug']
-
- for log_lvl in log_levels:
- set_module_args({
- 'chain': 'INPUT',
- 'jump': 'LOG',
- 'log_level': log_lvl,
- 'source': '1.2.3.4/32',
- 'log_prefix': '** DROP-this_ip **'
- })
- commands_results = [
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t', 'filter',
- '-C', 'INPUT',
- '-s', '1.2.3.4/32',
- '-j', 'LOG',
- '--log-prefix', '** DROP-this_ip **',
- '--log-level', log_lvl
- ])
-
- def test_iprange(self):
- """ Test iprange module with its flags src_range and dst_range """
- set_module_args({
- 'chain': 'INPUT',
- 'match': ['iprange'],
- 'src_range': '192.168.1.100-192.168.1.199',
- 'jump': 'ACCEPT'
- })
-
- commands_results = [
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-C',
- 'INPUT',
- '-m',
- 'iprange',
- '-j',
- 'ACCEPT',
- '--src-range',
- '192.168.1.100-192.168.1.199',
- ])
-
- set_module_args({
- 'chain': 'INPUT',
- 'src_range': '192.168.1.100-192.168.1.199',
- 'dst_range': '10.0.0.50-10.0.0.100',
- 'jump': 'ACCEPT'
- })
-
- commands_results = [
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-C',
- 'INPUT',
- '-j',
- 'ACCEPT',
- '-m',
- 'iprange',
- '--src-range',
- '192.168.1.100-192.168.1.199',
- '--dst-range',
- '10.0.0.50-10.0.0.100'
- ])
-
- set_module_args({
- 'chain': 'INPUT',
- 'dst_range': '10.0.0.50-10.0.0.100',
- 'jump': 'ACCEPT'
- })
-
- commands_results = [
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-C',
- 'INPUT',
- '-j',
- 'ACCEPT',
- '-m',
- 'iprange',
- '--dst-range',
- '10.0.0.50-10.0.0.100'
- ])
-
- def test_insert_rule_with_wait(self):
- """Test flush without parameters"""
- set_module_args({
- 'chain': 'OUTPUT',
- 'source': '1.2.3.4/32',
- 'destination': '7.8.9.10/42',
- 'jump': 'ACCEPT',
- 'action': 'insert',
- 'wait': '10'
- })
-
- commands_results = [
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-C',
- 'OUTPUT',
- '-w',
- '10',
- '-s',
- '1.2.3.4/32',
- '-d',
- '7.8.9.10/42',
- '-j',
- 'ACCEPT'
- ])
-
- def test_comment_position_at_end(self):
- """Test comment position to make sure it is at the end of command"""
- set_module_args({
- 'chain': 'INPUT',
- 'jump': 'ACCEPT',
- 'action': 'insert',
- 'ctstate': ['NEW'],
- 'comment': 'this is a comment',
- '_ansible_check_mode': True,
- })
-
- commands_results = [
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t',
- 'filter',
- '-C',
- 'INPUT',
- '-j',
- 'ACCEPT',
- '-m',
- 'conntrack',
- '--ctstate',
- 'NEW',
- '-m',
- 'comment',
- '--comment',
- 'this is a comment'
- ])
- self.assertEqual(run_command.call_args[0][0][14], 'this is a comment')
-
- def test_destination_ports(self):
- """ Test multiport module usage with multiple ports """
- set_module_args({
- 'chain': 'INPUT',
- 'protocol': 'tcp',
- 'in_interface': 'eth0',
- 'source': '192.168.0.1/32',
- 'destination_ports': ['80', '443', '8081:8085'],
- 'jump': 'ACCEPT',
- 'comment': 'this is a comment',
- })
- commands_results = [
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t', 'filter',
- '-C', 'INPUT',
- '-p', 'tcp',
- '-s', '192.168.0.1/32',
- '-j', 'ACCEPT',
- '-m', 'multiport',
- '--dports', '80,443,8081:8085',
- '-i', 'eth0',
- '-m', 'comment',
- '--comment', 'this is a comment'
- ])
-
- def test_match_set(self):
- """ Test match_set together with match_set_flags """
- set_module_args({
- 'chain': 'INPUT',
- 'protocol': 'tcp',
- 'match_set': 'admin_hosts',
- 'match_set_flags': 'src',
- 'destination_port': '22',
- 'jump': 'ACCEPT',
- 'comment': 'this is a comment',
- })
- commands_results = [
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t', 'filter',
- '-C', 'INPUT',
- '-p', 'tcp',
- '-j', 'ACCEPT',
- '--destination-port', '22',
- '-m', 'set',
- '--match-set', 'admin_hosts', 'src',
- '-m', 'comment',
- '--comment', 'this is a comment'
- ])
-
- set_module_args({
- 'chain': 'INPUT',
- 'protocol': 'udp',
- 'match_set': 'banned_hosts',
- 'match_set_flags': 'src,dst',
- 'jump': 'REJECT',
- })
- commands_results = [
- (0, '', ''),
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t', 'filter',
- '-C', 'INPUT',
- '-p', 'udp',
- '-j', 'REJECT',
- '-m', 'set',
- '--match-set', 'banned_hosts', 'src,dst'
- ])
-
- def test_chain_creation(self):
- """Test chain creation when absent"""
- set_module_args({
- 'chain': 'FOOBAR',
- 'state': 'present',
- 'chain_management': True,
- })
-
- commands_results = [
- (1, '', ''), # check_chain_present
- (0, '', ''), # create_chain
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 2)
-
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t', 'filter',
- '-L', 'FOOBAR',
- ])
-
- self.assertEqual(run_command.call_args_list[1][0][0], [
- '/sbin/iptables',
- '-t', 'filter',
- '-N', 'FOOBAR',
- ])
-
- commands_results = [
- (0, '', ''), # check_rule_present
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertFalse(result.exception.args[0]['changed'])
-
- def test_chain_creation_check_mode(self):
- """Test chain creation when absent"""
- set_module_args({
- 'chain': 'FOOBAR',
- 'state': 'present',
- 'chain_management': True,
- '_ansible_check_mode': True,
- })
-
- commands_results = [
- (1, '', ''), # check_rule_present
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
-
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t', 'filter',
- '-L', 'FOOBAR',
- ])
-
- commands_results = [
- (0, '', ''), # check_rule_present
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertFalse(result.exception.args[0]['changed'])
-
- def test_chain_deletion(self):
- """Test chain deletion when present"""
- set_module_args({
- 'chain': 'FOOBAR',
- 'state': 'absent',
- 'chain_management': True,
- })
-
- commands_results = [
- (0, '', ''), # check_chain_present
- (0, '', ''), # delete_chain
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 2)
-
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t', 'filter',
- '-L', 'FOOBAR',
- ])
-
- self.assertEqual(run_command.call_args_list[1][0][0], [
- '/sbin/iptables',
- '-t', 'filter',
- '-X', 'FOOBAR',
- ])
-
- commands_results = [
- (1, '', ''), # check_rule_present
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertFalse(result.exception.args[0]['changed'])
-
- def test_chain_deletion_check_mode(self):
- """Test chain deletion when present"""
- set_module_args({
- 'chain': 'FOOBAR',
- 'state': 'absent',
- 'chain_management': True,
- '_ansible_check_mode': True,
- })
-
- commands_results = [
- (0, '', ''), # check_chain_present
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertTrue(result.exception.args[0]['changed'])
-
- self.assertEqual(run_command.call_count, 1)
-
- self.assertEqual(run_command.call_args_list[0][0][0], [
- '/sbin/iptables',
- '-t', 'filter',
- '-L', 'FOOBAR',
- ])
-
- commands_results = [
- (1, '', ''), # check_rule_present
- ]
-
- with patch.object(basic.AnsibleModule, 'run_command') as run_command:
- run_command.side_effect = commands_results
- with self.assertRaises(AnsibleExitJson) as result:
- iptables.main()
- self.assertFalse(result.exception.args[0]['changed'])
+ id="tcp-flags-dict"
+ ),
+ pytest.param(
+ {
+ "flags": ["ALL"], "flags_set": ["ACK", "RST", "SYN", "FIN"]
+ },
+ id="tcp-flags-list"
+ ),
+ ],
+)
+def test_tcp_flags(mocker, test_input):
+ """Test various ways of inputting tcp_flags."""
+ rule_data = {
+ "chain": "OUTPUT",
+ "protocol": "tcp",
+ "jump": "DROP",
+ "tcp_flags": test_input,
+ }
+
+ set_module_args(rule_data)
+
+ commands_results = [
+ (0, "", ""),
+ ]
+
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "OUTPUT",
+ "-p",
+ "tcp",
+ "--tcp-flags",
+ "ALL",
+ "ACK,RST,SYN,FIN",
+ "-j",
+ "DROP",
+ ]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+@pytest.mark.parametrize(
+ "log_level",
+ [
+ "0",
+ "1",
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "emerg",
+ "alert",
+ "crit",
+ "error",
+ "warning",
+ "notice",
+ "info",
+ "debug",
+ ],
+)
+def test_log_level(mocker, log_level):
+ """Test various ways of log level flag."""
+
+ set_module_args(
+ {
+ "chain": "INPUT",
+ "jump": "LOG",
+ "log_level": log_level,
+ "source": "1.2.3.4/32",
+ "log_prefix": "** DROP-this_ip **",
+ }
+ )
+ commands_results = [
+ (0, "", ""),
+ ]
+
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "INPUT",
+ "-s",
+ "1.2.3.4/32",
+ "-j",
+ "LOG",
+ "--log-prefix",
+ "** DROP-this_ip **",
+ "--log-level",
+ log_level,
+ ]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+@pytest.mark.parametrize(
+ ("test_input", "expected"),
+ [
+ pytest.param(
+ {
+ "chain": "INPUT",
+ "match": ["iprange"],
+ "src_range": "192.168.1.100-192.168.1.199",
+ "jump": "ACCEPT",
+ },
+ [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "INPUT",
+ "-m",
+ "iprange",
+ "-j",
+ "ACCEPT",
+ "--src-range",
+ "192.168.1.100-192.168.1.199",
+ ],
+ id="src-range",
+ ),
+ pytest.param(
+ {
+ "chain": "INPUT",
+ "src_range": "192.168.1.100-192.168.1.199",
+ "dst_range": "10.0.0.50-10.0.0.100",
+ "jump": "ACCEPT",
+ },
+ [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "INPUT",
+ "-j",
+ "ACCEPT",
+ "-m",
+ "iprange",
+ "--src-range",
+ "192.168.1.100-192.168.1.199",
+ "--dst-range",
+ "10.0.0.50-10.0.0.100",
+ ],
+ id="src-range-dst-range",
+ ),
+ pytest.param(
+ {
+ "chain": "INPUT",
+ "dst_range": "10.0.0.50-10.0.0.100",
+ "jump": "ACCEPT"
+ },
+ [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "INPUT",
+ "-j",
+ "ACCEPT",
+ "-m",
+ "iprange",
+ "--dst-range",
+ "10.0.0.50-10.0.0.100",
+ ],
+ id="dst-range"
+ ),
+ ],
+)
+def test_iprange(mocker, test_input, expected):
+ """Test iprange module with its flags src_range and dst_range."""
+ set_module_args(test_input)
+
+ commands_results = [
+ (0, "", ""),
+ ]
+
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == expected
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_insert_rule_with_wait(mocker):
+ """Test flush without parameters."""
+ set_module_args(
+ {
+ "chain": "OUTPUT",
+ "source": "1.2.3.4/32",
+ "destination": "7.8.9.10/42",
+ "jump": "ACCEPT",
+ "action": "insert",
+ "wait": "10",
+ }
+ )
+
+ commands_results = [
+ (0, "", ""),
+ ]
+
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "OUTPUT",
+ "-w",
+ "10",
+ "-s",
+ "1.2.3.4/32",
+ "-d",
+ "7.8.9.10/42",
+ "-j",
+ "ACCEPT",
+ ]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_comment_position_at_end(mocker):
+ """Test comment position to make sure it is at the end of command."""
+ set_module_args(
+ {
+ "chain": "INPUT",
+ "jump": "ACCEPT",
+ "action": "insert",
+ "ctstate": ["NEW"],
+ "comment": "this is a comment",
+ "_ansible_check_mode": True,
+ }
+ )
+
+ commands_results = [
+ (0, "", ""),
+ ]
+
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "INPUT",
+ "-j",
+ "ACCEPT",
+ "-m",
+ "conntrack",
+ "--ctstate",
+ "NEW",
+ "-m",
+ "comment",
+ "--comment",
+ "this is a comment",
+ ]
+ assert run_command.call_args[0][0][14] == "this is a comment"
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_destination_ports(mocker):
+ """Test multiport module usage with multiple ports."""
+ set_module_args(
+ {
+ "chain": "INPUT",
+ "protocol": "tcp",
+ "in_interface": "eth0",
+ "source": "192.168.0.1/32",
+ "destination_ports": ["80", "443", "8081:8085"],
+ "jump": "ACCEPT",
+ "comment": "this is a comment",
+ }
+ )
+ commands_results = [
+ (0, "", ""),
+ ]
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "INPUT",
+ "-p",
+ "tcp",
+ "-s",
+ "192.168.0.1/32",
+ "-j",
+ "ACCEPT",
+ "-m",
+ "multiport",
+ "--dports",
+ "80,443,8081:8085",
+ "-i",
+ "eth0",
+ "-m",
+ "comment",
+ "--comment",
+ "this is a comment",
+ ]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+@pytest.mark.parametrize(
+ ("test_input", "expected"),
+ [
+ pytest.param(
+ {
+ "chain": "INPUT",
+ "protocol": "tcp",
+ "match_set": "admin_hosts",
+ "match_set_flags": "src",
+ "destination_port": "22",
+ "jump": "ACCEPT",
+ "comment": "this is a comment",
+ },
+ [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "INPUT",
+ "-p",
+ "tcp",
+ "-j",
+ "ACCEPT",
+ "--destination-port",
+ "22",
+ "-m",
+ "set",
+ "--match-set",
+ "admin_hosts",
+ "src",
+ "-m",
+ "comment",
+ "--comment",
+ "this is a comment",
+ ],
+ id="match-set-src",
+ ),
+ pytest.param(
+ {
+ "chain": "INPUT",
+ "protocol": "udp",
+ "match_set": "banned_hosts",
+ "match_set_flags": "src,dst",
+ "jump": "REJECT",
+ },
+ [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "INPUT",
+ "-p",
+ "udp",
+ "-j",
+ "REJECT",
+ "-m",
+ "set",
+ "--match-set",
+ "banned_hosts",
+ "src,dst",
+ ],
+ id="match-set-src-dst",
+ ),
+ pytest.param(
+ {
+ "chain": "INPUT",
+ "protocol": "udp",
+ "match_set": "banned_hosts_dst",
+ "match_set_flags": "dst,dst",
+ "jump": "REJECT",
+ },
+ [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "INPUT",
+ "-p",
+ "udp",
+ "-j",
+ "REJECT",
+ "-m",
+ "set",
+ "--match-set",
+ "banned_hosts_dst",
+ "dst,dst",
+ ],
+ id="match-set-dst-dst",
+ ),
+ pytest.param(
+ {
+ "chain": "INPUT",
+ "protocol": "udp",
+ "match_set": "banned_hosts",
+ "match_set_flags": "src,src",
+ "jump": "REJECT",
+ },
+ [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-C",
+ "INPUT",
+ "-p",
+ "udp",
+ "-j",
+ "REJECT",
+ "-m",
+ "set",
+ "--match-set",
+ "banned_hosts",
+ "src,src",
+ ],
+ id="match-set-src-src",
+ ),
+ ],
+)
+def test_match_set(mocker, test_input, expected):
+ """Test match_set together with match_set_flags."""
+ set_module_args(test_input)
+ commands_results = [
+ (0, "", ""),
+ ]
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(SystemExit):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == expected
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_chain_creation(mocker):
+ """Test chain creation when absent."""
+ set_module_args(
+ {
+ "chain": "FOOBAR",
+ "state": "present",
+ "chain_management": True,
+ }
+ )
+
+ commands_results = [
+ (1, "", ""), # check_chain_present
+ (0, "", ""), # create_chain
+ ]
+
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.exit_json",
+ side_effect=exit_json,
+ )
+ with pytest.raises(AnsibleExitJson):
+ iptables.main()
+
+ assert run_command.call_count == 2
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-L",
+ "FOOBAR",
+ ]
+
+ second_cmd_args_list = run_command.call_args_list[1]
+ assert second_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-N",
+ "FOOBAR",
+ ]
+
+ commands_results = [
+ (0, "", ""), # check_rule_present
+ ]
+
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(AnsibleExitJson) as exc:
+ iptables.main()
+ assert not exc.value.args[0]["changed"]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_chain_creation_check_mode(mocker):
+ """Test chain creation when absent in check mode."""
+ set_module_args(
+ {
+ "chain": "FOOBAR",
+ "state": "present",
+ "chain_management": True,
+ "_ansible_check_mode": True,
+ }
+ )
+
+ commands_results = [
+ (1, "", ""), # check_rule_present
+ ]
+
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.exit_json",
+ side_effect=exit_json,
+ )
+ with pytest.raises(AnsibleExitJson):
+ iptables.main()
+
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-L",
+ "FOOBAR",
+ ]
+
+ commands_results = [
+ (0, "", ""), # check_rule_present
+ ]
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+ with pytest.raises(AnsibleExitJson) as exc:
+ iptables.main()
+
+ assert not exc.value.args[0]["changed"]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_chain_deletion(mocker):
+ """Test chain deletion when present."""
+ set_module_args(
+ {
+ "chain": "FOOBAR",
+ "state": "absent",
+ "chain_management": True,
+ }
+ )
+
+ commands_results = [
+ (0, "", ""), # check_chain_present
+ (0, "", ""), # delete_chain
+ ]
+
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.exit_json",
+ side_effect=exit_json,
+ )
+ with pytest.raises(AnsibleExitJson) as exc:
+ iptables.main()
+
+ assert exc.value.args[0]["changed"]
+ assert run_command.call_count == 2
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-L",
+ "FOOBAR",
+ ]
+ second_cmd_args_list = run_command.call_args_list[1]
+ assert second_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-X",
+ "FOOBAR",
+ ]
+
+ commands_results = [
+ (1, "", ""), # check_rule_present
+ ]
+
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(AnsibleExitJson) as exc:
+ iptables.main()
+
+ assert not exc.value.args[0]["changed"]
+
+
+@pytest.mark.usefixtures('_mock_basic_commands')
+def test_chain_deletion_check_mode(mocker):
+ """Test chain deletion when present in check mode."""
+ set_module_args(
+ {
+ "chain": "FOOBAR",
+ "state": "absent",
+ "chain_management": True,
+ "_ansible_check_mode": True,
+ }
+ )
+
+ commands_results = [
+ (0, "", ""), # check_chain_present
+ ]
+
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.exit_json",
+ side_effect=exit_json,
+ )
+ with pytest.raises(AnsibleExitJson) as exc:
+ iptables.main()
+
+ assert exc.value.args[0]["changed"]
+ assert run_command.call_count == 1
+ first_cmd_args_list = run_command.call_args_list[0]
+ assert first_cmd_args_list[0][0] == [
+ IPTABLES_CMD,
+ "-t",
+ "filter",
+ "-L",
+ "FOOBAR",
+ ]
+
+ commands_results = [
+ (1, "", ""), # check_rule_present
+ ]
+
+ run_command = mocker.patch(
+ "ansible.module_utils.basic.AnsibleModule.run_command",
+ side_effect=commands_results,
+ )
+
+ with pytest.raises(AnsibleExitJson) as exc:
+ iptables.main()
+
+ assert not exc.value.args[0]["changed"]
diff --git a/test/units/modules/test_known_hosts.py b/test/units/modules/test_known_hosts.py
index 667f3e5..f98c998 100644
--- a/test/units/modules/test_known_hosts.py
+++ b/test/units/modules/test_known_hosts.py
@@ -1,11 +1,10 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import tempfile
from ansible.module_utils import basic
-from units.compat import unittest
+import unittest
from ansible.module_utils.common.text.converters import to_bytes
from ansible.module_utils.basic import AnsibleModule
diff --git a/test/units/modules/test_pip.py b/test/units/modules/test_pip.py
index 5640b80..7ddee22 100644
--- a/test/units/modules/test_pip.py
+++ b/test/units/modules/test_pip.py
@@ -1,7 +1,6 @@
# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
diff --git a/test/units/modules/test_service.py b/test/units/modules/test_service.py
index caabd74..684645e 100644
--- a/test/units/modules/test_service.py
+++ b/test/units/modules/test_service.py
@@ -2,9 +2,8 @@
# Copyright: (c) 2021, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
+from __future__ import annotations
-__metaclass__ = type
import json
import platform
@@ -12,7 +11,6 @@ import platform
import pytest
from ansible.modules import service
from ansible.module_utils.basic import AnsibleModule
-from ansible.module_utils.six import PY2
from units.modules.utils import set_module_args
@@ -29,7 +27,7 @@ def mocker_sunos_service(mocker):
# Read a mocked /etc/release file
mocked_etc_release_data = mocker.mock_open(
read_data=" Oracle Solaris 12.0")
- builtin_open = "__builtin__.open" if PY2 else "builtins.open"
+ builtin_open = "builtins.open"
mocker.patch(builtin_open, mocked_etc_release_data)
service_status = mocker.patch.object(
diff --git a/test/units/modules/test_service_facts.py b/test/units/modules/test_service_facts.py
index 07f6827..6917b8b 100644
--- a/test/units/modules/test_service_facts.py
+++ b/test/units/modules/test_service_facts.py
@@ -2,11 +2,10 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
-from units.compat.mock import patch
+import unittest
+from unittest.mock import patch
from ansible.module_utils import basic
from ansible.modules.service_facts import AIXScanService
diff --git a/test/units/modules/test_systemd.py b/test/units/modules/test_systemd.py
index 52c212a..1c5339c 100644
--- a/test/units/modules/test_systemd.py
+++ b/test/units/modules/test_systemd.py
@@ -1,7 +1,6 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from ansible.modules.systemd import parse_systemctl_show
diff --git a/test/units/modules/test_unarchive.py b/test/units/modules/test_unarchive.py
index 935231b..e66d0a1 100644
--- a/test/units/modules/test_unarchive.py
+++ b/test/units/modules/test_unarchive.py
@@ -1,6 +1,4 @@
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/modules/test_uri.py b/test/units/modules/test_uri.py
new file mode 100644
index 0000000..2aeb464
--- /dev/null
+++ b/test/units/modules/test_uri.py
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+# Copyright:
+# (c) 2023 Ansible Project
+# License: GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import annotations
+
+from unittest.mock import MagicMock, patch
+from units.modules.utils import AnsibleExitJson, AnsibleFailJson, ModuleTestCase, set_module_args
+from ansible.modules import uri
+
+
+class TestUri(ModuleTestCase):
+
+ def test_main_no_args(self):
+ """Module must fail if called with no args."""
+ with self.assertRaises(AnsibleFailJson):
+ set_module_args({})
+ uri.main()
+
+ def test_main_no_force(self):
+ """The "force" parameter to fetch_url() must be absent or false when the module is called without "force"."""
+ set_module_args({"url": "http://example.com/"})
+ resp = MagicMock()
+ resp.headers.get_content_type.return_value = "text/html"
+ info = {"url": "http://example.com/", "status": 200}
+ with patch.object(uri, "fetch_url", return_value=(resp, info)) as fetch_url:
+ with self.assertRaises(AnsibleExitJson):
+ uri.main()
+ fetch_url.assert_called_once()
+ assert not fetch_url.call_args[1].get("force")
+
+ def test_main_force(self):
+ """The "force" parameter to fetch_url() must be true when the module is called with "force"."""
+ set_module_args({"url": "http://example.com/", "force": True})
+ resp = MagicMock()
+ resp.headers.get_content_type.return_value = "text/html"
+ info = {"url": "http://example.com/", "status": 200}
+ with patch.object(uri, "fetch_url", return_value=(resp, info)) as fetch_url:
+ with self.assertRaises(AnsibleExitJson):
+ uri.main()
+ fetch_url.assert_called_once()
+ assert fetch_url.call_args[1].get("force")
diff --git a/test/units/modules/test_yum.py b/test/units/modules/test_yum.py
deleted file mode 100644
index 8052eff..0000000
--- a/test/units/modules/test_yum.py
+++ /dev/null
@@ -1,222 +0,0 @@
-# -*- coding: utf-8 -*-
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-from units.compat import unittest
-
-from ansible.modules.yum import YumModule
-
-
-yum_plugin_load_error = """
-Plugin "product-id" can't be imported
-Plugin "search-disabled-repos" can't be imported
-Plugin "subscription-manager" can't be imported
-Plugin "product-id" can't be imported
-Plugin "search-disabled-repos" can't be imported
-Plugin "subscription-manager" can't be imported
-"""
-
-# from https://github.com/ansible/ansible/issues/20608#issuecomment-276106505
-wrapped_output_1 = """
-Загружены модули: fastestmirror
-Loading mirror speeds from cached hostfile
- * base: mirror.h1host.ru
- * extras: mirror.h1host.ru
- * updates: mirror.h1host.ru
-
-vms-agent.x86_64 0.0-9 dev
-"""
-
-# from https://github.com/ansible/ansible/issues/20608#issuecomment-276971275
-wrapped_output_2 = """
-Загружены модули: fastestmirror
-Loading mirror speeds from cached hostfile
- * base: mirror.corbina.net
- * extras: mirror.corbina.net
- * updates: mirror.corbina.net
-
-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty.x86_64
- 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1-0
- addons
-libtiff.x86_64 4.0.3-27.el7_3 updates
-"""
-
-# From https://github.com/ansible/ansible/issues/20608#issuecomment-276698431
-wrapped_output_3 = """
-Loaded plugins: fastestmirror, langpacks
-Loading mirror speeds from cached hostfile
-
-ceph.x86_64 1:11.2.0-0.el7 ceph
-ceph-base.x86_64 1:11.2.0-0.el7 ceph
-ceph-common.x86_64 1:11.2.0-0.el7 ceph
-ceph-mds.x86_64 1:11.2.0-0.el7 ceph
-ceph-mon.x86_64 1:11.2.0-0.el7 ceph
-ceph-osd.x86_64 1:11.2.0-0.el7 ceph
-ceph-selinux.x86_64 1:11.2.0-0.el7 ceph
-libcephfs1.x86_64 1:11.0.2-0.el7 ceph
-librados2.x86_64 1:11.2.0-0.el7 ceph
-libradosstriper1.x86_64 1:11.2.0-0.el7 ceph
-librbd1.x86_64 1:11.2.0-0.el7 ceph
-librgw2.x86_64 1:11.2.0-0.el7 ceph
-python-cephfs.x86_64 1:11.2.0-0.el7 ceph
-python-rados.x86_64 1:11.2.0-0.el7 ceph
-python-rbd.x86_64 1:11.2.0-0.el7 ceph
-"""
-
-# from https://github.com/ansible/ansible-modules-core/issues/4318#issuecomment-251416661
-wrapped_output_4 = """
-ipxe-roms-qemu.noarch 20160127-1.git6366fa7a.el7
- rhelosp-9.0-director-puddle
-quota.x86_64 1:4.01-11.el7_2.1 rhelosp-rhel-7.2-z
-quota-nls.noarch 1:4.01-11.el7_2.1 rhelosp-rhel-7.2-z
-rdma.noarch 7.2_4.1_rc6-2.el7 rhelosp-rhel-7.2-z
-screen.x86_64 4.1.0-0.23.20120314git3c2946.el7_2
- rhelosp-rhel-7.2-z
-sos.noarch 3.2-36.el7ost.2 rhelosp-9.0-puddle
-sssd-client.x86_64 1.13.0-40.el7_2.12 rhelosp-rhel-7.2-z
-"""
-
-
-# A 'normal-ish' yum check-update output, without any wrapped lines
-unwrapped_output_rhel7 = """
-
-Loaded plugins: etckeeper, product-id, search-disabled-repos, subscription-
- : manager
-This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
-
-NetworkManager-openvpn.x86_64 1:1.2.6-1.el7 epel
-NetworkManager-openvpn-gnome.x86_64 1:1.2.6-1.el7 epel
-cabal-install.x86_64 1.16.1.0-2.el7 epel
-cgit.x86_64 1.1-1.el7 epel
-python34-libs.x86_64 3.4.5-3.el7 epel
-python34-test.x86_64 3.4.5-3.el7 epel
-python34-tkinter.x86_64 3.4.5-3.el7 epel
-python34-tools.x86_64 3.4.5-3.el7 epel
-qgit.x86_64 2.6-4.el7 epel
-rdiff-backup.x86_64 1.2.8-12.el7 epel
-stoken-libs.x86_64 0.91-1.el7 epel
-xlockmore.x86_64 5.49-2.el7 epel
-"""
-
-# Some wrapped obsoletes for prepending to output for testing both
-wrapped_output_rhel7_obsoletes_postfix = """
-Obsoleting Packages
-ddashboard.x86_64 0.2.0.1-1.el7_3 mhlavink-developerdashboard
- developerdashboard.x86_64 0.1.12.2-1.el7_2 @mhlavink-developerdashboard
-python-bugzilla.noarch 1.2.2-3.el7_2.1 mhlavink-developerdashboard
- python-bugzilla-develdashboardfixes.noarch
- 1.2.2-3.el7 @mhlavink-developerdashboard
-python2-futures.noarch 3.0.5-1.el7 epel
- python-futures.noarch 3.0.3-1.el7 @epel
-python2-pip.noarch 8.1.2-5.el7 epel
- python-pip.noarch 7.1.0-1.el7 @epel
-python2-pyxdg.noarch 0.25-6.el7 epel
- pyxdg.noarch 0.25-5.el7 @epel
-python2-simplejson.x86_64 3.10.0-1.el7 epel
- python-simplejson.x86_64 3.3.3-1.el7 @epel
-Security: kernel-3.10.0-327.28.2.el7.x86_64 is an installed security update
-Security: kernel-3.10.0-327.22.2.el7.x86_64 is the currently running version
-"""
-
-wrapped_output_multiple_empty_lines = """
-Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
-
-This system is not registered with an entitlement server. You can use subscription-manager to register.
-
-
-screen.x86_64 4.1.0-0.23.20120314git3c2946.el7_2
- rhelosp-rhel-7.2-z
-sos.noarch 3.2-36.el7ost.2 rhelosp-9.0-puddle
-"""
-
-longname = """
-Loaded plugins: fastestmirror, priorities, rhnplugin
-This system is receiving updates from RHN Classic or Red Hat Satellite.
-Loading mirror speeds from cached hostfile
-
-xxxxxxxxxxxxxxxxxxxxxxxxxx.noarch
- 1.16-1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-glibc.x86_64 2.17-157.el7_3.1 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"""
-
-
-unwrapped_output_rhel7_obsoletes = unwrapped_output_rhel7 + wrapped_output_rhel7_obsoletes_postfix
-unwrapped_output_rhel7_expected_new_obsoletes_pkgs = [
- "ddashboard", "python-bugzilla", "python2-futures", "python2-pip",
- "python2-pyxdg", "python2-simplejson"
-]
-unwrapped_output_rhel7_expected_old_obsoletes_pkgs = [
- "developerdashboard", "python-bugzilla-develdashboardfixes",
- "python-futures", "python-pip", "pyxdg", "python-simplejson"
-]
-unwrapped_output_rhel7_expected_updated_pkgs = [
- "NetworkManager-openvpn", "NetworkManager-openvpn-gnome", "cabal-install",
- "cgit", "python34-libs", "python34-test", "python34-tkinter",
- "python34-tools", "qgit", "rdiff-backup", "stoken-libs", "xlockmore"
-]
-
-
-class TestYumUpdateCheckParse(unittest.TestCase):
- def _assert_expected(self, expected_pkgs, result):
-
- for expected_pkg in expected_pkgs:
- self.assertIn(expected_pkg, result)
- self.assertEqual(len(result), len(expected_pkgs))
- self.assertIsInstance(result, dict)
-
- def test_empty_output(self):
- res, obs = YumModule.parse_check_update("")
- expected_pkgs = []
- self._assert_expected(expected_pkgs, res)
-
- def test_longname(self):
- res, obs = YumModule.parse_check_update(longname)
- expected_pkgs = ['xxxxxxxxxxxxxxxxxxxxxxxxxx', 'glibc']
- self._assert_expected(expected_pkgs, res)
-
- def test_plugin_load_error(self):
- res, obs = YumModule.parse_check_update(yum_plugin_load_error)
- expected_pkgs = []
- self._assert_expected(expected_pkgs, res)
-
- def test_wrapped_output_1(self):
- res, obs = YumModule.parse_check_update(wrapped_output_1)
- expected_pkgs = ["vms-agent"]
- self._assert_expected(expected_pkgs, res)
-
- def test_wrapped_output_2(self):
- res, obs = YumModule.parse_check_update(wrapped_output_2)
- expected_pkgs = ["empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty-empty",
- "libtiff"]
-
- self._assert_expected(expected_pkgs, res)
-
- def test_wrapped_output_3(self):
- res, obs = YumModule.parse_check_update(wrapped_output_3)
- expected_pkgs = ["ceph", "ceph-base", "ceph-common", "ceph-mds",
- "ceph-mon", "ceph-osd", "ceph-selinux", "libcephfs1",
- "librados2", "libradosstriper1", "librbd1", "librgw2",
- "python-cephfs", "python-rados", "python-rbd"]
- self._assert_expected(expected_pkgs, res)
-
- def test_wrapped_output_4(self):
- res, obs = YumModule.parse_check_update(wrapped_output_4)
-
- expected_pkgs = ["ipxe-roms-qemu", "quota", "quota-nls", "rdma", "screen",
- "sos", "sssd-client"]
- self._assert_expected(expected_pkgs, res)
-
- def test_wrapped_output_rhel7(self):
- res, obs = YumModule.parse_check_update(unwrapped_output_rhel7)
- self._assert_expected(unwrapped_output_rhel7_expected_updated_pkgs, res)
-
- def test_wrapped_output_rhel7_obsoletes(self):
- res, obs = YumModule.parse_check_update(unwrapped_output_rhel7_obsoletes)
- self._assert_expected(
- unwrapped_output_rhel7_expected_updated_pkgs + unwrapped_output_rhel7_expected_new_obsoletes_pkgs,
- res
- )
- self._assert_expected(unwrapped_output_rhel7_expected_old_obsoletes_pkgs, obs)
-
- def test_wrapped_output_multiple_empty_lines(self):
- res, obs = YumModule.parse_check_update(wrapped_output_multiple_empty_lines)
- self._assert_expected(['screen', 'sos'], res)
diff --git a/test/units/modules/utils.py b/test/units/modules/utils.py
index b56229e..4e83d1f 100644
--- a/test/units/modules/utils.py
+++ b/test/units/modules/utils.py
@@ -1,10 +1,9 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
-from units.compat import unittest
-from units.compat.mock import patch
+import unittest
+from unittest.mock import patch
from ansible.module_utils import basic
from ansible.module_utils.common.text.converters import to_bytes
diff --git a/test/units/parsing/test_ajson.py b/test/units/parsing/test_ajson.py
index bb7bf1a..6faf3f9 100644
--- a/test/units/parsing/test_ajson.py
+++ b/test/units/parsing/test_ajson.py
@@ -2,8 +2,7 @@
# Copyright 2019, Andrew Klychkov @Andersson007 <aaklychkov@mail.ru>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import os
import json
diff --git a/test/units/parsing/test_dataloader.py b/test/units/parsing/test_dataloader.py
index a7f8b1d..05040c3 100644
--- a/test/units/parsing/test_dataloader.py
+++ b/test/units/parsing/test_dataloader.py
@@ -15,13 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
-from units.compat import unittest
+import unittest
from unittest.mock import patch, mock_open
from ansible.errors import AnsibleParserError, yaml_strings, AnsibleFileNotFound
from ansible.parsing.vault import AnsibleVaultError
@@ -230,5 +228,20 @@ class TestDataLoaderWithVault(unittest.TestCase):
"""
with patch('builtins.open', mock_open(read_data=vaulted_data.encode('utf-8'))):
- output = self._loader.load_from_file('dummy_vault.txt')
+ output = self._loader.load_from_file('dummy_vault.txt', cache='none')
self.assertEqual(output, dict(foo='bar'))
+
+ # no cache used
+ self.assertFalse(self._loader._FILE_CACHE)
+
+ # vault cache entry written
+ output = self._loader.load_from_file('dummy_vault.txt', cache='vaulted')
+ self.assertEqual(output, dict(foo='bar'))
+ self.assertTrue(self._loader._FILE_CACHE)
+
+ # cache entry used
+ key = next(iter(self._loader._FILE_CACHE.keys()))
+ modified = {'changed': True}
+ self._loader._FILE_CACHE[key] = modified
+ output = self._loader.load_from_file('dummy_vault.txt', cache='vaulted')
+ self.assertEqual(output, modified)
diff --git a/test/units/parsing/test_mod_args.py b/test/units/parsing/test_mod_args.py
index aeb74ad..0bb0c95 100644
--- a/test/units/parsing/test_mod_args.py
+++ b/test/units/parsing/test_mod_args.py
@@ -2,8 +2,7 @@
# Copyright 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/parsing/test_splitter.py b/test/units/parsing/test_splitter.py
index 893f047..9eb957d 100644
--- a/test/units/parsing/test_splitter.py
+++ b/test/units/parsing/test_splitter.py
@@ -16,9 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.parsing.splitter import split_args, parse_kv
from ansible.errors import AnsibleParserError
diff --git a/test/units/parsing/test_unquote.py b/test/units/parsing/test_unquote.py
index 4b4260e..9d8918a 100644
--- a/test/units/parsing/test_unquote.py
+++ b/test/units/parsing/test_unquote.py
@@ -16,9 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.parsing.quoting import unquote
diff --git a/test/units/parsing/utils/test_addresses.py b/test/units/parsing/utils/test_addresses.py
index 4f7304f..7562940 100644
--- a/test/units/parsing/utils/test_addresses.py
+++ b/test/units/parsing/utils/test_addresses.py
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import unittest
diff --git a/test/units/parsing/utils/test_jsonify.py b/test/units/parsing/utils/test_jsonify.py
index 37be782..bb71a02 100644
--- a/test/units/parsing/utils/test_jsonify.py
+++ b/test/units/parsing/utils/test_jsonify.py
@@ -16,10 +16,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from ansible.parsing.utils.jsonify import jsonify
diff --git a/test/units/parsing/utils/test_yaml.py b/test/units/parsing/utils/test_yaml.py
index 27b2905..64d43c3 100644
--- a/test/units/parsing/utils/test_yaml.py
+++ b/test/units/parsing/utils/test_yaml.py
@@ -16,8 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/parsing/vault/test_vault.py b/test/units/parsing/vault/test_vault.py
index f94171a..982ae82 100644
--- a/test/units/parsing/vault/test_vault.py
+++ b/test/units/parsing/vault/test_vault.py
@@ -17,9 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import io
import os
@@ -28,11 +26,10 @@ import tempfile
from binascii import hexlify
import pytest
-from units.compat import unittest
+import unittest
from unittest.mock import patch, MagicMock
from ansible import errors
-from ansible.module_utils import six
from ansible.module_utils.common.text.converters import to_bytes, to_text
from ansible.parsing import vault
@@ -507,7 +504,7 @@ class TestVaultCipherAes256(unittest.TestCase):
b_password = b'hunter42'
b_salt = os.urandom(32)
b_key_cryptography = self.vault_cipher._create_key_cryptography(b_password, b_salt, key_length=32, iv_length=16)
- self.assertIsInstance(b_key_cryptography, six.binary_type)
+ self.assertIsInstance(b_key_cryptography, bytes)
def test_create_key_known_cryptography(self):
b_password = b'hunter42'
@@ -515,13 +512,13 @@ class TestVaultCipherAes256(unittest.TestCase):
# A fixed salt
b_salt = b'q' * 32 # q is the most random letter.
b_key_1 = self.vault_cipher._create_key_cryptography(b_password, b_salt, key_length=32, iv_length=16)
- self.assertIsInstance(b_key_1, six.binary_type)
+ self.assertIsInstance(b_key_1, bytes)
# verify we get the same answer
# we could potentially run a few iterations of this and time it to see if it's roughly constant time
# and or that it exceeds some minimal time, but that would likely cause unreliable fails, esp in CI
b_key_2 = self.vault_cipher._create_key_cryptography(b_password, b_salt, key_length=32, iv_length=16)
- self.assertIsInstance(b_key_2, six.binary_type)
+ self.assertIsInstance(b_key_2, bytes)
self.assertEqual(b_key_1, b_key_2)
def test_is_equal_is_equal(self):
@@ -612,7 +609,7 @@ class TestVaultLib(unittest.TestCase):
plaintext = u'Some text to encrypt in a café'
b_vaulttext = self.v.encrypt(plaintext)
- self.assertIsInstance(b_vaulttext, six.binary_type)
+ self.assertIsInstance(b_vaulttext, bytes)
b_header = b'$ANSIBLE_VAULT;1.1;AES256\n'
self.assertEqual(b_vaulttext[:len(b_header)], b_header)
@@ -621,7 +618,7 @@ class TestVaultLib(unittest.TestCase):
plaintext = u'Some text to encrypt in a café'
b_vaulttext = self.v.encrypt(plaintext, vault_id='test_id')
- self.assertIsInstance(b_vaulttext, six.binary_type)
+ self.assertIsInstance(b_vaulttext, bytes)
b_header = b'$ANSIBLE_VAULT;1.2;AES256;test_id\n'
self.assertEqual(b_vaulttext[:len(b_header)], b_header)
@@ -631,7 +628,7 @@ class TestVaultLib(unittest.TestCase):
plaintext = to_bytes(u'Some text to encrypt in a café')
b_vaulttext = self.v.encrypt(plaintext)
- self.assertIsInstance(b_vaulttext, six.binary_type)
+ self.assertIsInstance(b_vaulttext, bytes)
b_header = b'$ANSIBLE_VAULT;1.1;AES256\n'
self.assertEqual(b_vaulttext[:len(b_header)], b_header)
diff --git a/test/units/parsing/vault/test_vault_editor.py b/test/units/parsing/vault/test_vault_editor.py
index 28561c6..d191cf8 100644
--- a/test/units/parsing/vault/test_vault_editor.py
+++ b/test/units/parsing/vault/test_vault_editor.py
@@ -16,9 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import tempfile
@@ -26,7 +24,7 @@ from io import BytesIO, StringIO
import pytest
-from units.compat import unittest
+import unittest
from unittest.mock import patch
from ansible import errors
diff --git a/test/units/parsing/yaml/test_constructor.py b/test/units/parsing/yaml/test_constructor.py
index 717bf35..7e16d17 100644
--- a/test/units/parsing/yaml/test_constructor.py
+++ b/test/units/parsing/yaml/test_constructor.py
@@ -2,8 +2,7 @@
# (c) 2020 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
from yaml import MappingNode, Mark, ScalarNode
diff --git a/test/units/parsing/yaml/test_dumper.py b/test/units/parsing/yaml/test_dumper.py
index 8af1eee..5d3961e 100644
--- a/test/units/parsing/yaml/test_dumper.py
+++ b/test/units/parsing/yaml/test_dumper.py
@@ -14,15 +14,13 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import io
from jinja2.exceptions import UndefinedError
-from units.compat import unittest
+import unittest
from ansible.parsing import vault
from ansible.parsing.yaml import dumper, objects
from ansible.parsing.yaml.loader import AnsibleLoader
diff --git a/test/units/parsing/yaml/test_loader.py b/test/units/parsing/yaml/test_loader.py
index 117f80a..75ad7c4 100644
--- a/test/units/parsing/yaml/test_loader.py
+++ b/test/units/parsing/yaml/test_loader.py
@@ -16,17 +16,14 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from collections.abc import Sequence, Set, Mapping
from io import StringIO
-from units.compat import unittest
+import unittest
from ansible import errors
-from ansible.module_utils.six import text_type, binary_type
from ansible.parsing.yaml.loader import AnsibleLoader
from ansible.parsing import vault
from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode
@@ -66,7 +63,7 @@ class TestAnsibleLoaderBasic(unittest.TestCase):
loader = AnsibleLoader(stream, 'myfile.yml')
data = loader.get_single_data()
self.assertEqual(data, u'Ansible')
- self.assertIsInstance(data, text_type)
+ self.assertIsInstance(data, str)
self.assertEqual(data.ansible_pos, ('myfile.yml', 2, 17))
@@ -77,7 +74,7 @@ class TestAnsibleLoaderBasic(unittest.TestCase):
loader = AnsibleLoader(stream, 'myfile.yml')
data = loader.get_single_data()
self.assertEqual(data, u'Cafè Eñyei')
- self.assertIsInstance(data, text_type)
+ self.assertIsInstance(data, str)
self.assertEqual(data.ansible_pos, ('myfile.yml', 2, 17))
@@ -90,8 +87,8 @@ class TestAnsibleLoaderBasic(unittest.TestCase):
data = loader.get_single_data()
self.assertEqual(data, {'webster': 'daniel', 'oed': 'oxford'})
self.assertEqual(len(data), 2)
- self.assertIsInstance(list(data.keys())[0], text_type)
- self.assertIsInstance(list(data.values())[0], text_type)
+ self.assertIsInstance(list(data.keys())[0], str)
+ self.assertIsInstance(list(data.values())[0], str)
# Beginning of the first key
self.assertEqual(data.ansible_pos, ('myfile.yml', 2, 17))
@@ -108,7 +105,7 @@ class TestAnsibleLoaderBasic(unittest.TestCase):
data = loader.get_single_data()
self.assertEqual(data, [u'a', u'b'])
self.assertEqual(len(data), 2)
- self.assertIsInstance(data[0], text_type)
+ self.assertIsInstance(data[0], str)
self.assertEqual(data.ansible_pos, ('myfile.yml', 2, 17))
@@ -355,10 +352,10 @@ class TestAnsibleLoaderPlay(unittest.TestCase):
def walk(self, data):
# Make sure there's no str in the data
- self.assertNotIsInstance(data, binary_type)
+ self.assertNotIsInstance(data, bytes)
# Descend into various container types
- if isinstance(data, text_type):
+ if isinstance(data, str):
# strings are a sequence so we have to be explicit here
return
elif isinstance(data, (Sequence, Set)):
diff --git a/test/units/parsing/yaml/test_objects.py b/test/units/parsing/yaml/test_objects.py
index f899915..32aca1c 100644
--- a/test/units/parsing/yaml/test_objects.py
+++ b/test/units/parsing/yaml/test_objects.py
@@ -16,11 +16,9 @@
#
# Copyright 2016, Adrian Likins <alikins@redhat.com>
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from ansible.errors import AnsibleError
diff --git a/test/units/playbook/role/test_include_role.py b/test/units/playbook/role/test_include_role.py
index aa97da1..97ce325 100644
--- a/test/units/playbook/role/test_include_role.py
+++ b/test/units/playbook/role/test_include_role.py
@@ -15,11 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from unittest.mock import patch
from ansible.playbook import Play
@@ -94,13 +92,11 @@ class TestIncludeRole(unittest.TestCase):
if isinstance(task, IncludeRole):
blocks, handlers = task.get_block_list(loader=self.loader)
for block in blocks:
- for t in self.flatten_tasks(block.block):
- yield t
+ yield from self.flatten_tasks(block.block)
elif isinstance(task, Task):
yield task
else:
- for t in self.flatten_tasks(task.block):
- yield t
+ yield from self.flatten_tasks(task.block)
def get_tasks_vars(self, play, tasks):
for task in self.flatten_tasks(tasks):
diff --git a/test/units/playbook/role/test_role.py b/test/units/playbook/role/test_role.py
index 9d6b0ed..cbfe776 100644
--- a/test/units/playbook/role/test_role.py
+++ b/test/units/playbook/role/test_role.py
@@ -15,15 +15,13 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from collections.abc import Container
import pytest
-from units.compat import unittest
+import unittest
from unittest.mock import patch, MagicMock
from ansible.errors import AnsibleParserError
diff --git a/test/units/playbook/test_attribute.py b/test/units/playbook/test_attribute.py
index bdb37c1..14c4807 100644
--- a/test/units/playbook/test_attribute.py
+++ b/test/units/playbook/test_attribute.py
@@ -15,10 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from ansible.playbook.attribute import Attribute
diff --git a/test/units/playbook/test_base.py b/test/units/playbook/test_base.py
index bedd96a..de0c7ed 100644
--- a/test/units/playbook/test_base.py
+++ b/test/units/playbook/test_base.py
@@ -15,14 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from ansible.errors import AnsibleParserError, AnsibleAssertionError
-from ansible.module_utils.six import string_types
from ansible.playbook.attribute import FieldAttribute, NonInheritableFieldAttribute
from ansible.template import Templar
from ansible.playbook import base
@@ -336,9 +333,9 @@ class BaseSubClass(base.Base):
test_attr_bool = FieldAttribute(isa='bool', always_post_validate=True)
test_attr_int = FieldAttribute(isa='int', always_post_validate=True)
test_attr_float = FieldAttribute(isa='float', default=3.14159, always_post_validate=True)
- test_attr_list = FieldAttribute(isa='list', listof=string_types, always_post_validate=True)
+ test_attr_list = FieldAttribute(isa='list', listof=(str,), always_post_validate=True)
test_attr_list_no_listof = FieldAttribute(isa='list', always_post_validate=True)
- test_attr_list_required = FieldAttribute(isa='list', listof=string_types, required=True,
+ test_attr_list_required = FieldAttribute(isa='list', listof=(str,), required=True,
default=list, always_post_validate=True)
test_attr_string = FieldAttribute(isa='string', default='the_test_attr_string_default_value')
test_attr_string_required = FieldAttribute(isa='string', required=True,
diff --git a/test/units/playbook/test_block.py b/test/units/playbook/test_block.py
index 4847123..aac5f71 100644
--- a/test/units/playbook/test_block.py
+++ b/test/units/playbook/test_block.py
@@ -15,11 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from ansible.playbook.block import Block
from ansible.playbook.task import Task
diff --git a/test/units/playbook/test_collectionsearch.py b/test/units/playbook/test_collectionsearch.py
index d16541b..f91d632 100644
--- a/test/units/playbook/test_collectionsearch.py
+++ b/test/units/playbook/test_collectionsearch.py
@@ -15,8 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.errors import AnsibleParserError
from ansible.playbook.play import Play
diff --git a/test/units/playbook/test_conditional.py b/test/units/playbook/test_conditional.py
index 8231d16..e0f0857 100644
--- a/test/units/playbook/test_conditional.py
+++ b/test/units/playbook/test_conditional.py
@@ -1,7 +1,6 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from units.mock.loader import DictDataLoader
from unittest.mock import MagicMock
diff --git a/test/units/playbook/test_helpers.py b/test/units/playbook/test_helpers.py
index 23385c0..2977b0d 100644
--- a/test/units/playbook/test_helpers.py
+++ b/test/units/playbook/test_helpers.py
@@ -15,13 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
-from units.compat import unittest
+import unittest
from unittest.mock import MagicMock
from units.mock.loader import DictDataLoader
diff --git a/test/units/playbook/test_included_file.py b/test/units/playbook/test_included_file.py
index c7a66b0..7d1e707 100644
--- a/test/units/playbook/test_included_file.py
+++ b/test/units/playbook/test_included_file.py
@@ -15,9 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
@@ -318,9 +316,6 @@ def test_empty_raw_params():
task_ds_list = [
{
- 'include': ''
- },
- {
'include_tasks': ''
},
{
diff --git a/test/units/playbook/test_play.py b/test/units/playbook/test_play.py
index bcc1e5e..a54b93d 100644
--- a/test/units/playbook/test_play.py
+++ b/test/units/playbook/test_play.py
@@ -15,9 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/playbook/test_play_context.py b/test/units/playbook/test_play_context.py
index 7461b45..485a0e5 100644
--- a/test/units/playbook/test_play_context.py
+++ b/test/units/playbook/test_play_context.py
@@ -3,9 +3,7 @@
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/playbook/test_playbook.py b/test/units/playbook/test_playbook.py
index 68a9fb7..c04479b 100644
--- a/test/units/playbook/test_playbook.py
+++ b/test/units/playbook/test_playbook.py
@@ -15,11 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from ansible.errors import AnsibleParserError
from ansible.playbook import Playbook
from ansible.vars.manager import VariableManager
diff --git a/test/units/playbook/test_taggable.py b/test/units/playbook/test_taggable.py
index c6ce35d..7076f98 100644
--- a/test/units/playbook/test_taggable.py
+++ b/test/units/playbook/test_taggable.py
@@ -15,11 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from ansible.playbook.taggable import Taggable
from units.mock.loader import DictDataLoader
diff --git a/test/units/playbook/test_task.py b/test/units/playbook/test_task.py
index e28d2ec..6eb3bf2 100644
--- a/test/units/playbook/test_task.py
+++ b/test/units/playbook/test_task.py
@@ -15,11 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from unittest.mock import patch
from ansible.playbook.task import Task
from ansible.plugins.loader import init_plugin_loader
diff --git a/test/units/plugins/action/test_action.py b/test/units/plugins/action/test_action.py
index 33d09c4..7d9c291 100644
--- a/test/units/plugins/action/test_action.py
+++ b/test/units/plugins/action/test_action.py
@@ -16,21 +16,19 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import re
from importlib import import_module
from ansible import constants as C
-from units.compat import unittest
+import unittest
from unittest.mock import patch, MagicMock, mock_open
from ansible.errors import AnsibleError, AnsibleAuthenticationFailure
-from ansible.module_utils.six import text_type
-from ansible.module_utils.six.moves import shlex_quote, builtins
+import builtins
+import shlex
from ansible.module_utils.common.text.converters import to_bytes
from ansible.playbook.play_context import PlayContext
from ansible.plugins.action import ActionBase
@@ -197,7 +195,7 @@ class TestActionBase(unittest.TestCase):
# create a mock connection, so we don't actually try and connect to things
def env_prefix(**args):
- return ' '.join(['%s=%s' % (k, shlex_quote(text_type(v))) for k, v in args.items()])
+ return ' '.join(['%s=%s' % (k, shlex.quote(str(v))) for k, v in args.items()])
mock_connection = MagicMock()
mock_connection._shell.env_prefix.side_effect = env_prefix
diff --git a/test/units/plugins/action/test_gather_facts.py b/test/units/plugins/action/test_gather_facts.py
index 20225aa..5bacb63 100644
--- a/test/units/plugins/action/test_gather_facts.py
+++ b/test/units/plugins/action/test_gather_facts.py
@@ -15,10 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from unittest.mock import MagicMock, patch
from ansible import constants as C
diff --git a/test/units/plugins/action/test_raw.py b/test/units/plugins/action/test_raw.py
index c50004a..9413fdf 100644
--- a/test/units/plugins/action/test_raw.py
+++ b/test/units/plugins/action/test_raw.py
@@ -15,12 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
-from units.compat import unittest
+import unittest
from unittest.mock import MagicMock, Mock
from ansible.plugins.action.raw import ActionModule
from ansible.playbook.task import Task
@@ -37,6 +36,16 @@ class TestCopyResultExclude(unittest.TestCase):
def tearDown(self):
pass
+ def _build_task(self):
+
+ task = MagicMock(Task)
+ task.async_val = False
+ task.diff = False
+ task.check_mode = False
+ task.environment = None
+ task.args = {'_raw_params': 'Args1'}
+
+ return task
# The current behavior of the raw aciton in regards to executable is currently in question;
# the test_raw_executable_is_not_empty_string verifies the current behavior (whether it is desireed or not.
# Please refer to the following for context:
@@ -45,11 +54,7 @@ class TestCopyResultExclude(unittest.TestCase):
def test_raw_executable_is_not_empty_string(self):
- task = MagicMock(Task)
- task.async_val = False
-
- task.args = {'_raw_params': 'Args1'}
- self.play_context.check_mode = False
+ task = self._build_task()
self.mock_am = ActionModule(task, self.connection, self.play_context, loader=None, templar=None, shared_loader_obj=None)
self.mock_am._low_level_execute_command = Mock(return_value={})
@@ -61,22 +66,14 @@ class TestCopyResultExclude(unittest.TestCase):
def test_raw_check_mode_is_True(self):
- task = MagicMock(Task)
- task.async_val = False
-
- task.args = {'_raw_params': 'Args1'}
- self.play_context.check_mode = True
+ task = self._build_task()
+ task.check_mode = True
self.mock_am = ActionModule(task, self.connection, self.play_context, loader=None, templar=None, shared_loader_obj=None)
def test_raw_test_environment_is_None(self):
- task = MagicMock(Task)
- task.async_val = False
-
- task.args = {'_raw_params': 'Args1'}
- task.environment = None
- self.play_context.check_mode = False
+ task = self._build_task()
self.mock_am = ActionModule(task, self.connection, self.play_context, loader=None, templar=None, shared_loader_obj=None)
self.mock_am._low_level_execute_command = Mock(return_value={})
@@ -86,12 +83,7 @@ class TestCopyResultExclude(unittest.TestCase):
def test_raw_task_vars_is_not_None(self):
- task = MagicMock(Task)
- task.async_val = False
-
- task.args = {'_raw_params': 'Args1'}
- task.environment = None
- self.play_context.check_mode = False
+ task = self._build_task()
self.mock_am = ActionModule(task, self.connection, self.play_context, loader=None, templar=None, shared_loader_obj=None)
self.mock_am._low_level_execute_command = Mock(return_value={})
diff --git a/test/units/plugins/action/test_reboot.py b/test/units/plugins/action/test_reboot.py
index 36d9e12..ba03f3e 100644
--- a/test/units/plugins/action/test_reboot.py
+++ b/test/units/plugins/action/test_reboot.py
@@ -1,6 +1,8 @@
# Copyright (c) 2022 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""Tests for the reboot action plugin."""
+from __future__ import annotations
+
import os
import pytest
@@ -24,6 +26,8 @@ def module_task(mocker, task_args):
task.action = 'reboot'
task.args = task_args
task.async_val = False
+ task.check_mode = False
+ task.diff = False
return task
diff --git a/test/units/plugins/become/conftest.py b/test/units/plugins/become/conftest.py
index a04a5e2..ce47dda 100644
--- a/test/units/plugins/become/conftest.py
+++ b/test/units/plugins/become/conftest.py
@@ -3,9 +3,7 @@
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/plugins/become/test_su.py b/test/units/plugins/become/test_su.py
index bf74a4c..a690637 100644
--- a/test/units/plugins/become/test_su.py
+++ b/test/units/plugins/become/test_su.py
@@ -3,9 +3,7 @@
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import re
diff --git a/test/units/plugins/become/test_sudo.py b/test/units/plugins/become/test_sudo.py
index 67eb9a4..6b7ca13 100644
--- a/test/units/plugins/become/test_sudo.py
+++ b/test/units/plugins/become/test_sudo.py
@@ -3,9 +3,7 @@
#
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import re
diff --git a/test/units/plugins/cache/test_cache.py b/test/units/plugins/cache/test_cache.py
index b4ffe4e..edd5048 100644
--- a/test/units/plugins/cache/test_cache.py
+++ b/test/units/plugins/cache/test_cache.py
@@ -15,9 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import shutil
@@ -25,7 +23,7 @@ import tempfile
from unittest import mock
-from units.compat import unittest
+import unittest
from ansible.errors import AnsibleError
from ansible.plugins.cache import CachePluginAdjudicator
from ansible.plugins.cache.memory import CacheModule as MemoryCache
diff --git a/test/units/plugins/callback/test_callback.py b/test/units/plugins/callback/test_callback.py
index ccfa465..dd83820 100644
--- a/test/units/plugins/callback/test_callback.py
+++ b/test/units/plugins/callback/test_callback.py
@@ -15,16 +15,14 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import json
import re
import textwrap
import types
-from units.compat import unittest
+import unittest
from unittest.mock import MagicMock
from ansible.executor.task_result import TaskResult
diff --git a/test/units/plugins/connection/test_connection.py b/test/units/plugins/connection/test_connection.py
index 56095c6..da140ea 100644
--- a/test/units/plugins/connection/test_connection.py
+++ b/test/units/plugins/connection/test_connection.py
@@ -15,13 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from io import StringIO
-from units.compat import unittest
+import unittest
from ansible.playbook.play_context import PlayContext
from ansible.plugins.connection import ConnectionBase
from ansible.plugins.loader import become_loader
diff --git a/test/units/plugins/connection/test_local.py b/test/units/plugins/connection/test_local.py
index 483a881..06a1ba3 100644
--- a/test/units/plugins/connection/test_local.py
+++ b/test/units/plugins/connection/test_local.py
@@ -16,13 +16,11 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from io import StringIO
-from units.compat import unittest
+import unittest
from ansible.plugins.connection import local
from ansible.playbook.play_context import PlayContext
diff --git a/test/units/plugins/connection/test_paramiko_ssh.py b/test/units/plugins/connection/test_paramiko_ssh.py
index 0307261..708ae74 100644
--- a/test/units/plugins/connection/test_paramiko_ssh.py
+++ b/test/units/plugins/connection/test_paramiko_ssh.py
@@ -16,9 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from io import StringIO
import pytest
diff --git a/test/units/plugins/connection/test_psrp.py b/test/units/plugins/connection/test_psrp.py
index 38052e8..7fd6ead 100644
--- a/test/units/plugins/connection/test_psrp.py
+++ b/test/units/plugins/connection/test_psrp.py
@@ -2,9 +2,7 @@
# (c) 2018, Jordan Borean <jborean@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
import sys
diff --git a/test/units/plugins/connection/test_ssh.py b/test/units/plugins/connection/test_ssh.py
index 48ad3b7..5207af7 100644
--- a/test/units/plugins/connection/test_ssh.py
+++ b/test/units/plugins/connection/test_ssh.py
@@ -16,20 +16,18 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from io import StringIO
+from selectors import SelectorKey, EVENT_READ
import pytest
from ansible.errors import AnsibleAuthenticationFailure
-from units.compat import unittest
+import unittest
from unittest.mock import patch, MagicMock, PropertyMock
from ansible.errors import AnsibleError, AnsibleConnectionFailure, AnsibleFileNotFound
-from ansible.module_utils.compat.selectors import SelectorKey, EVENT_READ
-from ansible.module_utils.six.moves import shlex_quote
+import shlex
from ansible.module_utils.common.text.converters import to_bytes
from ansible.playbook.play_context import PlayContext
from ansible.plugins.connection import ssh
@@ -243,46 +241,40 @@ class TestConnectionBaseClass(unittest.TestCase):
conn.host = "some_host"
conn.set_option('reconnection_retries', 9)
- conn.set_option('ssh_transfer_method', None) # unless set to None scp_if_ssh is ignored
+ conn.set_option('ssh_transfer_method', None) # default is smart
- # Test with SCP_IF_SSH set to smart
# Test when SFTP works
- conn.set_option('scp_if_ssh', 'smart')
- expected_in_data = b' '.join((b'put', to_bytes(shlex_quote('/path/to/in/file')), to_bytes(shlex_quote('/path/to/dest/file')))) + b'\n'
+ expected_in_data = b' '.join((b'put', to_bytes(shlex.quote('/path/to/in/file')), to_bytes(shlex.quote('/path/to/dest/file')))) + b'\n'
conn.put_file('/path/to/in/file', '/path/to/dest/file')
conn._bare_run.assert_called_with('some command to run', expected_in_data, checkrc=False)
+ # Test filenames with unicode
+ expected_in_data = b' '.join((b'put',
+ to_bytes(shlex.quote('/path/to/in/file/with/unicode-fö〩')),
+ to_bytes(shlex.quote('/path/to/dest/file/with/unicode-fö〩')))) + b'\n'
+ conn.put_file(u'/path/to/in/file/with/unicode-fö〩', u'/path/to/dest/file/with/unicode-fö〩')
+ conn._bare_run.assert_called_with('some command to run', expected_in_data, checkrc=False)
+
# Test when SFTP doesn't work but SCP does
conn._bare_run.side_effect = [(1, 'stdout', 'some errors'), (0, '', '')]
conn.put_file('/path/to/in/file', '/path/to/dest/file')
conn._bare_run.assert_called_with('some command to run', None, checkrc=False)
conn._bare_run.side_effect = None
- # test with SCP_IF_SSH enabled
- conn.set_option('scp_if_ssh', True)
- conn.put_file('/path/to/in/file', '/path/to/dest/file')
- conn._bare_run.assert_called_with('some command to run', None, checkrc=False)
-
- conn.put_file(u'/path/to/in/file/with/unicode-fö〩', u'/path/to/dest/file/with/unicode-fö〩')
- conn._bare_run.assert_called_with('some command to run', None, checkrc=False)
+ # Test that a non-zero rc raises an error
+ conn.set_option('ssh_transfer_method', 'sftp')
+ conn._bare_run.return_value = (1, 'stdout', 'some errors')
+ self.assertRaises(AnsibleError, conn.put_file, '/path/to/bad/file', '/remote/path/to/file')
- # test with SCPP_IF_SSH disabled
- conn.set_option('scp_if_ssh', False)
- expected_in_data = b' '.join((b'put', to_bytes(shlex_quote('/path/to/in/file')), to_bytes(shlex_quote('/path/to/dest/file')))) + b'\n'
- conn.put_file('/path/to/in/file', '/path/to/dest/file')
- conn._bare_run.assert_called_with('some command to run', expected_in_data, checkrc=False)
+ # Test that rc=255 raises an error
+ conn._bare_run.return_value = (255, 'stdout', 'some errors')
+ self.assertRaises(AnsibleConnectionFailure, conn.put_file, '/path/to/bad/file', '/remote/path/to/file')
- expected_in_data = b' '.join((b'put',
- to_bytes(shlex_quote('/path/to/in/file/with/unicode-fö〩')),
- to_bytes(shlex_quote('/path/to/dest/file/with/unicode-fö〩')))) + b'\n'
- conn.put_file(u'/path/to/in/file/with/unicode-fö〩', u'/path/to/dest/file/with/unicode-fö〩')
- conn._bare_run.assert_called_with('some command to run', expected_in_data, checkrc=False)
-
- # test that a non-zero rc raises an error
- conn._bare_run.return_value = (1, 'stdout', 'some errors')
+ # Test that rc=256 raises an error
+ conn._bare_run.return_value = (256, 'stdout', 'some errors')
self.assertRaises(AnsibleError, conn.put_file, '/path/to/bad/file', '/remote/path/to/file')
- # test that a not-found path raises an error
+ # Test that a not-found path raises an error
mock_ospe.return_value = False
conn._bare_run.return_value = (0, 'stdout', '')
self.assertRaises(AnsibleFileNotFound, conn.put_file, '/path/to/bad/file', '/remote/path/to/file')
@@ -301,12 +293,10 @@ class TestConnectionBaseClass(unittest.TestCase):
conn.host = "some_host"
conn.set_option('reconnection_retries', 9)
- conn.set_option('ssh_transfer_method', None) # unless set to None scp_if_ssh is ignored
+ conn.set_option('ssh_transfer_method', None) # default is smart
- # Test with SCP_IF_SSH set to smart
# Test when SFTP works
- conn.set_option('scp_if_ssh', 'smart')
- expected_in_data = b' '.join((b'get', to_bytes(shlex_quote('/path/to/in/file')), to_bytes(shlex_quote('/path/to/dest/file')))) + b'\n'
+ expected_in_data = b' '.join((b'get', to_bytes(shlex.quote('/path/to/in/file')), to_bytes(shlex.quote('/path/to/dest/file')))) + b'\n'
conn.set_options({})
conn.fetch_file('/path/to/in/file', '/path/to/dest/file')
conn._bare_run.assert_called_with('some command to run', expected_in_data, checkrc=False)
@@ -315,33 +305,29 @@ class TestConnectionBaseClass(unittest.TestCase):
conn._bare_run.side_effect = [(1, 'stdout', 'some errors'), (0, '', '')]
conn.fetch_file('/path/to/in/file', '/path/to/dest/file')
conn._bare_run.assert_called_with('some command to run', None, checkrc=False)
-
- # test with SCP_IF_SSH enabled
conn._bare_run.side_effect = None
- conn.set_option('ssh_transfer_method', None) # unless set to None scp_if_ssh is ignored
- conn.set_option('scp_if_ssh', 'True')
- conn.fetch_file('/path/to/in/file', '/path/to/dest/file')
- conn._bare_run.assert_called_with('some command to run', None, checkrc=False)
-
- conn.fetch_file(u'/path/to/in/file/with/unicode-fö〩', u'/path/to/dest/file/with/unicode-fö〩')
- conn._bare_run.assert_called_with('some command to run', None, checkrc=False)
-
- # test with SCP_IF_SSH disabled
- conn.set_option('scp_if_ssh', False)
- expected_in_data = b' '.join((b'get', to_bytes(shlex_quote('/path/to/in/file')), to_bytes(shlex_quote('/path/to/dest/file')))) + b'\n'
- conn.fetch_file('/path/to/in/file', '/path/to/dest/file')
- conn._bare_run.assert_called_with('some command to run', expected_in_data, checkrc=False)
+ # Test when filename is unicode
expected_in_data = b' '.join((b'get',
- to_bytes(shlex_quote('/path/to/in/file/with/unicode-fö〩')),
- to_bytes(shlex_quote('/path/to/dest/file/with/unicode-fö〩')))) + b'\n'
+ to_bytes(shlex.quote('/path/to/in/file/with/unicode-fö〩')),
+ to_bytes(shlex.quote('/path/to/dest/file/with/unicode-fö〩')))) + b'\n'
conn.fetch_file(u'/path/to/in/file/with/unicode-fö〩', u'/path/to/dest/file/with/unicode-fö〩')
conn._bare_run.assert_called_with('some command to run', expected_in_data, checkrc=False)
+ conn._bare_run.side_effect = None
- # test that a non-zero rc raises an error
+ # Test that a non-zero rc raises an error
+ conn.set_option('ssh_transfer_method', 'sftp')
conn._bare_run.return_value = (1, 'stdout', 'some errors')
self.assertRaises(AnsibleError, conn.fetch_file, '/path/to/bad/file', '/remote/path/to/file')
+ # Test that rc=255 raises an error
+ conn._bare_run.return_value = (255, 'stdout', 'some errors')
+ self.assertRaises(AnsibleConnectionFailure, conn.fetch_file, '/path/to/bad/file', '/remote/path/to/file')
+
+ # Test that rc=256 raises an error
+ conn._bare_run.return_value = (256, 'stdout', 'some errors')
+ self.assertRaises(AnsibleError, conn.fetch_file, '/path/to/bad/file', '/remote/path/to/file')
+
class MockSelector(object):
def __init__(self):
@@ -391,7 +377,7 @@ def mock_run_env(request, mocker):
request.cls.mock_popen = mock_popen
request.cls.mock_selector = MockSelector()
- mocker.patch('ansible.module_utils.compat.selectors.DefaultSelector', lambda: request.cls.mock_selector)
+ mocker.patch('selectors.DefaultSelector', lambda: request.cls.mock_selector)
request.cls.mock_openpty = mocker.patch('pty.openpty')
diff --git a/test/units/plugins/connection/test_winrm.py b/test/units/plugins/connection/test_winrm.py
index c3060da..c08cdd9 100644
--- a/test/units/plugins/connection/test_winrm.py
+++ b/test/units/plugins/connection/test_winrm.py
@@ -2,9 +2,7 @@
# (c) 2018, Jordan Borean <jborean@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
diff --git a/test/units/plugins/filter/test_core.py b/test/units/plugins/filter/test_core.py
index ab09ec4..6c25d15 100644
--- a/test/units/plugins/filter/test_core.py
+++ b/test/units/plugins/filter/test_core.py
@@ -2,8 +2,7 @@
# Copyright (c) 2019 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/plugins/inventory/test_constructed.py b/test/units/plugins/inventory/test_constructed.py
index 8ae78f1..cd91691 100644
--- a/test/units/plugins/inventory/test_constructed.py
+++ b/test/units/plugins/inventory/test_constructed.py
@@ -17,8 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/plugins/inventory/test_inventory.py b/test/units/plugins/inventory/test_inventory.py
index fb5342a..ee9811c 100644
--- a/test/units/plugins/inventory/test_inventory.py
+++ b/test/units/plugins/inventory/test_inventory.py
@@ -15,9 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import string
import textwrap
@@ -25,8 +23,7 @@ import textwrap
from unittest import mock
from ansible import constants as C
-from units.compat import unittest
-from ansible.module_utils.six import string_types
+import unittest
from ansible.module_utils.common.text.converters import to_text
from units.mock.path import mock_unfrackpath_noop
@@ -160,8 +157,8 @@ class TestInventoryPlugins(unittest.TestCase):
variables = inventory.get_host('host1').vars
for i in range(len(values)):
- if isinstance(values[i], string_types):
- self.assertIsInstance(variables['var%s' % i], string_types)
+ if isinstance(values[i], str):
+ self.assertIsInstance(variables['var%s' % i], str)
else:
self.assertIsInstance(variables['var%s' % i], type(values[i]))
diff --git a/test/units/plugins/inventory/test_script.py b/test/units/plugins/inventory/test_script.py
index 89eb4f5..875f830 100644
--- a/test/units/plugins/inventory/test_script.py
+++ b/test/units/plugins/inventory/test_script.py
@@ -17,9 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
from unittest import mock
@@ -27,7 +25,7 @@ from unittest import mock
from ansible import constants as C
from ansible.errors import AnsibleError
from ansible.plugins.loader import PluginLoader
-from units.compat import unittest
+import unittest
from ansible.module_utils.common.text.converters import to_bytes, to_native
diff --git a/test/units/plugins/loader_fixtures/import_fixture.py b/test/units/plugins/loader_fixtures/import_fixture.py
index 8112733..46af1f2 100644
--- a/test/units/plugins/loader_fixtures/import_fixture.py
+++ b/test/units/plugins/loader_fixtures/import_fixture.py
@@ -1,7 +1,6 @@
# Nothing to see here, this file is just empty to support a imp.load_source
# without doing anything
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
class test:
diff --git a/test/units/plugins/lookup/test_env.py b/test/units/plugins/lookup/test_env.py
index 5d9713f..add511b 100644
--- a/test/units/plugins/lookup/test_env.py
+++ b/test/units/plugins/lookup/test_env.py
@@ -2,9 +2,7 @@
# Copyright: (c) 2019, Abhay Kadam <abhaykadam88@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
@@ -16,7 +14,7 @@ from ansible.plugins.loader import lookup_loader
('equation', 'a=b*100')
])
def test_env_var_value(monkeypatch, env_var, exp_value):
- monkeypatch.setattr('ansible.utils.py3compat.environ.get', lambda x, y: exp_value)
+ monkeypatch.setattr('os.environ.get', lambda x, y: exp_value)
env_lookup = lookup_loader.get('env')
retval = env_lookup.run([env_var], None)
@@ -28,7 +26,7 @@ def test_env_var_value(monkeypatch, env_var, exp_value):
('the_var', 'ãnˈsiβle')
])
def test_utf8_env_var_value(monkeypatch, env_var, exp_value):
- monkeypatch.setattr('ansible.utils.py3compat.environ.get', lambda x, y: exp_value)
+ monkeypatch.setattr('os.environ.get', lambda x, y: exp_value)
env_lookup = lookup_loader.get('env')
retval = env_lookup.run([env_var], None)
diff --git a/test/units/plugins/lookup/test_ini.py b/test/units/plugins/lookup/test_ini.py
index b2d883c..212cf08 100644
--- a/test/units/plugins/lookup/test_ini.py
+++ b/test/units/plugins/lookup/test_ini.py
@@ -16,11 +16,9 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from ansible.plugins.lookup.ini import _parse_params
diff --git a/test/units/plugins/lookup/test_password.py b/test/units/plugins/lookup/test_password.py
index 685f2ce..d615be9 100644
--- a/test/units/plugins/lookup/test_password.py
+++ b/test/units/plugins/lookup/test_password.py
@@ -16,9 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
try:
import passlib
@@ -31,11 +29,10 @@ import pytest
from units.mock.loader import DictDataLoader
-from units.compat import unittest
+import unittest
from unittest.mock import mock_open, patch
from ansible.errors import AnsibleError
-from ansible.module_utils.six import text_type
-from ansible.module_utils.six.moves import builtins
+import builtins
from ansible.module_utils.common.text.converters import to_bytes
from ansible.plugins.loader import PluginLoader, lookup_loader
from ansible.plugins.lookup import password
@@ -276,13 +273,13 @@ class TestRandomPassword(unittest.TestCase):
def test_default(self):
res = password.random_password()
self.assertEqual(len(res), DEFAULT_LENGTH)
- self.assertTrue(isinstance(res, text_type))
+ self.assertTrue(isinstance(res, str))
self._assert_valid_chars(res, DEFAULT_CANDIDATE_CHARS)
def test_zero_length(self):
res = password.random_password(length=0)
self.assertEqual(len(res), 0)
- self.assertTrue(isinstance(res, text_type))
+ self.assertTrue(isinstance(res, str))
self._assert_valid_chars(res, u',')
def test_just_a_common(self):
@@ -437,7 +434,7 @@ class TestLookupModuleWithoutPasslib(BaseTestLookupModule):
# FIXME: assert something useful
for result in results:
assert len(result) == DEFAULT_LENGTH
- assert isinstance(result, text_type)
+ assert isinstance(result, str)
@patch.object(PluginLoader, '_get_paths')
@patch('ansible.plugins.lookup.password._write_password_file')
@@ -520,7 +517,7 @@ class TestLookupModuleWithPasslib(BaseTestLookupModule):
# verify the string and parsehash agree on the number of rounds
self.assertEqual(int(str_parts[2]), crypt_parts['rounds'])
- self.assertIsInstance(result, text_type)
+ self.assertIsInstance(result, str)
@patch('ansible.plugins.lookup.password._write_password_file')
def test_password_already_created_encrypt(self, mock_write_file):
@@ -556,7 +553,7 @@ class TestLookupModuleWithPasslibWrappedAlgo(BaseTestLookupModule):
self.assertEqual(len(results), 1)
result = results[0]
- self.assertIsInstance(result, text_type)
+ self.assertIsInstance(result, str)
expected_password_length = 76
self.assertEqual(len(result), expected_password_length)
diff --git a/test/units/plugins/lookup/test_url.py b/test/units/plugins/lookup/test_url.py
index 2aa77b3..2c88a05 100644
--- a/test/units/plugins/lookup/test_url.py
+++ b/test/units/plugins/lookup/test_url.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2020, Sam Doran <sdoran@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/plugins/shell/test_cmd.py b/test/units/plugins/shell/test_cmd.py
index 4c1a654..fe75d9d 100644
--- a/test/units/plugins/shell/test_cmd.py
+++ b/test/units/plugins/shell/test_cmd.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/plugins/shell/test_powershell.py b/test/units/plugins/shell/test_powershell.py
index c94baab..90ee008 100644
--- a/test/units/plugins/shell/test_powershell.py
+++ b/test/units/plugins/shell/test_powershell.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.plugins.shell.powershell import _parse_clixml, ShellModule
diff --git a/test/units/plugins/strategy/test_linear.py b/test/units/plugins/strategy/test_linear.py
index b39c142..6f4ea92 100644
--- a/test/units/plugins/strategy/test_linear.py
+++ b/test/units/plugins/strategy/test_linear.py
@@ -1,12 +1,10 @@
# Copyright (c) 2018 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from unittest.mock import patch, MagicMock
from ansible.executor.play_iterator import PlayIterator
diff --git a/test/units/plugins/test_plugins.py b/test/units/plugins/test_plugins.py
index ba2ad2b..4bd96a1 100644
--- a/test/units/plugins/test_plugins.py
+++ b/test/units/plugins/test_plugins.py
@@ -16,13 +16,11 @@
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
-from units.compat import unittest
+import unittest
from unittest.mock import patch, MagicMock
from ansible.plugins.loader import PluginLoader, PluginPathContext
diff --git a/test/units/regex/test_invalid_var_names.py b/test/units/regex/test_invalid_var_names.py
index d47e68d..8aed871 100644
--- a/test/units/regex/test_invalid_var_names.py
+++ b/test/units/regex/test_invalid_var_names.py
@@ -1,8 +1,6 @@
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
-from units.compat import unittest
+import unittest
from ansible import constants as C
diff --git a/test/units/template/test_native_concat.py b/test/units/template/test_native_concat.py
index ee1b7df..5b41dbc 100644
--- a/test/units/template/test_native_concat.py
+++ b/test/units/template/test_native_concat.py
@@ -1,9 +1,7 @@
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.playbook.conditional import Conditional
from ansible.template import Templar
diff --git a/test/units/template/test_templar.py b/test/units/template/test_templar.py
index 02840e1..e57f591 100644
--- a/test/units/template/test_templar.py
+++ b/test/units/template/test_templar.py
@@ -15,13 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from jinja2.runtime import Context
-from units.compat import unittest
+import unittest
from ansible import constants as C
from ansible.errors import AnsibleError, AnsibleUndefinedVariable
diff --git a/test/units/template/test_template_utilities.py b/test/units/template/test_template_utilities.py
index 1044895..5f934d9 100644
--- a/test/units/template/test_template_utilities.py
+++ b/test/units/template/test_template_utilities.py
@@ -15,12 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import jinja2
-from units.compat import unittest
+import unittest
from ansible.template import AnsibleUndefined, _escape_backslashes, _count_newlines_from_end
diff --git a/test/units/template/test_vars.py b/test/units/template/test_vars.py
index f43cfac..9547d1e 100644
--- a/test/units/template/test_vars.py
+++ b/test/units/template/test_vars.py
@@ -15,9 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible.template import Templar
from ansible.template.vars import AnsibleJ2Vars
diff --git a/test/units/test_context.py b/test/units/test_context.py
index 24e2376..545b151 100644
--- a/test/units/test_context.py
+++ b/test/units/test_context.py
@@ -2,9 +2,7 @@
# Copyright: (c) 2018, Toshio Kuratomi <tkuratomi@ansible.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ansible import context
diff --git a/test/units/test_no_tty.py b/test/units/test_no_tty.py
index 290c0b9..1103ff0 100644
--- a/test/units/test_no_tty.py
+++ b/test/units/test_no_tty.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import sys
diff --git a/test/units/utils/collection_loader/fixtures/collections/ansible_collections/ansible/builtin/plugins/modules/shouldnotload.py b/test/units/utils/collection_loader/fixtures/collections/ansible_collections/ansible/builtin/plugins/modules/shouldnotload.py
index 4041a33..6f98990 100644
--- a/test/units/utils/collection_loader/fixtures/collections/ansible_collections/ansible/builtin/plugins/modules/shouldnotload.py
+++ b/test/units/utils/collection_loader/fixtures/collections/ansible_collections/ansible/builtin/plugins/modules/shouldnotload.py
@@ -1,4 +1,3 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations # pragma: nocover
-raise Exception('this module should never be loaded')
+raise Exception('this module should never be loaded') # pragma: nocover
diff --git a/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/action/my_action.py b/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/action/my_action.py
index a85f422..42f089d 100644
--- a/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/action/my_action.py
+++ b/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/action/my_action.py
@@ -1,8 +1,7 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from ..module_utils.my_util import question # pylint: disable=unused-import
def action_code():
- return "hello from my_action.py"
+ raise Exception('hello from my_action.py, this code should never execute') # pragma: nocover
diff --git a/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/module_utils/my_other_util.py b/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/module_utils/my_other_util.py
index 463b133..ddb7e47 100644
--- a/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/module_utils/my_other_util.py
+++ b/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/module_utils/my_other_util.py
@@ -1,4 +1,3 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from .my_util import question # pylint: disable=unused-import
diff --git a/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/module_utils/my_util.py b/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/module_utils/my_util.py
index c431c34..f551875 100644
--- a/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/module_utils/my_util.py
+++ b/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/module_utils/my_util.py
@@ -1,6 +1,6 @@
# WARNING: Changing line numbers of code in this file will break collection tests that use tracing to check paths and line numbers.
-# Also, do not import division from __future__ as this will break detection of __future__ inheritance on Python 2.
+# Also, do not import annotations from __future__ as this will break detection of __future__ inheritance.
-def question():
+def question() -> float:
return 3 / 2
diff --git a/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/modules/__init__.py b/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/modules/__init__.py
index 6d69703..9e774e1 100644
--- a/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/modules/__init__.py
+++ b/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/modules/__init__.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations # pragma: nocover
-raise Exception('this should never run')
+raise Exception('this should never run') # pragma: nocover
diff --git a/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/modules/amodule.py b/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/modules/amodule.py
index 99320a0..bca4751 100644
--- a/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/modules/amodule.py
+++ b/test/units/utils/collection_loader/fixtures/collections/ansible_collections/testns/testcoll/plugins/modules/amodule.py
@@ -1,6 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations # pragma: nocover
-def module_code():
- return "hello from amodule.py"
+raise Exception('hello from amodule.py, this code should never execute') # pragma: nocover
diff --git a/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/__init__.py b/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/__init__.py
index 6068ac1..c197d42 100644
--- a/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/__init__.py
+++ b/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/__init__.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations # pragma: nocover
-raise Exception('this code should never execute')
+raise Exception('this code should never execute') # pragma: nocover
diff --git a/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/ansible/__init__.py b/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/ansible/__init__.py
index 6068ac1..c197d42 100644
--- a/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/ansible/__init__.py
+++ b/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/ansible/__init__.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations # pragma: nocover
-raise Exception('this code should never execute')
+raise Exception('this code should never execute') # pragma: nocover
diff --git a/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/__init__.py b/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/__init__.py
index 6068ac1..c197d42 100644
--- a/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/__init__.py
+++ b/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/__init__.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations # pragma: nocover
-raise Exception('this code should never execute')
+raise Exception('this code should never execute') # pragma: nocover
diff --git a/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/testcoll/__init__.py b/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/testcoll/__init__.py
index 6068ac1..c197d42 100644
--- a/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/testcoll/__init__.py
+++ b/test/units/utils/collection_loader/fixtures/collections_masked/ansible_collections/testns/testcoll/__init__.py
@@ -1,5 +1,4 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations # pragma: nocover
-raise Exception('this code should never execute')
+raise Exception('this code should never execute') # pragma: nocover
diff --git a/test/units/utils/collection_loader/test_collection_loader.py b/test/units/utils/collection_loader/test_collection_loader.py
index feaaf97..51aab2c 100644
--- a/test/units/utils/collection_loader/test_collection_loader.py
+++ b/test/units/utils/collection_loader/test_collection_loader.py
@@ -1,14 +1,13 @@
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
+import inspect
import os
import pkgutil
import pytest
import re
import sys
+from importlib import import_module
-from ansible.module_utils.six import PY3, string_types
-from ansible.module_utils.compat.importlib import import_module
from ansible.modules import ping as ping_module
from ansible.utils.collection_loader import AnsibleCollectionConfig, AnsibleCollectionRef
from ansible.utils.collection_loader._collection_finder import (
@@ -37,7 +36,7 @@ def teardown(*args, **kwargs):
r'FileFinder\.find_loader\(\) is deprecated and slated for removal in Python 3\.12; use find_spec\(\) instead'
':DeprecationWarning',
)
-@pytest.mark.skipif(not PY3 or sys.version_info >= (3, 12), reason='Testing Python 2 codepath (find_module) on Python 3, <= 3.11')
+@pytest.mark.skipif(sys.version_info >= (3, 12), reason='Testing Python 2 codepath (find_module) on Python 3, <= 3.11')
def test_find_module_py3_lt_312():
dir_to_a_file = os.path.dirname(ping_module.__file__)
path_hook_finder = _AnsiblePathHookFinder(_AnsibleCollectionFinder(), dir_to_a_file)
@@ -186,8 +185,7 @@ def test_root_loader():
name = 'ansible_collections'
# ensure this works even when ansible_collections doesn't exist on disk
for paths in [], default_test_collection_paths:
- if name in sys.modules:
- del sys.modules[name]
+ sys.modules.pop(name, None)
loader = _AnsibleCollectionRootPkgLoader(name, paths)
assert repr(loader).startswith('_AnsibleCollectionRootPkgLoader(path=')
module = loader.load_module(name)
@@ -214,8 +212,7 @@ def test_nspkg_loader_load_module():
module_to_load = name.rpartition('.')[2]
paths = extend_paths(default_test_collection_paths, parent_pkg)
existing_child_paths = [p for p in extend_paths(paths, module_to_load) if os.path.exists(p)]
- if name in sys.modules:
- del sys.modules[name]
+ sys.modules.pop(name, None)
loader = _AnsibleCollectionNSPkgLoader(name, path_list=paths)
assert repr(loader).startswith('_AnsibleCollectionNSPkgLoader(path=')
module = loader.load_module(name)
@@ -244,8 +241,7 @@ def test_collpkg_loader_load_module():
paths = extend_paths(default_test_collection_paths, parent_pkg)
existing_child_paths = [p for p in extend_paths(paths, module_to_load) if os.path.exists(p)]
is_builtin = 'ansible.builtin' in name
- if name in sys.modules:
- del sys.modules[name]
+ sys.modules.pop(name, None)
loader = _AnsibleCollectionPkgLoader(name, path_list=paths)
assert repr(loader).startswith('_AnsibleCollectionPkgLoader(path=')
module = loader.load_module(name)
@@ -267,13 +263,16 @@ def test_collpkg_loader_load_module():
# FIXME: validate _collection_meta contents match what's on disk (or not)
- # if the module has metadata, try loading it with busted metadata
- if module._collection_meta:
- _collection_finder = import_module('ansible.utils.collection_loader._collection_finder')
- with patch.object(_collection_finder, '_meta_yml_to_dict', side_effect=Exception('bang')):
- with pytest.raises(Exception) as ex:
- _AnsibleCollectionPkgLoader(name, path_list=paths).load_module(name)
- assert 'error parsing collection metadata' in str(ex.value)
+ # verify the module has metadata, then try loading it with busted metadata
+ assert module._collection_meta
+
+ _collection_finder = import_module('ansible.utils.collection_loader._collection_finder')
+
+ with patch.object(_collection_finder, '_meta_yml_to_dict', side_effect=Exception('bang')):
+ with pytest.raises(Exception) as ex:
+ _AnsibleCollectionPkgLoader(name, path_list=paths).load_module(name)
+
+ assert 'error parsing collection metadata' in str(ex.value)
def test_coll_loader():
@@ -298,10 +297,7 @@ def test_path_hook_setup():
except Exception as phe:
pathhook_exc = phe
- if PY3:
- assert str(pathhook_exc) == 'need exactly one FileFinder import hook (found 0)'
- else:
- assert found_hook is None
+ assert str(pathhook_exc) == 'need exactly one FileFinder import hook (found 0)'
assert repr(_AnsiblePathHookFinder(object(), '/bogus/path')) == "_AnsiblePathHookFinder(path='/bogus/path')"
@@ -410,7 +406,7 @@ def test_import_from_collection(monkeypatch):
original_trace_function = sys.gettrace()
trace_log = []
- if original_trace_function:
+ if original_trace_function: # pragma: nocover
# enable tracing while preserving the existing trace function (coverage)
def my_trace_function(frame, event, arg):
trace_log.append((frame.f_code.co_filename, frame.f_lineno, event))
@@ -423,7 +419,7 @@ def test_import_from_collection(monkeypatch):
sys.settrace(my_trace_function)
return my_trace_function
- else:
+ else: # pragma: nocover
# no existing trace function, so our trace function is much simpler
def my_trace_function(frame, event, arg):
trace_log.append((frame.f_code.co_filename, frame.f_lineno, event))
@@ -485,11 +481,8 @@ def test_import_from_collection(monkeypatch):
import ansible_collections.testns.testcoll.plugins.action.my_action
# verify that code loaded from a collection does not inherit __future__ statements from the collection loader
- if sys.version_info[0] == 2:
- # if the collection code inherits the division future feature from the collection loader this will fail
- assert answer == 1
- else:
- assert answer == 1.5
+ # if the collection code inherits the annotations future feature from the collection loader this will fail
+ assert inspect.get_annotations(question)['return'] is float
# verify that the filename and line number reported by the trace is correct
# this makes sure that collection loading preserves file paths and line numbers
@@ -822,7 +815,7 @@ def test_collectionref_components_valid(name, subdirs, resource, ref_type, pytho
]
)
def test_legacy_plugin_dir_to_plugin_type(dirname, expected_result):
- if isinstance(expected_result, string_types):
+ if isinstance(expected_result, str):
assert AnsibleCollectionRef.legacy_plugin_dir_to_plugin_type(dirname) == expected_result
else:
with pytest.raises(expected_result):
@@ -846,12 +839,8 @@ def test_collectionref_components_invalid(name, subdirs, resource, ref_type, exp
assert re.search(expected_error_expression, str(curerr.value))
-@pytest.mark.skipif(not PY3, reason='importlib.resources only supported for py3')
def test_importlib_resources():
- if sys.version_info < (3, 10):
- from importlib_resources import files
- else:
- from importlib.resources import files
+ from importlib.resources import files
from pathlib import Path
f = get_default_finder()
diff --git a/test/units/utils/display/test_broken_cowsay.py b/test/units/utils/display/test_broken_cowsay.py
index 96157e1..854b78b 100644
--- a/test/units/utils/display/test_broken_cowsay.py
+++ b/test/units/utils/display/test_broken_cowsay.py
@@ -2,9 +2,7 @@
# Copyright (c) 2021 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
+from __future__ import annotations
from ansible.utils.display import Display
diff --git a/test/units/utils/display/test_curses.py b/test/units/utils/display/test_curses.py
index 05efc41..6816b71 100644
--- a/test/units/utils/display/test_curses.py
+++ b/test/units/utils/display/test_curses.py
@@ -2,8 +2,7 @@
# Copyright (c) 2021 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import curses
import importlib
diff --git a/test/units/utils/display/test_display.py b/test/units/utils/display/test_display.py
index cdeb496..af5f659 100644
--- a/test/units/utils/display/test_display.py
+++ b/test/units/utils/display/test_display.py
@@ -2,8 +2,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.utils.display import Display
diff --git a/test/units/utils/display/test_logger.py b/test/units/utils/display/test_logger.py
index ed69393..8767aff 100644
--- a/test/units/utils/display/test_logger.py
+++ b/test/units/utils/display/test_logger.py
@@ -2,8 +2,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import logging
diff --git a/test/units/utils/display/test_warning.py b/test/units/utils/display/test_warning.py
index be63c34..32870fa 100644
--- a/test/units/utils/display/test_warning.py
+++ b/test/units/utils/display/test_warning.py
@@ -2,8 +2,7 @@
# Copyright (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/utils/test_cleanup_tmp_file.py b/test/units/utils/test_cleanup_tmp_file.py
index 35374f4..213961d 100644
--- a/test/units/utils/test_cleanup_tmp_file.py
+++ b/test/units/utils/test_cleanup_tmp_file.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2019, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
import tempfile
diff --git a/test/units/utils/test_context_objects.py b/test/units/utils/test_context_objects.py
index c56a41d..eb6bfa9 100644
--- a/test/units/utils/test_context_objects.py
+++ b/test/units/utils/test_context_objects.py
@@ -2,8 +2,7 @@
# Copyright: (c) 2018, Toshio Kuratomi <tkuratomi@ansible.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import argparse
diff --git a/test/units/utils/test_display.py b/test/units/utils/test_display.py
index 80b7a09..ae7b16b 100644
--- a/test/units/utils/test_display.py
+++ b/test/units/utils/test_display.py
@@ -2,8 +2,7 @@
# (c) 2020 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import locale
import sys
diff --git a/test/units/utils/test_encrypt.py b/test/units/utils/test_encrypt.py
index be32579..4683b81 100644
--- a/test/units/utils/test_encrypt.py
+++ b/test/units/utils/test_encrypt.py
@@ -1,10 +1,7 @@
# (c) 2018, Matthias Fuchs <matthias.s.fuchs@gmail.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-import sys
+from __future__ import annotations
import pytest
@@ -13,50 +10,17 @@ from ansible.plugins.filter.core import get_encrypted_password
from ansible.utils import encrypt
-class passlib_off(object):
- def __init__(self):
- self.orig = encrypt.PASSLIB_AVAILABLE
-
- def __enter__(self):
- encrypt.PASSLIB_AVAILABLE = False
- return self
-
- def __exit__(self, exception_type, exception_value, traceback):
- encrypt.PASSLIB_AVAILABLE = self.orig
-
-
def assert_hash(expected, secret, algorithm, **settings):
-
assert encrypt.do_encrypt(secret, algorithm, **settings) == expected
- if encrypt.PASSLIB_AVAILABLE:
- assert encrypt.PasslibHash(algorithm).hash(secret, **settings) == expected
- else:
- with pytest.raises(AnsibleError) as excinfo:
- encrypt.PasslibHash(algorithm).hash(secret, **settings)
- assert excinfo.value.args[0] == "passlib must be installed and usable to hash with '%s'" % algorithm
+ assert encrypt.PasslibHash(algorithm).hash(secret, **settings) == expected
-@pytest.mark.skipif(sys.platform.startswith('darwin'), reason='macOS requires passlib')
-def test_passlib_or_crypt():
- with passlib_off():
- expected = "$5$rounds=5000$12345678$uAZsE3BenI2G.nA8DpTl.9Dc8JiqacI53pEqRr5ppT7"
- assert encrypt.passlib_or_crypt("123", "sha256_crypt", salt="12345678", rounds=5000) == expected
-
+@pytest.mark.skipif(not encrypt.PASSLIB_AVAILABLE, reason='passlib must be installed to run this test')
+def test_passlib():
expected = "$5$12345678$uAZsE3BenI2G.nA8DpTl.9Dc8JiqacI53pEqRr5ppT7"
assert encrypt.passlib_or_crypt("123", "sha256_crypt", salt="12345678", rounds=5000) == expected
-@pytest.mark.skipif(sys.platform.startswith('darwin'), reason='macOS requires passlib')
-def test_encrypt_with_rounds_no_passlib():
- with passlib_off():
- assert_hash("$5$rounds=5000$12345678$uAZsE3BenI2G.nA8DpTl.9Dc8JiqacI53pEqRr5ppT7",
- secret="123", algorithm="sha256_crypt", salt="12345678", rounds=5000)
- assert_hash("$5$rounds=10000$12345678$JBinliYMFEcBeAXKZnLjenhgEhTmJBvZn3aR8l70Oy/",
- secret="123", algorithm="sha256_crypt", salt="12345678", rounds=10000)
- assert_hash("$6$rounds=5000$12345678$LcV9LQiaPekQxZ.OfkMADjFdSO2k9zfbDQrHPVcYjSLqSdjLYpsgqviYvTEP/R41yPmhH3CCeEDqVhW1VHr3L.",
- secret="123", algorithm="sha512_crypt", salt="12345678", rounds=5000)
-
-
@pytest.mark.skipif(not encrypt.PASSLIB_AVAILABLE, reason='passlib must be installed to run this test')
def test_encrypt_with_ident():
assert_hash("$2$12$123456789012345678901ufd3hZRrev.WXCbemqGIV/gmWaTGLImm",
@@ -85,19 +49,6 @@ def test_encrypt_with_rounds():
secret="123", algorithm="sha512_crypt", salt="12345678", rounds=5000)
-@pytest.mark.skipif(sys.platform.startswith('darwin'), reason='macOS requires passlib')
-def test_encrypt_default_rounds_no_passlib():
- with passlib_off():
- assert_hash("$1$12345678$tRy4cXc3kmcfRZVj4iFXr/",
- secret="123", algorithm="md5_crypt", salt="12345678")
- assert_hash("$5$12345678$uAZsE3BenI2G.nA8DpTl.9Dc8JiqacI53pEqRr5ppT7",
- secret="123", algorithm="sha256_crypt", salt="12345678")
- assert_hash("$6$12345678$LcV9LQiaPekQxZ.OfkMADjFdSO2k9zfbDQrHPVcYjSLqSdjLYpsgqviYvTEP/R41yPmhH3CCeEDqVhW1VHr3L.",
- secret="123", algorithm="sha512_crypt", salt="12345678")
-
- assert encrypt.CryptHash("md5_crypt").hash("123")
-
-
# If passlib is not installed. this is identical to the test_encrypt_default_rounds_no_passlib() test
@pytest.mark.skipif(not encrypt.PASSLIB_AVAILABLE, reason='passlib must be installed to run this test')
def test_encrypt_default_rounds():
@@ -111,16 +62,6 @@ def test_encrypt_default_rounds():
assert encrypt.PasslibHash("md5_crypt").hash("123")
-@pytest.mark.skipif(sys.platform.startswith('darwin'), reason='macOS requires passlib')
-def test_password_hash_filter_no_passlib():
- with passlib_off():
- assert not encrypt.PASSLIB_AVAILABLE
- assert get_encrypted_password("123", "md5", salt="12345678") == "$1$12345678$tRy4cXc3kmcfRZVj4iFXr/"
-
- with pytest.raises(AnsibleFilterError):
- get_encrypted_password("123", "crypt16", salt="12")
-
-
@pytest.mark.skipif(not encrypt.PASSLIB_AVAILABLE, reason='passlib must be installed to run this test')
def test_password_hash_filter_passlib():
@@ -148,16 +89,6 @@ def test_password_hash_filter_passlib():
assert get_encrypted_password("123", "pbkdf2_sha256", ident='invalid_ident')
-@pytest.mark.skipif(sys.platform.startswith('darwin'), reason='macOS requires passlib')
-def test_do_encrypt_no_passlib():
- with passlib_off():
- assert not encrypt.PASSLIB_AVAILABLE
- assert encrypt.do_encrypt("123", "md5_crypt", salt="12345678") == "$1$12345678$tRy4cXc3kmcfRZVj4iFXr/"
-
- with pytest.raises(AnsibleError):
- encrypt.do_encrypt("123", "crypt16", salt="12")
-
-
@pytest.mark.skipif(not encrypt.PASSLIB_AVAILABLE, reason='passlib must be installed to run this test')
def test_do_encrypt_passlib():
with pytest.raises(AnsibleError):
@@ -183,30 +114,6 @@ def test_random_salt():
assert res_char in expected_salt_candidate_chars
-@pytest.mark.skipif(sys.platform.startswith('darwin'), reason='macOS requires passlib')
-def test_invalid_crypt_salt():
- pytest.raises(
- AnsibleError,
- encrypt.CryptHash('bcrypt')._salt,
- '_',
- None
- )
- encrypt.CryptHash('bcrypt')._salt('1234567890123456789012', None)
- pytest.raises(
- AnsibleError,
- encrypt.CryptHash('bcrypt')._salt,
- 'kljsdf',
- None
- )
- encrypt.CryptHash('sha256_crypt')._salt('123456', None)
- pytest.raises(
- AnsibleError,
- encrypt.CryptHash('sha256_crypt')._salt,
- '1234567890123456789012',
- None
- )
-
-
def test_passlib_bcrypt_salt(recwarn):
passlib_exc = pytest.importorskip("passlib.exc")
diff --git a/test/units/utils/test_helpers.py b/test/units/utils/test_helpers.py
index ec37b39..75e42c3 100644
--- a/test/units/utils/test_helpers.py
+++ b/test/units/utils/test_helpers.py
@@ -15,8 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import unittest
diff --git a/test/units/utils/test_isidentifier.py b/test/units/utils/test_isidentifier.py
index de6de64..e4b2a40 100644
--- a/test/units/utils/test_isidentifier.py
+++ b/test/units/utils/test_isidentifier.py
@@ -2,9 +2,7 @@
# Copyright: (c) 2020 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import pytest
diff --git a/test/units/utils/test_plugin_docs.py b/test/units/utils/test_plugin_docs.py
index ff973b1..d80f447 100644
--- a/test/units/utils/test_plugin_docs.py
+++ b/test/units/utils/test_plugin_docs.py
@@ -2,8 +2,7 @@
# (c) 2020 Felix Fontein <felix@fontein.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import copy
@@ -292,7 +291,7 @@ ADD_TESTS = [
),
(
# Return values
- True, # this value is is ignored
+ True, # this value is ignored
True,
{
'rv1': {
diff --git a/test/units/utils/test_shlex.py b/test/units/utils/test_shlex.py
index e13d302..97a69c6 100644
--- a/test/units/utils/test_shlex.py
+++ b/test/units/utils/test_shlex.py
@@ -15,8 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import unittest
diff --git a/test/units/utils/test_unsafe_proxy.py b/test/units/utils/test_unsafe_proxy.py
index 55f1b6d..483826a 100644
--- a/test/units/utils/test_unsafe_proxy.py
+++ b/test/units/utils/test_unsafe_proxy.py
@@ -2,8 +2,7 @@
# (c) 2018 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
import pathlib
import sys
diff --git a/test/units/utils/test_vars.py b/test/units/utils/test_vars.py
index 9be33de..11b01d1 100644
--- a/test/units/utils/test_vars.py
+++ b/test/units/utils/test_vars.py
@@ -16,17 +16,16 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
from collections import defaultdict
from unittest import mock
-from units.compat import unittest
+import unittest
from ansible.errors import AnsibleError
from ansible.utils.vars import combine_vars, merge_hash
+from ansible.vars.manager import VarsWithSources
class TestVariableUtils(unittest.TestCase):
@@ -43,6 +42,11 @@ class TestVariableUtils(unittest.TestCase):
result=dict(a=1, b=2),
),
dict(
+ a=dict(a=1),
+ b=VarsWithSources().new_vars_with_sources(dict(b=2), dict(b='task vars')),
+ result=dict(a=1, b=2),
+ ),
+ dict(
a=dict(a=1, c=dict(foo='bar')),
b=dict(b=2, c=dict(baz='bam')),
result=dict(a=1, b=2, c=dict(foo='bar', baz='bam'))
@@ -60,6 +64,11 @@ class TestVariableUtils(unittest.TestCase):
result=dict(a=1, b=2)
),
dict(
+ a=dict(a=1),
+ b=VarsWithSources().new_vars_with_sources(dict(b=2), dict(b='task vars')),
+ result=dict(a=1, b=2),
+ ),
+ dict(
a=dict(a=1, c=dict(foo='bar')),
b=dict(b=2, c=dict(baz='bam')),
result=dict(a=1, b=2, c=dict(baz='bam'))
diff --git a/test/units/utils/test_version.py b/test/units/utils/test_version.py
index 3c2cbaf..715076a 100644
--- a/test/units/utils/test_version.py
+++ b/test/units/utils/test_version.py
@@ -2,8 +2,7 @@
# (c) 2020 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.module_utils.compat.version import LooseVersion, StrictVersion
diff --git a/test/units/vars/test_module_response_deepcopy.py b/test/units/vars/test_module_response_deepcopy.py
index 3313dea..d484da0 100644
--- a/test/units/vars/test_module_response_deepcopy.py
+++ b/test/units/vars/test_module_response_deepcopy.py
@@ -2,8 +2,7 @@
# (c) 2018 Matt Martz <matt@sivel.net>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-from __future__ import absolute_import, division, print_function
-__metaclass__ = type
+from __future__ import annotations
from ansible.vars.clean import module_response_deepcopy
diff --git a/test/units/vars/test_variable_manager.py b/test/units/vars/test_variable_manager.py
index ee6de81..0318d9c 100644
--- a/test/units/vars/test_variable_manager.py
+++ b/test/units/vars/test_variable_manager.py
@@ -15,16 +15,13 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
+from __future__ import annotations
import os
-from units.compat import unittest
+import unittest
from unittest.mock import MagicMock, patch
from ansible.inventory.manager import InventoryManager
-from ansible.module_utils.six import iteritems
from ansible.playbook.play import Play
@@ -59,7 +56,7 @@ class TestVariableManager(unittest.TestCase):
v._extra_vars = extra_vars
myvars = v.get_vars(use_cache=False)
- for (key, val) in iteritems(extra_vars):
+ for key, val in extra_vars.items():
self.assertEqual(myvars.get(key), val)
def test_variable_manager_options_vars(self):
@@ -73,7 +70,7 @@ class TestVariableManager(unittest.TestCase):
v._extra_vars = options_vars
myvars = v.get_vars(use_cache=False)
- for (key, val) in iteritems(options_vars):
+ for key, val in options_vars.items():
self.assertEqual(myvars.get(key), val)
def test_variable_manager_play_vars(self):