diff options
author | Brian Coca <bcoca@users.noreply.github.com> | 2018-05-30 16:03:58 -0400 |
---|---|---|
committer | ansibot <ansibot@users.noreply.github.com> | 2018-05-30 16:03:58 -0400 |
commit | 5a77aceae57d3b7156306fe1927a09d579822fa6 (patch) | |
tree | e88a101c2f8784878af01719b938cce0ee3c16a9 | |
parent | f7f8d2b13304aed95c0b69f999872709d27b6b22 (diff) | |
download | ansible-5a77aceae57d3b7156306fe1927a09d579822fa6.tar.gz |
fix 'doas' become_method support, previously committed patch not submitted to devel branch (#37511) (#40896)
* fix become_method 'doas' support by properly specifying becomecmd
a repatch of https://github.com/ansible/ansible/pull/13451/ which was never committed to 'devel' branch.
* fix play_context test for become_method doas to match new becomecmd
(cherry picked from commit be3670f5285a4eebfa5b4947806618cab59d969c)
-rw-r--r-- | changelogs/fragments/fix_doas.yml | 2 | ||||
-rw-r--r-- | lib/ansible/playbook/play_context.py | 2 | ||||
-rw-r--r-- | test/units/playbook/test_play_context.py | 3 |
3 files changed, 4 insertions, 3 deletions
diff --git a/changelogs/fragments/fix_doas.yml b/changelogs/fragments/fix_doas.yml new file mode 100644 index 0000000000..8f179d05b5 --- /dev/null +++ b/changelogs/fragments/fix_doas.yml @@ -0,0 +1,2 @@ +- bugfix: + - fix doas construction for become https://github.com/ansible/ansible/pull/37511 diff --git a/lib/ansible/playbook/play_context.py b/lib/ansible/playbook/play_context.py index 669584b051..ea8bb8770d 100644 --- a/lib/ansible/playbook/play_context.py +++ b/lib/ansible/playbook/play_context.py @@ -544,7 +544,7 @@ class PlayContext(Base): flags += ' -u %s ' % self.become_user # FIXME: make shell independent - becomecmd = '%s %s echo %s && %s %s env ANSIBLE=true %s' % (exe, flags, success_key, exe, flags, cmd) + becomecmd = '%s %s %s -c %s' % (exe, flags, executable, success_cmd) elif self.become_method == 'dzdo': diff --git a/test/units/playbook/test_play_context.py b/test/units/playbook/test_play_context.py index 47b6958231..bcad2f6b30 100644 --- a/test/units/playbook/test_play_context.py +++ b/test/units/playbook/test_play_context.py @@ -153,8 +153,7 @@ def test_play_context_make_become_cmd(parser): play_context.become_method = 'doas' cmd = play_context.make_become_cmd(cmd=default_cmd, executable="/bin/bash") - assert (cmd == """%s %s echo %s && %s %s env ANSIBLE=true %s""" % (doas_exe, doas_flags, play_context. - success_key, doas_exe, doas_flags, default_cmd)) + assert (cmd == """%s %s %s -c 'echo %s; %s'""" % (doas_exe, doas_flags, default_exe, play_context.success_key, default_cmd)) play_context.become_method = 'ksu' cmd = play_context.make_become_cmd(cmd=default_cmd, executable="/bin/bash") |