|
|
|
@ -39,6 +39,11 @@ class Connection(ConnectionBase):
|
|
|
|
|
transport = 'local'
|
|
|
|
|
has_pipelining = True
|
|
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
|
|
|
|
|
|
super(Connection, self).__init__(*args, **kwargs)
|
|
|
|
|
self.cwd = None
|
|
|
|
|
|
|
|
|
|
def _connect(self):
|
|
|
|
|
''' connect to the local host; nothing to do here '''
|
|
|
|
|
|
|
|
|
@ -76,7 +81,8 @@ class Connection(ConnectionBase):
|
|
|
|
|
p = subprocess.Popen(
|
|
|
|
|
cmd,
|
|
|
|
|
shell=isinstance(cmd, (text_type, binary_type)),
|
|
|
|
|
executable=executable, # cwd=...
|
|
|
|
|
executable=executable,
|
|
|
|
|
cwd=self.cwd,
|
|
|
|
|
stdin=subprocess.PIPE,
|
|
|
|
|
stdout=subprocess.PIPE,
|
|
|
|
|
stderr=subprocess.PIPE,
|
|
|
|
@ -123,11 +129,19 @@ class Connection(ConnectionBase):
|
|
|
|
|
display.debug("done with local.exec_command()")
|
|
|
|
|
return (p.returncode, stdout, stderr)
|
|
|
|
|
|
|
|
|
|
def _ensure_abs(self, path):
|
|
|
|
|
if not os.path.isabs(path) and self.cwd is not None:
|
|
|
|
|
path = os.path.normpath(os.path.join(self.cwd, path))
|
|
|
|
|
return path
|
|
|
|
|
|
|
|
|
|
def put_file(self, in_path, out_path):
|
|
|
|
|
''' transfer a file from local to local '''
|
|
|
|
|
|
|
|
|
|
super(Connection, self).put_file(in_path, out_path)
|
|
|
|
|
|
|
|
|
|
in_path = self._ensure_abs(in_path)
|
|
|
|
|
out_path = self._ensure_abs(out_path)
|
|
|
|
|
|
|
|
|
|
display.vvv(u"PUT {0} TO {1}".format(in_path, out_path), host=self._play_context.remote_addr)
|
|
|
|
|
if not os.path.exists(to_bytes(in_path, errors='surrogate_or_strict')):
|
|
|
|
|
raise AnsibleFileNotFound("file or module does not exist: {0}".format(to_native(in_path)))
|
|
|
|
|