mirror of
https://github.com/ansible/ansible.git
synced 2026-08-03 08:03:05 +02:00
deprecate esoteric/undocumented playbook syntaxes (#85378)
Co-authored-by: Matt Clay <matt@mystile.com>
(cherry picked from commit 547c64f326)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from ansible.plugins.action import ActionBase
|
||||
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
return dict(action_args=self._task.args)
|
||||
@@ -0,0 +1,4 @@
|
||||
shippable/posix/group3
|
||||
context/controller
|
||||
gather_facts/no
|
||||
env/set/ANSIBLE_DEPRECATION_WARNINGS/yes
|
||||
@@ -0,0 +1,39 @@
|
||||
# Validates some deprecated (previously untested/undocumented) playbook syntax until support is removed.
|
||||
|
||||
- name: action-as-dict (static-only, template-to-dict never worked anyway)
|
||||
action:
|
||||
module: "{{ 'echo' }}"
|
||||
args: "{{ echo_args }}" # note that `module` and `args` are children of `action`
|
||||
vars:
|
||||
echo_args:
|
||||
a: 1
|
||||
register: action_as_dict
|
||||
|
||||
- assert:
|
||||
that: action_as_dict.action_args == action_args
|
||||
vars:
|
||||
action_args:
|
||||
a: 1
|
||||
|
||||
- name: kv and task args at the same time
|
||||
echo: kv1=kv
|
||||
args:
|
||||
kv1: task_arg
|
||||
kv2: task_arg
|
||||
register: kv_and_task_args
|
||||
|
||||
- assert:
|
||||
that: kv_and_task_args.action_args == action_args
|
||||
vars:
|
||||
action_args:
|
||||
kv1: kv
|
||||
kv2: task_arg
|
||||
|
||||
- name: task args with no value
|
||||
echo:
|
||||
args:
|
||||
register: args_were_none
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- args_were_none.action_args == {}
|
||||
@@ -62,7 +62,7 @@ def test_play_ds_positive():
|
||||
adhoc_cli.parse()
|
||||
ret = adhoc_cli._play_ds('command', 10, 2)
|
||||
assert ret['name'] == 'Ansible Ad-Hoc'
|
||||
assert ret['tasks'] == [{'action': {'module': 'command', 'args': {}}, 'async_val': 10, 'poll': 2, 'timeout': 0}]
|
||||
assert ret['tasks'] == [{'action': 'command', 'args': {}, 'async_val': 10, 'poll': 2, 'timeout': 0}]
|
||||
|
||||
|
||||
def test_play_ds_with_include_role():
|
||||
|
||||
Reference in New Issue
Block a user