mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
dzdo prompt fix
fixed tests dzdo has 2 paths now, with and w/o password fixes #17838
This commit is contained in:
parent
6008fbd5cf
commit
dfff608ceb
2 changed files with 11 additions and 2 deletions
|
@ -562,7 +562,10 @@ class PlayContext(Base):
|
||||||
elif self.become_method == 'dzdo':
|
elif self.become_method == 'dzdo':
|
||||||
|
|
||||||
exe = self.become_exe or 'dzdo'
|
exe = self.become_exe or 'dzdo'
|
||||||
|
if self.become_pass:
|
||||||
|
prompt = '[dzdo via ansible, key=%s] password: ' % randbits
|
||||||
|
becomecmd = '%s -p %s -u %s %s' % (exe, pipes.quote(prompt), self.become_user, command)
|
||||||
|
else:
|
||||||
becomecmd = '%s -u %s %s' % (exe, self.become_user, command)
|
becomecmd = '%s -u %s %s' % (exe, self.become_user, command)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -20,6 +20,7 @@ from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import pipes
|
||||||
|
|
||||||
from ansible.compat.tests import unittest
|
from ansible.compat.tests import unittest
|
||||||
from ansible.compat.tests.mock import patch, MagicMock
|
from ansible.compat.tests.mock import patch, MagicMock
|
||||||
|
@ -177,6 +178,11 @@ class TestPlayContext(unittest.TestCase):
|
||||||
cmd = play_context.make_become_cmd(cmd=default_cmd, executable="/bin/bash")
|
cmd = play_context.make_become_cmd(cmd=default_cmd, executable="/bin/bash")
|
||||||
self.assertEqual(cmd, """%s -u %s %s -c 'echo %s; %s'""" % (dzdo_exe, play_context.become_user, default_exe, play_context.success_key, default_cmd))
|
self.assertEqual(cmd, """%s -u %s %s -c 'echo %s; %s'""" % (dzdo_exe, play_context.become_user, default_exe, play_context.success_key, default_cmd))
|
||||||
|
|
||||||
|
play_context.become_pass = 'testpass'
|
||||||
|
play_context.become_method = 'dzdo'
|
||||||
|
cmd = play_context.make_become_cmd(cmd=default_cmd, executable="/bin/bash")
|
||||||
|
self.assertEqual(cmd, """%s -p %s -u %s %s -c 'echo %s; %s'""" % (dzdo_exe, pipes.quote(play_context.prompt), play_context.become_user, default_exe, play_context.success_key, default_cmd))
|
||||||
|
|
||||||
class TestTaskAndVariableOverrride(unittest.TestCase):
|
class TestTaskAndVariableOverrride(unittest.TestCase):
|
||||||
|
|
||||||
inventory_vars = (
|
inventory_vars = (
|
||||||
|
|
Loading…
Reference in a new issue