Debian Codegraph @

lib/ansible/plugins/action/raw.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.plugins.action import ActionBase
20
21
22 class ActionModule(ActionBase):
23 TRANSFERS_FILES = False
24
25 def run(self, tmp=None, task_vars=None):
26 if task_vars is None:
27 task_vars = dict()
28
29 if self._task.environment and any(self._task.environment):
30 self._display.warning('raw module does not support the environment keyword')
31
32 result = super(ActionModule, self).run(tmp, task_vars)
33 del tmp # tmp no longer has any effect
34
35 if self._task.check_mode:
36 # in --check mode, always indicate raw didn't run
37 result['skipped'] = True # deprecated: description='returning skipped from actions/modules' core_version='2.25'
38 result['changed'] = False
39 result['msg'] = "Task `raw` did not execute due to check_mode"
40 return result
41
42 executable = self._task.args.get('executable', False)
43 result.update(self._low_level_execute_command(self._task.args.get('_raw_params'), executable=executable))
44
45 result['changed'] = True
46
47 if 'rc' in result and result['rc'] != 0:
48 result['failed'] = True
49 result['msg'] = 'non-zero return code'
50
51 return result