Fixing up some check-mode stuff
This commit is contained in:
parent
ad53b6f36a
commit
cf51d0a790
11 changed files with 26 additions and 68 deletions
|
@ -908,11 +908,11 @@ class AnsibleModule(object):
|
||||||
|
|
||||||
def _check_for_check_mode(self):
|
def _check_for_check_mode(self):
|
||||||
for (k,v) in self.params.iteritems():
|
for (k,v) in self.params.iteritems():
|
||||||
if k == '_ansible_check_mode':
|
if k == '_ansible_check_mode' and v:
|
||||||
if not self.supports_check_mode:
|
if not self.supports_check_mode:
|
||||||
self.exit_json(skipped=True, msg="remote module does not support check mode")
|
self.exit_json(skipped=True, msg="remote module does not support check mode")
|
||||||
if self.supports_check_mode:
|
|
||||||
self.check_mode = True
|
self.check_mode = True
|
||||||
|
break
|
||||||
|
|
||||||
def _check_for_no_log(self):
|
def _check_for_no_log(self):
|
||||||
for (k,v) in self.params.iteritems():
|
for (k,v) in self.params.iteritems():
|
||||||
|
|
|
@ -31,9 +31,8 @@ class ActionModule(ActionBase):
|
||||||
|
|
||||||
def run(self, tmp=None, task_vars=dict()):
|
def run(self, tmp=None, task_vars=dict()):
|
||||||
|
|
||||||
# FIXME: is this necessary in v2?
|
if self._connection_info.check_mode:
|
||||||
#if self.runner.noop_on_check(inject):
|
return 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'))
|
|
||||||
|
|
||||||
# Parse out any hostname:port patterns
|
# Parse out any hostname:port patterns
|
||||||
new_name = self._task.args.get('name', self._task.args.get('hostname', None))
|
new_name = self._task.args.get('name', self._task.args.get('hostname', None))
|
||||||
|
|
|
@ -133,14 +133,8 @@ class ActionModule(ActionBase):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# FIXME: checkmode stuff
|
|
||||||
#if self.runner.noop_on_check(inject):
|
|
||||||
# return ReturnData(conn=conn, comm_ok=True, result=dict(changed=True), diff=dict(before_header=dest, after_header=src, after=resultant))
|
|
||||||
#else:
|
|
||||||
# res = self.runner._execute_module(conn, tmp, 'copy', module_args_tmp, inject=inject)
|
|
||||||
# res.diff = dict(after=resultant)
|
|
||||||
# return res
|
|
||||||
res = self._execute_module(module_name='copy', module_args=new_module_args, task_vars=task_vars, tmp=tmp)
|
res = self._execute_module(module_name='copy', module_args=new_module_args, task_vars=task_vars, tmp=tmp)
|
||||||
|
# FIXME: diff stuff
|
||||||
#res.diff = dict(after=resultant)
|
#res.diff = dict(after=resultant)
|
||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -28,9 +28,8 @@ class ActionModule(ActionBase):
|
||||||
def run(self, tmp=None, task_vars=dict()):
|
def run(self, tmp=None, task_vars=dict()):
|
||||||
''' transfer the given module name, plus the async module, then run it '''
|
''' transfer the given module name, plus the async module, then run it '''
|
||||||
|
|
||||||
# FIXME: noop stuff needs to be sorted ut
|
if self._connection_info.check_mode:
|
||||||
#if self.runner.noop_on_check(inject):
|
return 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'))
|
|
||||||
|
|
||||||
if not tmp:
|
if not tmp:
|
||||||
tmp = self._make_tmp_path()
|
tmp = self._make_tmp_path()
|
||||||
|
|
|
@ -191,13 +191,13 @@ class ActionModule(ActionBase):
|
||||||
# diff = {}
|
# diff = {}
|
||||||
diff = {}
|
diff = {}
|
||||||
|
|
||||||
# FIXME: noop stuff
|
if self._connection_info.check_mode:
|
||||||
#if self.runner.noop_on_check(inject):
|
self._remove_tempfile_if_content_defined(content, content_tempfile)
|
||||||
# self._remove_tempfile_if_content_defined(content, content_tempfile)
|
# FIXME: diff stuff
|
||||||
# diffs.append(diff)
|
#diffs.append(diff)
|
||||||
# changed = True
|
changed = True
|
||||||
# module_result = dict(changed=True)
|
module_return = dict(changed=True)
|
||||||
# continue
|
continue
|
||||||
|
|
||||||
# Define a remote directory that we will copy the file to.
|
# Define a remote directory that we will copy the file to.
|
||||||
tmp_src = tmp + 'source'
|
tmp_src = tmp + 'source'
|
||||||
|
|
|
@ -36,9 +36,8 @@ class ActionModule(ActionBase):
|
||||||
def run(self, tmp=None, task_vars=dict()):
|
def run(self, tmp=None, task_vars=dict()):
|
||||||
''' handler for fetch operations '''
|
''' handler for fetch operations '''
|
||||||
|
|
||||||
# FIXME: is this even required anymore?
|
if self._connection_info.check_mode:
|
||||||
#if self.runner.noop_on_check(inject):
|
return dict(skipped=True, msg='check mode not (yet) supported for this module')
|
||||||
# return ReturnData(conn=conn, comm_ok=True, result=dict(skipped=True, msg='check mode not (yet) supported for this module'))
|
|
||||||
|
|
||||||
source = self._task.args.get('src', None)
|
source = self._task.args.get('src', None)
|
||||||
dest = self._task.args.get('dest', None)
|
dest = self._task.args.get('dest', None)
|
||||||
|
|
|
@ -51,9 +51,7 @@ class ActionModule(ActionBase):
|
||||||
self._connection.put_file(src, tmp_src)
|
self._connection.put_file(src, tmp_src)
|
||||||
|
|
||||||
if self._connection_info.become and self._connection_info.become_user != 'root':
|
if self._connection_info.become and self._connection_info.become_user != 'root':
|
||||||
# FIXME: noop stuff here
|
if not self._connection_info.check_mode:
|
||||||
#if not self.runner.noop_on_check(inject):
|
|
||||||
# self._remote_chmod('a+r', tmp_src, tmp)
|
|
||||||
self._remote_chmod('a+r', tmp_src, tmp)
|
self._remote_chmod('a+r', tmp_src, tmp)
|
||||||
|
|
||||||
new_module_args = self._task.args.copy()
|
new_module_args = self._task.args.copy()
|
||||||
|
|
|
@ -24,10 +24,9 @@ class ActionModule(ActionBase):
|
||||||
|
|
||||||
def run(self, tmp=None, task_vars=dict()):
|
def run(self, tmp=None, task_vars=dict()):
|
||||||
|
|
||||||
# FIXME: need to rework the noop stuff still
|
if self._connection_info.check_mode:
|
||||||
#if self.runner.noop_on_check(inject):
|
# in --check mode, always skip this module execution
|
||||||
# # in --check mode, always skip this module execution
|
return dict(skipped=True)
|
||||||
# return ReturnData(conn=conn, comm_ok=True, result=dict(skipped=True))
|
|
||||||
|
|
||||||
executable = self._task.args.get('executable')
|
executable = self._task.args.get('executable')
|
||||||
result = self._low_level_execute_command(self._task.args.get('_raw_params'), tmp=tmp, executable=executable)
|
result = self._low_level_execute_command(self._task.args.get('_raw_params'), tmp=tmp, executable=executable)
|
||||||
|
|
|
@ -28,11 +28,8 @@ class ActionModule(ActionBase):
|
||||||
def run(self, tmp=None, task_vars=None):
|
def run(self, tmp=None, task_vars=None):
|
||||||
''' handler for file transfer operations '''
|
''' handler for file transfer operations '''
|
||||||
|
|
||||||
# FIXME: noop stuff still needs to be sorted out
|
if self._connection_info.check_mode:
|
||||||
#if self.runner.noop_on_check(inject):
|
return dict(skipped=True, msg='check mode not supported for 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'))
|
|
||||||
|
|
||||||
if not tmp:
|
if not tmp:
|
||||||
tmp = self._make_tmp_path()
|
tmp = self._make_tmp_path()
|
||||||
|
|
|
@ -139,15 +139,6 @@ class ActionModule(ActionBase):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# FIXME: noop stuff needs to be sorted out
|
|
||||||
#if self.runner.noop_on_check(task_vars):
|
|
||||||
# return ReturnData(conn=conn, comm_ok=True, result=dict(changed=True), diff=dict(before_header=dest, after_header=source, before=dest_contents, after=resultant))
|
|
||||||
#else:
|
|
||||||
# res = self.runner._execute_module(conn, tmp, 'copy', module_args_tmp, task_vars=task_vars, complex_args=complex_args)
|
|
||||||
# if res.result.get('changed', False):
|
|
||||||
# res.diff = dict(before=dest_contents, after=resultant)
|
|
||||||
# return res
|
|
||||||
|
|
||||||
result = self._execute_module(module_name='copy', module_args=new_module_args, task_vars=task_vars)
|
result = self._execute_module(module_name='copy', module_args=new_module_args, task_vars=task_vars)
|
||||||
if result.get('changed', False):
|
if result.get('changed', False):
|
||||||
result['diff'] = dict(before=dest_contents, after=resultant)
|
result['diff'] = dict(before=dest_contents, after=resultant)
|
||||||
|
@ -169,12 +160,5 @@ class ActionModule(ActionBase):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# FIXME: this may not be required anymore, as the checkmod params
|
|
||||||
# should be in the regular module args?
|
|
||||||
# be sure to task_vars the check mode param into the module args and
|
|
||||||
# rely on the file module to report its changed status
|
|
||||||
#if self.runner.noop_on_check(task_vars):
|
|
||||||
# new_module_args['CHECKMODE'] = True
|
|
||||||
|
|
||||||
return self._execute_module(module_name='file', module_args=new_module_args, task_vars=task_vars)
|
return self._execute_module(module_name='file', module_args=new_module_args, task_vars=task_vars)
|
||||||
|
|
||||||
|
|
|
@ -78,9 +78,7 @@ class ActionModule(ActionBase):
|
||||||
# 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 copy:
|
if copy:
|
||||||
if self._connection_info.become and self._connection_info.become_user != 'root':
|
if self._connection_info.become and self._connection_info.become_user != 'root':
|
||||||
# FIXME: noop stuff needs to be reworked
|
if not self._connection_info.check_mode:
|
||||||
#if not self.runner.noop_on_check(task_vars):
|
|
||||||
# self.runner._remote_chmod(conn, 'a+r', tmp_src, tmp)
|
|
||||||
self._remote_chmod(tmp, 'a+r', tmp_src)
|
self._remote_chmod(tmp, 'a+r', tmp_src)
|
||||||
|
|
||||||
# Build temporary module_args.
|
# Build temporary module_args.
|
||||||
|
@ -92,11 +90,6 @@ class ActionModule(ActionBase):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# make sure checkmod is passed on correctly
|
|
||||||
# FIXME: noop again, probably doesn't need to be done here anymore?
|
|
||||||
#if self.runner.noop_on_check(task_vars):
|
|
||||||
# new_module_args['CHECKMODE'] = True
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
new_module_args = self._task.args.copy()
|
new_module_args = self._task.args.copy()
|
||||||
new_module_args.update(
|
new_module_args.update(
|
||||||
|
@ -104,10 +97,6 @@ class ActionModule(ActionBase):
|
||||||
original_basename=os.path.basename(source),
|
original_basename=os.path.basename(source),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
# make sure checkmod is passed on correctly
|
|
||||||
# FIXME: noop again, probably doesn't need to be done here anymore?
|
|
||||||
#if self.runner.noop_on_check(task_vars):
|
|
||||||
# module_args += " CHECKMODE=True"
|
|
||||||
|
|
||||||
# execute the unarchive module now, with the updated args
|
# execute the unarchive module now, with the updated args
|
||||||
return self._execute_module(module_args=new_module_args, task_vars=task_vars)
|
return self._execute_module(module_args=new_module_args, task_vars=task_vars)
|
||||||
|
|
Loading…
Reference in a new issue