|
|
|
@ -70,6 +70,7 @@ def _executor_hook(job_queue, result_queue):
|
|
|
|
|
################################################
|
|
|
|
|
|
|
|
|
|
class ReturnData(object):
|
|
|
|
|
''' internal return class for execute methods, not part of API signature '''
|
|
|
|
|
|
|
|
|
|
__slots__ = [ 'result', 'comm_ok', 'host' ]
|
|
|
|
|
|
|
|
|
@ -100,6 +101,7 @@ class ReturnData(object):
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
class Runner(object):
|
|
|
|
|
''' core API interface to ansible '''
|
|
|
|
|
|
|
|
|
|
def __init__(self,
|
|
|
|
|
host_list=C.DEFAULT_HOST_LIST, module_path=C.DEFAULT_MODULE_PATH,
|
|
|
|
@ -182,15 +184,14 @@ class Runner(object):
|
|
|
|
|
self.sudo_pass = sudo_pass
|
|
|
|
|
self.is_playbook = is_playbook
|
|
|
|
|
|
|
|
|
|
euid = pwd.getpwuid(os.geteuid())[0]
|
|
|
|
|
if self.transport == 'local' and self.remote_user != euid:
|
|
|
|
|
raise errors.AnsibleError("User mismatch: expected %s, but is %s" % (self.remote_user, euid))
|
|
|
|
|
if self.transport == 'local':
|
|
|
|
|
self.remote_user = pwd.getpwuid(os.geteuid())[0]
|
|
|
|
|
|
|
|
|
|
if type(self.module_args) not in [str, unicode, dict]:
|
|
|
|
|
raise errors.AnsibleError("module_args must be a string or dict: %s" % self.module_args)
|
|
|
|
|
if self.transport == 'ssh' and self.remote_pass:
|
|
|
|
|
raise errors.AnsibleError("SSH transport does not support remote passwords, only keys or agents")
|
|
|
|
|
raise errors.AnsibleError("SSH transport does not support passwords, only keys or agents")
|
|
|
|
|
|
|
|
|
|
self._tmp_paths = {}
|
|
|
|
|
random.seed()
|
|
|
|
|
|
|
|
|
|
# *****************************************************
|
|
|
|
@ -638,6 +639,8 @@ class Runner(object):
|
|
|
|
|
self.callbacks.on_unreachable(host, msg)
|
|
|
|
|
return ReturnData(host=host, comm_ok=False, result=dict(failed=True, msg=msg))
|
|
|
|
|
|
|
|
|
|
# *****************************************************
|
|
|
|
|
|
|
|
|
|
def _executor_internal(self, host):
|
|
|
|
|
''' callback executed in parallel for each host. returns (hostname, connected_ok, extra) '''
|
|
|
|
|
|
|
|
|
@ -860,6 +863,8 @@ class Runner(object):
|
|
|
|
|
results = [ self._executor(h[1]) for h in hosts ]
|
|
|
|
|
return self._partition_results(results)
|
|
|
|
|
|
|
|
|
|
# *****************************************************
|
|
|
|
|
|
|
|
|
|
def run_async(self, time_limit):
|
|
|
|
|
''' Run this module asynchronously and return a poller. '''
|
|
|
|
|
self.background = time_limit
|
|
|
|
|