diff --git a/changelogs/fragments/3671-illumos-pfexec.yml b/changelogs/fragments/3671-illumos-pfexec.yml new file mode 100644 index 0000000000..b1fcdb31ea --- /dev/null +++ b/changelogs/fragments/3671-illumos-pfexec.yml @@ -0,0 +1,2 @@ +minor_changes: + - "become_pfexec - remove superflous quotes preventing exe wrap from working as expected, fixes #3671, see https://github.com/ansible-collections/community.general/issues/3671#issuecomment-1174906473" diff --git a/plugins/become/pfexec.py b/plugins/become/pfexec.py index 2b37044c93..ee67857647 100644 --- a/plugins/become/pfexec.py +++ b/plugins/become/pfexec.py @@ -101,4 +101,4 @@ class BecomeModule(BecomeBase): flags = self.get_option('become_flags') noexe = not self.get_option('wrap_exe') - return '%s %s "%s"' % (exe, flags, self._build_success_command(cmd, shell, noexe=noexe)) + return '%s %s %s' % (exe, flags, self._build_success_command(cmd, shell, noexe=noexe)) diff --git a/tests/unit/plugins/become/test_pfexec.py b/tests/unit/plugins/become/test_pfexec.py index 3adc2ed51d..ce37d4159f 100644 --- a/tests/unit/plugins/become/test_pfexec.py +++ b/tests/unit/plugins/become/test_pfexec.py @@ -31,7 +31,7 @@ def test_pfexec_basic(mocker, parser, reset_cli_args): var_options = {} cmd = call_become_plugin(task, var_options, cmd=default_cmd, executable=default_exe) print(cmd) - assert re.match('''%s %s "'echo %s; %s'"''' % (pfexec_exe, pfexec_flags, success, default_cmd), cmd) is not None + assert re.match("""%s %s 'echo %s; %s'""" % (pfexec_exe, pfexec_flags, success, default_cmd), cmd) is not None def test_pfexec(mocker, parser, reset_cli_args): @@ -53,7 +53,7 @@ def test_pfexec(mocker, parser, reset_cli_args): var_options = {} cmd = call_become_plugin(task, var_options, cmd=default_cmd, executable=default_exe) print(cmd) - assert re.match('''%s %s "'echo %s; %s'"''' % (pfexec_exe, pfexec_flags, success, default_cmd), cmd) is not None + assert re.match("""%s %s 'echo %s; %s'""" % (pfexec_exe, pfexec_flags, success, default_cmd), cmd) is not None def test_pfexec_varoptions(mocker, parser, reset_cli_args): @@ -78,4 +78,4 @@ def test_pfexec_varoptions(mocker, parser, reset_cli_args): } cmd = call_become_plugin(task, var_options, cmd=default_cmd, executable=default_exe) print(cmd) - assert re.match('''%s %s "'echo %s; %s'"''' % (pfexec_exe, pfexec_flags, success, default_cmd), cmd) is not None + assert re.match("""%s %s 'echo %s; %s'""" % (pfexec_exe, pfexec_flags, success, default_cmd), cmd) is not None