Debian Codegraph @

lib/ansible/plugins/action/shell.py

raw
1 # Copyright: (c) 2017, Ansible Project
2 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
3
4 from __future__ import annotations
5
6 from ansible.errors import AnsibleActionFail
7 from ansible.plugins.action import ActionBase
8
9
10 class ActionModule(ActionBase):
11
12 def run(self, tmp=None, task_vars=None):
13 del tmp # tmp no longer has any effect
14
15 # Shell module is implemented via command with a special arg
16 self._task.args['_uses_shell'] = True
17
18 # Shell shares the same module code as command. Fail if command
19 # specific options are set.
20 if "expand_argument_vars" in self._task.args:
21 raise AnsibleActionFail(f"Unsupported parameters for ({self._task.action}) module: expand_argument_vars")
22
23 command_action = self._shared_loader_obj.action_loader.get('ansible.legacy.command',
24 task=self._task,
25 connection=self._connection,
26 play_context=self._play_context,
27 loader=self._loader,
28 templar=self._templar,
29 shared_loader_obj=self._shared_loader_obj)
30 result = command_action.run(task_vars=task_vars)
31
32 return result