From e4d7286298ea72c80097b86b9d747b5e9b319994 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 8 Aug 2024 15:18:00 -0400 Subject: [PATCH] use diff intermediate var to preserve functionality (#83738) add tests --- lib/ansible/parsing/mod_args.py | 5 +++-- .../targets/run_modules/run_raw_args.yml | 17 +++++++++++++++++ test/integration/targets/run_modules/runme.sh | 11 +++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 test/integration/targets/run_modules/run_raw_args.yml diff --git a/lib/ansible/parsing/mod_args.py b/lib/ansible/parsing/mod_args.py index eeca065a852..bf8275b69fa 100644 --- a/lib/ansible/parsing/mod_args.py +++ b/lib/ansible/parsing/mod_args.py @@ -29,8 +29,9 @@ from ansible.utils.sentinel import Sentinel # modules formated for user msg -FREEFORM_ACTIONS = set(C.MODULE_REQUIRE_ARGS_SIMPLE) -RAW_PARAM_MODULES = FREEFORM_ACTIONS.union(set([ +FREEFORM_ACTIONS_SIMPLE = set(C.MODULE_REQUIRE_ARGS_SIMPLE) +FREEFORM_ACTIONS = frozenset(add_internal_fqcns(FREEFORM_ACTIONS_SIMPLE)) +RAW_PARAM_MODULES = FREEFORM_ACTIONS_SIMPLE.union(set([ 'include_vars', 'include_tasks', 'include_role', diff --git a/test/integration/targets/run_modules/run_raw_args.yml b/test/integration/targets/run_modules/run_raw_args.yml new file mode 100644 index 00000000000..d1f3c979a55 --- /dev/null +++ b/test/integration/targets/run_modules/run_raw_args.yml @@ -0,0 +1,17 @@ +- hosts: localhost + gather_facts: false + vars: + output_dir: '{{ lookup("env", "OUTPUT_DIR") }}' + tasks: + - name: set tempfile + tempfile: + path: '{{output_dir}}' + prefix: 'ansible-test' + state: file + register: mktemp + + - name: ensure 'command' can use raw args + command: dd if=/dev/zero of="{{mktemp.path}}" bs=1K count=1 + + - name: ensure fqcn 'command' can use raw args + ansible.legacy.command: dd if=/dev/zero of="{{mktemp.path}}" bs=1K count=1 diff --git a/test/integration/targets/run_modules/runme.sh b/test/integration/targets/run_modules/runme.sh index 34c245cbf61..94c09f09af0 100755 --- a/test/integration/targets/run_modules/runme.sh +++ b/test/integration/targets/run_modules/runme.sh @@ -4,3 +4,14 @@ set -eux # test running module directly python.py library/test.py args.json + +TMPFILE=$(shell mktemp -p "${OUTPUT_DIR}" 2>/dev/null || mktemp -t 'ansible-testing-XXXXXXXXXX' -p "${OUTPUT_DIR}") + +# ensure 'command' can use 'raw args' +ansible -m command -a "dd if=/dev/zero of=\"${TMPFILE}\" bs=1K count=1" localhost + +# ensure fqcn 'command' can use 'raw args' +ansible -m ansible.legacy.command -a "dd if=/dev/zero of=\"${TMPFILE}\" bs=1K count=1" localhost + +# same in playbook +ansible-playbook run_raw_args.yml "$@"