Fixing checkmode support and some other things in v2

This commit is contained in:
James Cammarata 2015-01-28 08:55:18 -06:00
commit b6a34518ad
5 changed files with 52 additions and 34 deletions

View file

@ -52,6 +52,8 @@ class ActionBase:
self._module_loader = module_loader
self._shell = self.get_shell()
self._supports_check_mode = True
def get_shell(self):
# FIXME: no more inject, get this from the host variables?
@ -327,6 +329,16 @@ class ActionBase:
if module_args is None:
module_args = self._task.args
# set check mode in the module arguments, if required
if self._connection_info.check_mode and not self._task.always_run:
if not self._supports_check_mode:
raise AnsibleError("check mode is not supported for this operation")
module_args['_ansible_check_mode'] = True
# set no log in the module arguments, if required
if self._connection_info.no_log:
module_args['_ansible_no_log'] = True
debug("in _execute_module (%s, %s)" % (module_name, module_args))
(module_style, shebang, module_data) = self._configure_module(module_name=module_name, module_args=module_args)
@ -339,7 +351,7 @@ class ActionBase:
tmp = self._make_tmp_path()
remote_module_path = self._shell.join_path(tmp, module_name)
# FIXME: async stuff here
# FIXME: async stuff here?
#if (module_style != 'new' or async_jid is not None or not self._connection._has_pipelining or not C.ANSIBLE_SSH_PIPELINING or C.DEFAULT_KEEP_REMOTE_FILES):
if remote_module_path:
self._transfer_data(remote_module_path, module_data)

View file

@ -21,19 +21,6 @@ class ActionModule(ActionBase):
def run(self, tmp=None, task_vars=dict()):
# FIXME: a lot of this should pretty much go away with module
# args being stored within the task being run itself
#if self.runner.noop_on_check(inject):
# if module_name in [ 'shell', 'command' ]:
# return ReturnData(conn=conn, comm_ok=True, result=dict(skipped=True, msg='check mode not supported for %s' % module_name))
# # else let the module parsing code decide, though this will only be allowed for AnsibleModuleCommon using
# # python modules for now
# module_args += " CHECKMODE=True"
#if self.runner.no_log:
# module_args += " NO_LOG=True"
#vv("REMOTE_MODULE %s %s" % (module_name, module_args), host=conn.host)
return self._execute_module(tmp)