|
|
@ -24,6 +24,8 @@ import subprocess
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import ansible.constants as C
|
|
|
|
|
|
|
|
|
|
|
|
from ansible import errors
|
|
|
|
from ansible import errors
|
|
|
|
from ansible.plugins.connections import ConnectionBase
|
|
|
|
from ansible.plugins.connections import ConnectionBase
|
|
|
|
|
|
|
|
|
|
|
@ -88,25 +90,16 @@ class Connection(ConnectionBase):
|
|
|
|
|
|
|
|
|
|
|
|
return self
|
|
|
|
return self
|
|
|
|
|
|
|
|
|
|
|
|
def exec_command(self, cmd, tmp_path, sudo_user=None, sudoable=False,
|
|
|
|
def exec_command(self, cmd, tmp_path, in_data=None, sudoable=False):
|
|
|
|
executable='/bin/sh', in_data=None, su=None,
|
|
|
|
|
|
|
|
su_user=None):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
""" Run a command on the local host """
|
|
|
|
""" Run a command on the local host """
|
|
|
|
|
|
|
|
super(Connection, self).exec_command(cmd, tmp_path, in_data=in_data, sudoable=sudoable)
|
|
|
|
|
|
|
|
|
|
|
|
# Don't currently support su
|
|
|
|
# Don't currently support su
|
|
|
|
if su or su_user:
|
|
|
|
|
|
|
|
raise errors.AnsibleError("Internal Error: this module does not "
|
|
|
|
|
|
|
|
"support running commands via su")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if in_data:
|
|
|
|
if in_data:
|
|
|
|
raise errors.AnsibleError("Internal Error: this module does not "
|
|
|
|
raise errors.AnsibleError("Internal Error: this module does not "
|
|
|
|
"support optimized module pipelining")
|
|
|
|
"support optimized module pipelining")
|
|
|
|
|
|
|
|
|
|
|
|
if sudoable and sudo_user:
|
|
|
|
executable = C.DEFAULT_EXECUTABLE.split()[0] if C.DEFAULT_EXECUTABLE else None
|
|
|
|
raise errors.AnsibleError("Internal Error: this module does not "
|
|
|
|
|
|
|
|
"support running commands via sudo")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if executable:
|
|
|
|
if executable:
|
|
|
|
local_cmd = [self.docker_cmd, "exec", self._play_context.remote_addr, executable,
|
|
|
|
local_cmd = [self.docker_cmd, "exec", self._play_context.remote_addr, executable,
|
|
|
|
'-c', cmd]
|
|
|
|
'-c', cmd]
|
|
|
|