Commit 8be8dbc9 by Richard C Isaacson

Formatting cleanup.

parent 087f7c23
...@@ -25,8 +25,8 @@ from ansible import utils ...@@ -25,8 +25,8 @@ from ansible import utils
from ansible import errors from ansible import errors
from ansible.runner.return_data import ReturnData from ansible.runner.return_data import ReturnData
class ActionModule(object):
class ActionModule(object):
TRANSFERS_FILES = True TRANSFERS_FILES = True
def __init__(self, runner): def __init__(self, runner):
...@@ -37,7 +37,8 @@ class ActionModule(object): ...@@ -37,7 +37,8 @@ class ActionModule(object):
if self.runner.noop_on_check(inject): if self.runner.noop_on_check(inject):
# in check mode, always skip this module # in check mode, always skip this module
return ReturnData(conn=conn, comm_ok=True, result=dict(skipped=True, msg='check mode not supported for this module')) return ReturnData(conn=conn, comm_ok=True,
result=dict(skipped=True, msg='check mode not supported for this module'))
# extract ansible reserved parameters # extract ansible reserved parameters
# From library/command keep in sync # From library/command keep in sync
...@@ -52,13 +53,13 @@ class ActionModule(object): ...@@ -52,13 +53,13 @@ class ActionModule(object):
removes = v removes = v
module_args = r.sub("", module_args) module_args = r.sub("", module_args)
if creates: if creates:
# do not run the command if the line contains creates=filename # do not run the command if the line contains creates=filename
# and the filename already exists. This allows idempotence # and the filename already exists. This allows idempotence
# of command executions. # of command executions.
module_args_tmp = "path=%s" % creates module_args_tmp = "path=%s" % creates
module_return = self.runner._execute_module(conn, tmp, 'stat', module_args_tmp, inject=inject, complex_args=complex_args, persist_files=True) module_return = self.runner._execute_module(conn, tmp, 'stat', module_args_tmp, inject=inject,
complex_args=complex_args, persist_files=True)
stat = module_return.result.get('stat', None) stat = module_return.result.get('stat', None)
if stat and stat.get('exists', False): if stat and stat.get('exists', False):
return ReturnData( return ReturnData(
...@@ -74,7 +75,8 @@ class ActionModule(object): ...@@ -74,7 +75,8 @@ class ActionModule(object):
# and the filename does not exist. This allows idempotence # and the filename does not exist. This allows idempotence
# of command executions. # of command executions.
module_args_tmp = "path=%s" % removes module_args_tmp = "path=%s" % removes
module_return = self.runner._execute_module(conn, tmp, 'stat', module_args_tmp, inject=inject, complex_args=complex_args, persist_files=True) module_return = self.runner._execute_module(conn, tmp, 'stat', module_args_tmp, inject=inject,
complex_args=complex_args, persist_files=True)
stat = module_return.result.get('stat', None) stat = module_return.result.get('stat', None)
if stat and not stat.get('exists', False): if stat and not stat.get('exists', False):
return ReturnData( return ReturnData(
...@@ -102,18 +104,18 @@ class ActionModule(object): ...@@ -102,18 +104,18 @@ class ActionModule(object):
source = utils.path_dwim(self.runner.basedir, source) source = utils.path_dwim(self.runner.basedir, source)
# transfer the file to a remote tmp location # transfer the file to a remote tmp location
source = source.replace('\x00','') # why does this happen here? source = source.replace('\x00', '') # why does this happen here?
args = args.replace('\x00','') # why does this happen here? args = args.replace('\x00', '') # why does this happen here?
tmp_src = os.path.join(tmp, os.path.basename(source)) tmp_src = os.path.join(tmp, os.path.basename(source))
tmp_src = tmp_src.replace('\x00', '') tmp_src = tmp_src.replace('\x00', '')
conn.put_file(source, tmp_src) conn.put_file(source, tmp_src)
sudoable=True sudoable = True
# set file permissions, more permisive when the copy is done as a different user # set file permissions, more permisive 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':
cmd_args_chmod = "chmod a+rx %s" % tmp_src cmd_args_chmod = "chmod a+rx %s" % tmp_src
sudoable=False sudoable = False
else: else:
cmd_args_chmod = "chmod +rx %s" % tmp_src cmd_args_chmod = "chmod +rx %s" % tmp_src
self.runner._low_level_exec_command(conn, cmd_args_chmod, tmp, sudoable=sudoable) self.runner._low_level_exec_command(conn, cmd_args_chmod, tmp, sudoable=sudoable)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment