mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Support 'apply' to apply attributes to included tasks - Impl 1 (#39236)
* Support 'apply' to apply attributes to included tasks * Cannot validate args for task_include * Only allow apply on include_ * Re-enable arg validation, but only for include_tasks and import_tasks * s/task/ir/ * Add tests for include_ apply * Include context with AnsibleParserError * Add docs for apply * version_added * Add free-form documentation back * Add example of free-form with apply
This commit is contained in:
parent
961484e00d
commit
da4ff18406
9 changed files with 175 additions and 4 deletions
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
- hosts: testhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- import_tasks:
|
||||
file: import_tasks.yml
|
||||
apply:
|
||||
tags:
|
||||
- foo
|
||||
tags:
|
||||
- always
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- include_tasks_result is defined
|
||||
tags:
|
||||
- always
|
||||
|
||||
- import_role:
|
||||
name: import_role
|
||||
apply:
|
||||
tags:
|
||||
- foo
|
||||
tags:
|
||||
- always
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- include_role_result is defined
|
||||
tags:
|
||||
- always
|
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
- hosts: testhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- include_tasks:
|
||||
file: include_tasks.yml
|
||||
apply:
|
||||
tags:
|
||||
- foo
|
||||
tags:
|
||||
- always
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- include_tasks_result is defined
|
||||
tags:
|
||||
- always
|
||||
|
||||
- include_role:
|
||||
name: include_role
|
||||
apply:
|
||||
tags:
|
||||
- foo
|
||||
tags:
|
||||
- always
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- include_role_result is defined
|
||||
tags:
|
||||
- always
|
|
@ -0,0 +1,2 @@
|
|||
- set_fact:
|
||||
include_tasks_result: true
|
|
@ -0,0 +1,2 @@
|
|||
- set_fact:
|
||||
include_role_result: true
|
|
@ -67,3 +67,13 @@ ANSIBLE_STRATEGY='free' ansible-playbook undefined_var/playbook.yml -i ../../in
|
|||
# Include path inheritance using host var for include file path
|
||||
ANSIBLE_STRATEGY='linear' ansible-playbook include_path_inheritance/playbook.yml -i ../../inventory "$@"
|
||||
ANSIBLE_STRATEGY='free' ansible-playbook include_path_inheritance/playbook.yml -i ../../inventory "$@"
|
||||
|
||||
# include_ + apply (explicit inheritance)
|
||||
ANSIBLE_STRATEGY='linear' ansible-playbook apply/include_apply.yml -i ../../inventory "$@" --tags foo
|
||||
set +e
|
||||
OUT=$(ANSIBLE_STRATEGY='linear' ansible-playbook apply/import_apply.yml -i ../../inventory "$@" --tags foo 2>&1 | grep 'ERROR! Invalid options for import_tasks: apply')
|
||||
set -e
|
||||
if [[ -z "$OUT" ]]; then
|
||||
echo "apply on import_tasks did not cause error"
|
||||
exit 1
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue