2014-11-14 22:14:08 +00:00
|
|
|
# (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
|
|
|
|
#
|
|
|
|
# This file is part of Ansible
|
|
|
|
#
|
|
|
|
# Ansible is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Ansible is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
2015-04-13 20:28:01 +00:00
|
|
|
from __future__ import (absolute_import, division, print_function)
|
|
|
|
__metaclass__ = type
|
2014-11-14 22:14:08 +00:00
|
|
|
|
|
|
|
from ansible.plugins.action import ActionBase
|
2015-12-23 03:45:25 +00:00
|
|
|
from ansible.utils.vars import merge_hash
|
2014-11-14 22:14:08 +00:00
|
|
|
|
2015-10-22 23:07:26 +00:00
|
|
|
|
2014-11-14 22:14:08 +00:00
|
|
|
class ActionModule(ActionBase):
|
|
|
|
|
2015-10-22 23:07:26 +00:00
|
|
|
def run(self, tmp=None, task_vars=None):
|
2016-12-14 17:52:18 +00:00
|
|
|
|
|
|
|
# individual modules might disagree but as the generic the action plugin, pass at this point.
|
|
|
|
self._supports_check_mode = True
|
2017-06-02 11:14:11 +00:00
|
|
|
self._supports_async = True
|
2014-11-14 22:14:08 +00:00
|
|
|
|
2018-01-16 05:15:04 +00:00
|
|
|
result = super(ActionModule, self).run(tmp, task_vars)
|
2018-02-07 23:11:36 +00:00
|
|
|
del tmp # tmp no longer has any effect
|
2018-01-18 23:51:42 +00:00
|
|
|
|
2018-01-16 05:15:04 +00:00
|
|
|
if not result.get('skipped'):
|
2016-12-14 17:52:18 +00:00
|
|
|
|
2018-01-16 05:15:04 +00:00
|
|
|
if result.get('invocation', {}).get('module_args'):
|
2016-12-14 17:52:18 +00:00
|
|
|
# avoid passing to modules in case of no_log
|
|
|
|
# should not be set anymore but here for backwards compatibility
|
2018-01-16 05:15:04 +00:00
|
|
|
del result['invocation']['module_args']
|
2016-12-14 17:52:18 +00:00
|
|
|
|
2017-02-17 08:09:56 +00:00
|
|
|
# FUTURE: better to let _execute_module calculate this internally?
|
2017-11-22 20:35:58 +00:00
|
|
|
wrap_async = self._task.async_val and not self._connection.has_native_async
|
2017-02-17 08:09:56 +00:00
|
|
|
|
2016-12-14 17:52:18 +00:00
|
|
|
# do work!
|
2018-02-07 23:11:36 +00:00
|
|
|
result = merge_hash(result, self._execute_module(task_vars=task_vars, wrap_async=wrap_async))
|
2016-12-14 17:52:18 +00:00
|
|
|
|
2018-01-16 05:15:04 +00:00
|
|
|
# hack to keep --verbose from showing all the setup module result
|
|
|
|
# moved from setup module as now we filter out all _ansible_ from result
|
2016-12-14 17:52:18 +00:00
|
|
|
if self._task.action == 'setup':
|
2018-01-16 05:15:04 +00:00
|
|
|
result['_ansible_verbose_override'] = True
|
2014-11-14 22:14:08 +00:00
|
|
|
|
2018-01-16 05:15:04 +00:00
|
|
|
if not wrap_async:
|
|
|
|
# remove a temporary path we created
|
2018-02-15 17:01:02 +00:00
|
|
|
self._remove_tmp_path(self._connection._shell.tmpdir)
|
2018-01-16 05:15:04 +00:00
|
|
|
|
|
|
|
return result
|