Debian Codegraph @

lib/ansible/plugins/action/normal.py

raw
1 # (c) 2012, Michael DeHaan <[email protected]>
2 #
3 # This file is part of Ansible
4 #
5 # Ansible is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Ansible is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
17 from __future__ import annotations
18
19 from ansible import constants as C
20 from ansible.plugins.action import ActionBase
21 from ansible.utils.vars import merge_hash
22
23
24 class ActionModule(ActionBase):
25
26 _supports_check_mode = True
27 _supports_async = True
28
29 def run(self, tmp=None, task_vars=None):
30
31 # individual modules might disagree but as the generic the action plugin, pass at this point.
32 result = super(ActionModule, self).run(tmp, task_vars)
33 del tmp # tmp no longer has any effect
34
35 wrap_async = self._task.async_val
36
37 # do work!
38 result = merge_hash(result, self._execute_module(task_vars=task_vars, wrap_async=wrap_async))
39
40 # hack to keep --verbose from showing all the setup module result
41 # moved from setup module as now we filter out all _ansible_ from result
42 if self._task.action in C._ACTION_SETUP:
43 result['_ansible_verbose_override'] = True
44
45 if not wrap_async:
46 # remove a temporary path we created
47 self._remove_tmp_path(self._connection._shell.tmpdir)
48
49 return result