mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 22:51:23 -07:00
Fixes from 'make pep8'. Partial, more to come.
This commit is contained in:
parent
23a0a8daf9
commit
9cf66f4376
4 changed files with 36 additions and 33 deletions
|
@ -200,7 +200,7 @@ class Play(object):
|
||||||
salt = var.get("salt", None)
|
salt = var.get("salt", None)
|
||||||
|
|
||||||
if vname not in self.playbook.extra_vars:
|
if vname not in self.playbook.extra_vars:
|
||||||
vars[vname] = self.playbook.callbacks.on_vars_prompt (
|
vars[vname] = self.playbook.callbacks.on_vars_prompt(
|
||||||
vname, private, prompt, encrypt, confirm, salt_size, salt, default
|
vname, private, prompt, encrypt, confirm, salt_size, salt, default
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,6 @@ multiprocessing_runner = None
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
|
||||||
|
|
||||||
def _executor_hook(job_queue, result_queue):
|
def _executor_hook(job_queue, result_queue):
|
||||||
|
|
||||||
# attempt workaround of https://github.com/newsapps/beeswithmachineguns/issues/17
|
# attempt workaround of https://github.com/newsapps/beeswithmachineguns/issues/17
|
||||||
|
@ -531,9 +530,9 @@ class Runner(object):
|
||||||
err = stderr
|
err = stderr
|
||||||
|
|
||||||
if rc is not None:
|
if rc is not None:
|
||||||
return dict(rc=rc, stdout=out, stderr=err )
|
return dict(rc=rc, stdout=out, stderr=err)
|
||||||
else:
|
else:
|
||||||
return dict(stdout=out, stderr=err )
|
return dict(stdout=out, stderr=err)
|
||||||
|
|
||||||
# *****************************************************
|
# *****************************************************
|
||||||
|
|
||||||
|
|
|
@ -79,39 +79,39 @@ class ActionModule(object):
|
||||||
|
|
||||||
if local_md5 != remote_md5:
|
if local_md5 != remote_md5:
|
||||||
|
|
||||||
# template is different from the remote value
|
# template is different from the remote value
|
||||||
|
|
||||||
# if showing diffs, we need to get the remote value
|
# if showing diffs, we need to get the remote value
|
||||||
dest_contents = None
|
dest_contents = None
|
||||||
|
|
||||||
if self.runner.diff:
|
if self.runner.diff:
|
||||||
# using persist_files to keep the temp directory around to avoid needing to grab another
|
# using persist_files to keep the temp directory around to avoid needing to grab another
|
||||||
dest_result = self.runner._execute_module(conn, tmp, 'slurp', "path=%s" % dest, inject=inject, persist_files=True)
|
dest_result = self.runner._execute_module(conn, tmp, 'slurp', "path=%s" % dest, inject=inject, persist_files=True)
|
||||||
if 'content' in dest_result.result:
|
if 'content' in dest_result.result:
|
||||||
dest_contents = dest_result.result['content']
|
dest_contents = dest_result.result['content']
|
||||||
if dest_result.result['encoding'] == 'base64':
|
if dest_result.result['encoding'] == 'base64':
|
||||||
dest_contents = base64.b64decode(dest_contents)
|
dest_contents = base64.b64decode(dest_contents)
|
||||||
else:
|
else:
|
||||||
raise Exception("unknown encoding, failed: %s" % dest_result.result)
|
raise Exception("unknown encoding, failed: %s" % dest_result.result)
|
||||||
else:
|
else:
|
||||||
dest_result = ''
|
dest_result = ''
|
||||||
|
|
||||||
xfered = self.runner._transfer_str(conn, tmp, 'source', resultant)
|
xfered = self.runner._transfer_str(conn, tmp, 'source', resultant)
|
||||||
|
|
||||||
# fix file permissions when the copy is done as a different user
|
# fix file permissions when the copy is done as a different user
|
||||||
if self.runner.sudo and self.runner.sudo_user != 'root':
|
if self.runner.sudo and self.runner.sudo_user != 'root':
|
||||||
self.runner._low_level_exec_command(conn, "chmod a+r %s" % xfered, tmp)
|
self.runner._low_level_exec_command(conn, "chmod a+r %s" % xfered, tmp)
|
||||||
|
|
||||||
# run the copy module
|
# run the copy module
|
||||||
module_args = "%s src=%s dest=%s" % (module_args, xfered, dest)
|
module_args = "%s src=%s dest=%s" % (module_args, xfered, dest)
|
||||||
|
|
||||||
if self.runner.check:
|
if self.runner.check:
|
||||||
return ReturnData(conn=conn, comm_ok=True, result=dict(changed=True), before_diff_value=dest_contents, after_diff_value=resultant)
|
return ReturnData(conn=conn, comm_ok=True, result=dict(changed=True), before_diff_value=dest_contents, after_diff_value=resultant)
|
||||||
else:
|
else:
|
||||||
res = self.runner._execute_module(conn, tmp, 'copy', module_args, inject=inject)
|
res = self.runner._execute_module(conn, tmp, 'copy', module_args, inject=inject)
|
||||||
res.before_diff_value = dest_contents
|
res.before_diff_value = dest_contents
|
||||||
res.after_diff_value = resultant
|
res.after_diff_value = resultant
|
||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
return ReturnData(conn=conn, comm_ok=True, result=dict(changed=False))
|
return ReturnData(conn=conn, comm_ok=True, result=dict(changed=False))
|
||||||
|
|
||||||
|
|
|
@ -162,7 +162,7 @@ def _varFind(basedir, text, vars, lookup_fatal, depth, expand_lists):
|
||||||
if basedir is None:
|
if basedir is None:
|
||||||
return {'replacement': None, 'start': start, 'end': end}
|
return {'replacement': None, 'start': start, 'end': end}
|
||||||
var_end -= 1
|
var_end -= 1
|
||||||
from ansible import utils
|
from ansible import utils
|
||||||
args = text[part_start:var_end]
|
args = text[part_start:var_end]
|
||||||
if lookup_plugin_name == 'LOOKUP':
|
if lookup_plugin_name == 'LOOKUP':
|
||||||
lookup_plugin_name, args = args.split(",", 1)
|
lookup_plugin_name, args = args.split(",", 1)
|
||||||
|
@ -259,11 +259,13 @@ class _jinja2_vars(object):
|
||||||
here.
|
here.
|
||||||
extras is a list of locals to also search for variables.
|
extras is a list of locals to also search for variables.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, basedir, vars, globals, *extras):
|
def __init__(self, basedir, vars, globals, *extras):
|
||||||
self.basedir = basedir
|
self.basedir = basedir
|
||||||
self.vars = vars
|
self.vars = vars
|
||||||
self.globals = globals
|
self.globals = globals
|
||||||
self.extras = extras
|
self.extras = extras
|
||||||
|
|
||||||
def __contains__(self, k):
|
def __contains__(self, k):
|
||||||
if k in self.vars:
|
if k in self.vars:
|
||||||
return True
|
return True
|
||||||
|
@ -273,6 +275,7 @@ class _jinja2_vars(object):
|
||||||
if k in self.globals:
|
if k in self.globals:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def __getitem__(self, varname):
|
def __getitem__(self, varname):
|
||||||
if varname not in self.vars:
|
if varname not in self.vars:
|
||||||
for i in self.extras:
|
for i in self.extras:
|
||||||
|
@ -288,6 +291,7 @@ class _jinja2_vars(object):
|
||||||
return var
|
return var
|
||||||
else:
|
else:
|
||||||
return template(self.basedir, var, self.vars)
|
return template(self.basedir, var, self.vars)
|
||||||
|
|
||||||
def add_locals(self, locals):
|
def add_locals(self, locals):
|
||||||
'''
|
'''
|
||||||
If locals are provided, create a copy of self containing those
|
If locals are provided, create a copy of self containing those
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue