mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 04:11:25 -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
|
@ -23,10 +23,20 @@ description:
|
|||
- Includes a file with a list of tasks to be executed in the current playbook.
|
||||
version_added: "2.4"
|
||||
options:
|
||||
free-form:
|
||||
file:
|
||||
description:
|
||||
- The name of the imported file is specified directly without any other option.
|
||||
- Unlike M(import_tasks), most keywords, including loops and conditionals, apply to this statement.
|
||||
version_added: '2.7'
|
||||
apply:
|
||||
description:
|
||||
- Accepts a hash of task keywords (e.g. C(tags), C(become)) that will be applied to the tasks within the include.
|
||||
version_added: '2.7'
|
||||
free-form:
|
||||
description:
|
||||
- |
|
||||
Supplying a file name via free-form C(- include_tasks: file.yml) of a file to be included is the equivalent
|
||||
of specifying an argument of I(file).
|
||||
notes:
|
||||
- This is a core feature of the Ansible, rather than a module, and cannot be overridden like a module.
|
||||
'''
|
||||
|
@ -51,6 +61,24 @@ EXAMPLES = """
|
|||
- name: Include task list in play only if the condition is true
|
||||
include_tasks: "{{ hostvar }}.yaml"
|
||||
when: hostvar is defined
|
||||
|
||||
- name: Apply tags to tasks within included file
|
||||
include_tasks:
|
||||
file: install.yml
|
||||
apply:
|
||||
tags:
|
||||
- install
|
||||
tags:
|
||||
- always
|
||||
|
||||
- name: Apply tags to tasks within included file when using free-form
|
||||
include_tasks: install.yml
|
||||
args:
|
||||
apply:
|
||||
tags:
|
||||
- install
|
||||
tags:
|
||||
- always
|
||||
"""
|
||||
|
||||
RETURN = """
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue