|
|
|
@ -25,8 +25,8 @@ from ansible import utils
|
|
|
|
|
from ansible import errors
|
|
|
|
|
from ansible.runner.return_data import ReturnData
|
|
|
|
|
|
|
|
|
|
class ActionModule(object):
|
|
|
|
|
|
|
|
|
|
class ActionModule(object):
|
|
|
|
|
TRANSFERS_FILES = True
|
|
|
|
|
|
|
|
|
|
def __init__(self, runner):
|
|
|
|
@ -37,7 +37,8 @@ class ActionModule(object):
|
|
|
|
|
|
|
|
|
|
if self.runner.noop_on_check(inject):
|
|
|
|
|
# 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
|
|
|
|
|
# From library/command keep in sync
|
|
|
|
@ -52,13 +53,13 @@ class ActionModule(object):
|
|
|
|
|
removes = v
|
|
|
|
|
module_args = r.sub("", module_args)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if creates:
|
|
|
|
|
# do not run the command if the line contains creates=filename
|
|
|
|
|
# and the filename already exists. This allows idempotence
|
|
|
|
|
# of command executions.
|
|
|
|
|
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)
|
|
|
|
|
if stat and stat.get('exists', False):
|
|
|
|
|
return ReturnData(
|
|
|
|
@ -74,7 +75,8 @@ class ActionModule(object):
|
|
|
|
|
# and the filename does not exist. This allows idempotence
|
|
|
|
|
# of command executions.
|
|
|
|
|
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)
|
|
|
|
|
if stat and not stat.get('exists', False):
|
|
|
|
|
return ReturnData(
|
|
|
|
|