a bunch of updates to connection info and related, to pass down passwords

also now options populate required fields in required order allowing play to override
added capture of debug in action plugins when stdout is not json
This commit is contained in:
Brian Coca
2015-04-06 22:31:55 -04:00
parent bdd838f876
commit d732c94ac2
9 changed files with 72 additions and 35 deletions

View File

@@ -415,7 +415,11 @@ class ActionBase:
# FIXME: in error situations, the stdout may not contain valid data, so we
# should check for bad rc codes better to catch this here
if 'stdout' in res and res['stdout'].strip():
data = json.loads(self._filter_leading_non_json_lines(res['stdout']))
try:
data = json.loads(self._filter_leading_non_json_lines(res['stdout']))
except ValueError:
# not valid json, lets try to capture error
data = {'traceback': res['stdout']}
if 'parsed' in data and data['parsed'] == False:
data['msg'] += res['stderr']
# pre-split stdout into lines, if stdout is in the data and there

View File

@@ -37,6 +37,9 @@ class Connection(ConnectionBase):
def connect(self, port=None):
''' connect to the local host; nothing to do here '''
self._display.vvv("ESTABLISH LOCAL CONNECTION FOR USER: %s" % self._connection_info.remote_user, host=self._connection_info.remote_addr)
return self
def exec_command(self, cmd, tmp_path, executable='/bin/sh', in_data=None):

View File

@@ -57,7 +57,7 @@ class Connection(ConnectionBase):
def connect(self):
''' connect to the remote host '''
self._display.vvv("ESTABLISH CONNECTION FOR USER: %s" % self._connection_info.remote_user, host=self._connection_info.remote_addr)
self._display.vvv("ESTABLISH SSH CONNECTION FOR USER: %s" % self._connection_info.remote_user, host=self._connection_info.remote_addr)
self._common_args = []
extra_args = C.ANSIBLE_SSH_ARGS
@@ -99,7 +99,7 @@ class Connection(ConnectionBase):
self._common_args += ["-o", "KbdInteractiveAuthentication=no",
"-o", "PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey",
"-o", "PasswordAuthentication=no"]
if self._connection_info.remote_user != pwd.getpwuid(os.geteuid())[0]:
if self._connection_info.remote_user is not None and self._connection_info.remote_user != pwd.getpwuid(os.geteuid())[0]:
self._common_args += ["-o", "User="+self._connection_info.remote_user]
# FIXME: figure out where this goes
#self._common_args += ["-o", "ConnectTimeout=%d" % self.runner.timeout]