mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fixes #6298 and adds a sudo unit test for synchronize
This commit is contained in:
parent
118d24d171
commit
76037168b1
2 changed files with 36 additions and 3 deletions
|
@ -173,6 +173,11 @@ class ActionModule(object):
|
|||
if self.runner.noop_on_check(inject):
|
||||
module_items += " CHECKMODE=True"
|
||||
|
||||
return self.runner._execute_module(conn, tmp, 'synchronize',
|
||||
module_items, inject=inject)
|
||||
# run the module and store the result
|
||||
result = self.runner._execute_module(conn, tmp, 'synchronize', module_items, inject=inject)
|
||||
|
||||
# reset the sudo property
|
||||
self.runner.sudo = self.original_sudo
|
||||
|
||||
return result
|
||||
|
||||
|
|
|
@ -61,7 +61,35 @@ class TestSynchronize(unittest.TestCase):
|
|||
|
||||
assert runner.executed_inject['delegate_to'] == "127.0.0.1", "was not delegated to 127.0.0.1"
|
||||
assert runner.executed_args == "dest=root@el6.lab.net:/tmp/bar src=/tmp/foo", "wrong args used"
|
||||
assert runner.sudo == False, "sudo not set to false"
|
||||
assert runner.sudo == None, "sudo was not reset to None"
|
||||
|
||||
def test_synchronize_action_sudo(self):
|
||||
|
||||
""" verify the synchronize action plugin unsets and then sets sudo """
|
||||
|
||||
runner = FakeRunner()
|
||||
runner.sudo = True
|
||||
runner.remote_user = "root"
|
||||
runner.transport = "ssh"
|
||||
conn = FakeConn()
|
||||
inject = {
|
||||
'inventory_hostname': "el6.lab.net",
|
||||
'inventory_hostname_short': "el6",
|
||||
'ansible_connection': None,
|
||||
'ansible_ssh_user': 'root',
|
||||
'delegate_to': None,
|
||||
'playbook_dir': '.',
|
||||
}
|
||||
|
||||
x = Synchronize(runner)
|
||||
x.setup("synchronize", inject)
|
||||
x.run(conn, "/tmp", "synchronize", "src=/tmp/foo dest=/tmp/bar", inject)
|
||||
|
||||
assert runner.executed_inject['delegate_to'] == "127.0.0.1", "was not delegated to 127.0.0.1"
|
||||
assert runner.executed_args == 'dest=root@el6.lab.net:/tmp/bar src=/tmp/foo rsync_path="sudo rsync"', \
|
||||
"wrong args used: %s" % runner.executed_args
|
||||
assert runner.sudo == True, "sudo was not reset to True"
|
||||
|
||||
|
||||
def test_synchronize_action_local(self):
|
||||
|
||||
|
|
Loading…
Reference in a new issue