1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Unifying wording and formatting of all include and import modules (#31938)

* Unifying wording and formatting of all include and import modules

* Changes based on comments from dharmabumstead

* Removed instances of the term ‘Ansible Engine’

* Removed instances of term ‘Ansible Engine’

* Updated term

* Updated wording

* Updated wording

* Removed the term ‘Ansible Engine’
This commit is contained in:
Jiri Tyr 2017-11-22 22:05:29 +00:00 committed by scottb
parent 496ce388ab
commit 283fee90a7
7 changed files with 169 additions and 154 deletions

View file

@ -7,71 +7,74 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {
'status': ['deprecated'], 'metadata_version': '1.1',
'supported_by': 'core'} 'status': ['deprecated'],
'supported_by': 'core'
}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
author: author: Ansible Core Team (@ansible)
- "Ansible Core Team (@ansible)"
module: include module: include
short_description: include a play or task list. short_description: Include a play or task list
deprecated: deprecated:
The include action was too confusing, dealing with both plays and tasks, being both dynamic and static. This module will be removed in version 2.8. The include action was too confusing, dealing with both plays and tasks, being both dynamic and static. This module
As alternatives use include_tasks, import_playbook, import_tasks. will be removed in version 2.8. As alternatives use M(include_tasks), M(import_playbook), M(import_tasks).
description: description:
- Includes a file with a list of plays or tasks to be executed in the current playbook. - Includes a file with a list of plays or tasks to be executed in the current playbook.
- Files with a list of plays can only be included at the top level, lists of tasks can only be included where tasks normally run (in play). - Files with a list of plays can only be included at the top level. Lists of tasks can only be included where tasks
- Before 2.0 all includes were 'static', executed at play compile time. normally run (in play).
- Static includes are not subject to most directives, for example, loops or conditionals, they are applied instead to each inherited task. - Before Ansible version 2.0, all includes were 'static' and were executed when the play was compiled.
- Since 2.0 task includes are dynamic and behave more like real tasks. This means they can be looped, skipped and use variables from any source. - Static includes are not subject to most directives. For example, loops or conditionals are applied instead to each
Ansible tries to auto detect this, use the `static` directive (new in 2.1) to bypass autodetection. inherited task.
- This module is also supported for Windows targets. - Since Ansible 2.0, task includes are dynamic and behave more like real tasks. This means they can be looped,
skipped and use variables from any source. Ansible tries to auto detect this, but you can use the `static`
directive (which was added in Ansible 2.1) to bypass autodetection.
- This module is also supported for Windows targets.
version_added: "0.6" version_added: "0.6"
options: options:
free-form: free-form:
description: description:
- This module allows you to specify the name of the file directly w/o any other options. - This module allows you to specify the name of the file directly without any other options.
notes: notes:
- This is really not a module, though it appears as such, this is a feature of the Ansible Engine, as such it cannot be overridden the same way a - This is a core feature of Ansible, rather than a module, and cannot be overridden like a module.
module can. - This module is also supported for Windows targets.
- This module is also supported for Windows targets.
''' '''
EXAMPLES = """ EXAMPLES = """
# include a play after another play
- hosts: localhost - hosts: localhost
tasks: tasks:
- debug: - debug:
msg: "play1" msg: play1
- include: otherplays.yml - name: Include a play after another play
include: otherplays.yaml
# include task list in play
- hosts: all - hosts: all
tasks: tasks:
- debug: - debug:
msg: task1 msg: task1
- include: stuff.yml - name: Include task list in play
include: stuff.yaml
- debug: - debug:
msg: task10 msg: task10
# dyanmic include task list in play
- hosts: all - hosts: all
tasks: tasks:
- debug: - debug:
msg: task1 msg: task1
- include: "{{ hostvar }}.yml" - name: Include task list in play only if the condition is true
include: "{{ hostvar }}.yaml"
static: no static: no
when: hostvar is defined when: hostvar is defined
""" """
RETURN = """ RETURN = """
# this module does not return anything except plays or tasks to execute # This module does not return anything except plays or tasks to execute.
""" """

View file

@ -7,37 +7,38 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {
'status': ['preview'], 'metadata_version': '1.1',
'supported_by': 'core'} 'status': ['preview'],
'supported_by': 'core'
}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
author: author: Ansible Core Team (@ansible)
- "Ansible Core Team (@ansible)"
module: import_playbook module: import_playbook
short_description: import a playbook. short_description: Import a playbook
description: description:
- Includes a file with a list of plays to be executed. - Includes a file with a list of plays to be executed.
- Files with a list of plays can only be included at the top level, you cannot use this action inside a Play. - Files with a list of plays can only be included at the top level. You cannot use this action inside a play.
version_added: "2.4" version_added: "2.4"
options: options:
free-form: free-form:
description: description:
- This action allows you to specify the name of the file directly w/o any other options. - The name of the imported playbook is specified directly without any other option.
notes: notes:
- This is really not a module, this is a feature of the Ansible Engine, as such it cannot be overridden the same way a module can. - This is a core feature of Ansible, rather than a module, and cannot be overridden like a module.
''' '''
EXAMPLES = """ EXAMPLES = """
- name: include a play after another play - hosts: localhost
hosts: localhost
tasks: tasks:
- debug: - debug:
msg: "play1" msg: play1
- import_playbook: otherplays.yml - name: Include a play after another play
import_playbook: otherplays.yaml
- name: This DOES NOT WORK - name: This DOES NOT WORK
@ -46,10 +47,10 @@ EXAMPLES = """
- debug: - debug:
msg: task1 msg: task1
- name: This failes because I'm inside a play already - name: This fails because I'm inside a play already
import_playbook: stuff.yml import_playbook: stuff.yaml
""" """
RETURN = """ RETURN = """
# this module does not return anything except plays to execute # This module does not return anything except plays to execute.
""" """

View file

@ -7,21 +7,23 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {
'status': ['preview'], 'metadata_version': '1.1',
'supported_by': 'core'} 'status': ['preview'],
'supported_by': 'core'
}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
author: author: Ansible Core Team (@ansible)
- "Ansible Core Team (@ansible)"
module: import_role module: import_role
short_description: Import a role into a play short_description: Import a role into a play
description: description:
- Mostly like the `roles:` keyword this action loads a role, but it allows you to control when the tasks run in between other playbook tasks. - Much like the `roles:` keyword, this task loads a role, but it allows you to control it when the role tasks run in
- Most keywords, loops and conditionals will not be applied to this action, but to the imported tasks instead. between other tasks of the play.
If you want the opposite behaviour, use M(include_role) instead. - Most keywords, loops and conditionals will only be applied to the imported tasks, not to this statement itself. If
you want the opposite behaviour, use M(include_role) instead.
version_added: "2.4" version_added: "2.4"
options: options:
name: name:
@ -30,19 +32,19 @@ options:
required: True required: True
tasks_from: tasks_from:
description: description:
- "File to load from a Role's tasks/ directory." - File to load from a role's C(tasks/) directory.
required: False required: False
default: 'main' default: main
vars_from: vars_from:
description: description:
- "File to load from a Role's vars/ directory." - File to load from a role's C(vars/) directory.
required: False required: False
default: 'main' default: main
defaults_from: defaults_from:
description: description:
- "File to load from a Role's defaults/ directory." - File to load from a role's C(defaults/) directory.
required: False required: False
default: 'main' default: main
allow_duplicates: allow_duplicates:
description: description:
- Overrides the role's metadata setting to allow using a role more than once with the same parameters. - Overrides the role's metadata setting to allow using a role more than once with the same parameters.
@ -50,10 +52,11 @@ options:
default: True default: True
private: private:
description: description:
- If True the variables from defaults/ and vars/ in a role will not be made available to the rest of the play. - If C(True) the variables from C(defaults/) and C(vars/) in a role will not be made available to the rest of the
play.
default: None default: None
notes: notes:
- Handlers are made available to the whole play. - Handlers are made available to the whole play.
''' '''
EXAMPLES = """ EXAMPLES = """
@ -62,7 +65,7 @@ EXAMPLES = """
- import_role: - import_role:
name: myrole name: myrole
- name: Run tasks/other.yml instead of 'main' - name: Run tasks/other.yaml instead of 'main'
import_role: import_role:
name: myrole name: myrole
tasks_from: other tasks_from: other
@ -71,7 +74,7 @@ EXAMPLES = """
import_role: import_role:
name: myrole name: myrole
vars: vars:
rolevar1: 'value from task' rolevar1: value from task
- name: Apply loop to each task in role - name: Apply loop to each task in role
import_role: import_role:
@ -89,5 +92,5 @@ EXAMPLES = """
""" """
RETURN = """ RETURN = """
# this module does not return anything except tasks to execute # This module does not return anything except tasks to execute.
""" """

View file

@ -7,52 +7,53 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {
'status': ['preview'], 'metadata_version': '1.1',
'supported_by': 'core'} 'status': ['preview'],
'supported_by': 'core'
}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
author: author: Ansible Core Team (@ansible)
- "Ansible Core Team (@ansible)"
module: import_tasks module: import_tasks
short_description: import a task list. short_description: Import a task list
description: description:
- Imports a list of tasks to be added to the current playbook for subsequent execution. - Imports a list of tasks to be added to the current playbook for subsequent execution.
version_added: "2.4" version_added: "2.4"
options: options:
free-form: free-form:
description: description:
- This action allows you to specify the name of the file directly w/o any other options. - The name of the imported file is specified directly without any other option.
- Any loops, conditionals and most other keywords will be applied to the included tasks, not to this statement itself. - Most keywords, including loops and conditionals, only applied to the imported tasks, not to this statement
- If you need any of those to apply to this action, use M(include_tasks) instead. itself. If you need any of those to apply, use M(include_tasks) instead.
notes: notes:
- This is really not a module, this is a feature of the Ansible Engine, as such it cannot be overridden the same way a module can. - This is a core feature of Ansible, rather than a module, and cannot be overridden like a module.
''' '''
EXAMPLES = """ EXAMPLES = """
# include task list in play
- hosts: all - hosts: all
tasks: tasks:
- debug: - debug:
msg: task1 msg: task1
- import_tasks: stuff.yml - name: Include task list in play
import_tasks: stuff.yaml
- debug: - debug:
msg: task10 msg: task10
# apply conditional to all imported tasks hosts: all
- hosts: all
tasks: tasks:
- debug: - debug:
msg: task1 msg: task1
- import_tasks: stuff.yml - name: Apply conditional to all imported tasks
import_tasks: stuff.yaml
when: hostvar is defined when: hostvar is defined
""" """
RETURN = """ RETURN = """
# this module does not return anything except tasks to execute # This module does not return anything except tasks to execute.
""" """

View file

@ -7,20 +7,23 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {
'status': ['preview'], 'metadata_version': '1.1',
'supported_by': 'core'} 'status': ['preview'],
'supported_by': 'core'
}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
author: author: Ansible Core Team (@ansible)
- "Ansible Core Team (@ansible)"
module: include_role module: include_role
short_description: Load and execute a role short_description: Load and execute a role
description: description:
- Loads and executes a role as a task, this frees roles from the `role:` directive and allows them to be treated more as tasks. - Loads and executes a role as a task dynamically. This frees roles from the `roles:` directive and allows them to be
- This module is also supported for Windows targets. treated more as tasks.
- Unlike M(import_role), most keywords, including loops and conditionals, apply to this statement.
- This module is also supported for Windows targets.
version_added: "2.2" version_added: "2.2"
options: options:
name: name:
@ -29,19 +32,19 @@ options:
required: True required: True
tasks_from: tasks_from:
description: description:
- "File to load from a Role's tasks/ directory." - File to load from a role's C(tasks/) directory.
required: False required: False
default: 'main' default: main
vars_from: vars_from:
description: description:
- "File to load from a Role's vars/ directory." - File to load from a role's C(vars/) directory.
required: False required: False
default: 'main' default: main
defaults_from: defaults_from:
description: description:
- "File to load from a Role's defaults/ directory." - File to load from a role's C(defaults/) directory.
required: False required: False
default: 'main' default: main
allow_duplicates: allow_duplicates:
description: description:
- Overrides the role's metadata setting to allow using a role more than once with the same parameters. - Overrides the role's metadata setting to allow using a role more than once with the same parameters.
@ -49,21 +52,22 @@ options:
default: True default: True
private: private:
description: description:
- If True the variables from defaults/ and vars/ in a role will not be made available to the rest of the play. - If C(True) the variables from C(defaults/) and C(vars/) in a role will not be made available to the rest of the
play.
default: None default: None
notes: notes:
- Handlers are made available to the whole play. - Handlers are made available to the whole play.
- Before 2.4, as with C(include), this task could be static or dynamic, If static it implied that it won't need templating nor loops nor conditionals - Before Ansible 2.4, as with C(include), this task could be static or dynamic, If static, it implied that it won't
and will show included tasks in the --list options. need templating, loops or conditionals and will show included tasks in the `--list` options. Ansible would try to
Ansible would try to autodetect what is needed, but you can set `static` to `yes` or `no` at task level to control this. autodetect what is needed, but you can set `static` to `yes` or `no` at task level to control this.
- After 2.4, you can use M(import_role) for 'static' behaviour and this action for 'dynamic' one. - After Ansible 2.4, you can use M(import_role) for 'static' behaviour and this action for 'dynamic' one.
''' '''
EXAMPLES = """ EXAMPLES = """
- include_role: - include_role:
name: myrole name: myrole
- name: Run tasks/other.yml instead of 'main' - name: Run tasks/other.yaml instead of 'main'
include_role: include_role:
name: myrole name: myrole
tasks_from: other tasks_from: other
@ -72,7 +76,7 @@ EXAMPLES = """
include_role: include_role:
name: myrole name: myrole
vars: vars:
rolevar1: 'value from task' rolevar1: value from task
- name: Use role in loop - name: Use role in loop
include_role: include_role:
@ -83,12 +87,12 @@ EXAMPLES = """
loop_control: loop_control:
loop_var: roleinputvar loop_var: roleinputvar
- name: conditional role - name: Conditional role
include_role: include_role:
name: myrole name: myrole
when: not idontwanttorun when: not idontwanttorun
""" """
RETURN = """ RETURN = """
# this module does not return anything except tasks to execute # This module does not return anything except tasks to execute.
""" """

View file

@ -7,51 +7,52 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {
'status': ['preview'], 'metadata_version': '1.1',
'supported_by': 'core'} 'status': ['preview'],
'supported_by': 'core'
}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
author: author: Ansible Core Team (@ansible)
- "Ansible Core Team (@ansible)"
module: include_tasks module: include_tasks
short_description: dynamically include a task list. short_description: Dynamically include a task list
description: description:
- Includes a file with a list of tasks to be executed in the current playbook. - Includes a file with a list of tasks to be executed in the current playbook.
version_added: "2.4" version_added: "2.4"
options: options:
free-form: free-form:
description: description:
- This action allows you to specify the name of the file directly w/o any other options. - The name of the imported file is specified directly without any other option.
- Unlike M(import_tasks) this action will be affected by most keywords, including loops and conditionals. - Unlike M(import_tasks), most keywords, including loops and conditionals, apply to this statement.
notes: notes:
- This is really not a module, this is a feature of the Ansible Engine, as such it cannot be overridden the same way a module can. - This is a core feature of the Ansible, rather than a module, and cannot be overridden like a module.
''' '''
EXAMPLES = """ EXAMPLES = """
# include task list in play
- hosts: all - hosts: all
tasks: tasks:
- debug: - debug:
msg: task1 msg: task1
- include_tasks: stuff.yml - name: Include task list in play
include_tasks: stuff.yaml
- debug: - debug:
msg: task10 msg: task10
# dyanmic include task list in play
- hosts: all - hosts: all
tasks: tasks:
- debug: - debug:
msg: task1 msg: task1
- include_tasks: "{{ hostvar }}.yml" - name: Include task list in play only if the condition is true
include_tasks: "{{ hostvar }}.yaml"
when: hostvar is defined when: hostvar is defined
""" """
RETURN = """ RETURN = """
# this module does not return anything except tasks to execute # This module does not return anything except tasks to execute.
""" """

View file

@ -5,27 +5,29 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1', ANSIBLE_METADATA = {
'status': ['stableinterface'], 'metadata_version': '1.1',
'supported_by': 'core'} 'status': ['stableinterface'],
'supported_by': 'core'
}
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
author: "Allen Sanabria (@linuxdynasty)" author: Allen Sanabria (@linuxdynasty)
module: include_vars module: include_vars
short_description: Load variables from files, dynamically within a task. short_description: Load variables from files, dynamically within a task
description: description:
- Loads variables from a YAML/JSON files dynamically from within a file or from a directory recursively during task runtime. If loading a directory, - Loads variables from a YAML/JSON files dynamically from within a file or from a directory recursively during task
the files are sorted alphabetically before being loaded. runtime. If loading a directory, the files are sorted alphabetically before being loaded.
- This module is also supported for Windows targets. - This module is also supported for Windows targets.
version_added: "1.4" version_added: "1.4"
options: options:
file: file:
version_added: "2.2" version_added: "2.2"
description: description:
- The file name from which variables should be loaded. - The file name from which variables should be loaded.
- If the path is relative, it will look for the file in vars/ subdirectory of a role or relative to playbook. - If the path is relative, it will look for the file in vars/ subdirectory of a role or relative to playbook.
dir: dir:
version_added: "2.2" version_added: "2.2"
description: description:
@ -35,13 +37,13 @@ options:
name: name:
version_added: "2.2" version_added: "2.2"
description: description:
- The name of a variable into which assign the included vars, if omitted (null) they will be made top level vars. - The name of a variable into which assign the included vars. If omitted (null) they will be made top level vars.
default: null default: null
depth: depth:
version_added: "2.2" version_added: "2.2"
description: description:
- When using C(dir), this module will, by default, recursively go through each sub directory and load up the variables. - When using C(dir), this module will, by default, recursively go through each sub directory and load up the
By explicitly setting the depth, this module will only go as deep as the depth. variables. By explicitly setting the depth, this module will only go as deep as the depth.
default: 0 default: 0
files_matching: files_matching:
version_added: "2.2" version_added: "2.2"
@ -57,65 +59,65 @@ options:
version_added: "2.3" version_added: "2.3"
description: description:
- List of file extensions to read when using C(dir). - List of file extensions to read when using C(dir).
default: ['yaml', 'yml', 'json'] default: [yaml, yml, json]
required: False required: False
free-form: free-form:
description: description:
- This module allows you to specify the 'file' option directly w/o any other options. - This module allows you to specify the 'file' option directly without any other options.
There is no 'free-form' option, this is just an indicator, see example below. There is no 'free-form' option, this is just an indicator, see example below.
notes: notes:
- This module is also supported for Windows targets. - This module is also supported for Windows targets.
''' '''
EXAMPLES = """ EXAMPLES = """
- name: Include vars of stuff.yml into the 'stuff' variable (2.2). - name: Include vars of stuff.yaml into the 'stuff' variable (2.2).
include_vars: include_vars:
file: stuff.yml file: stuff.yaml
name: stuff name: stuff
- name: Conditionally decide to load in variables into 'plans' when x is 0, otherwise do not. (2.2) - name: Conditionally decide to load in variables into 'plans' when x is 0, otherwise do not. (2.2)
include_vars: include_vars:
file: contingency_plan.yml file: contingency_plan.yaml
name: plans name: plans
when: x == 0 when: x == 0
- name: Load a variable file based on the OS type, or a default if not found. Using free-form to specify the file. - name: Load a variable file based on the OS type, or a default if not found. Using free-form to specify the file.
include_vars: "{{ item }}" include_vars: "{{ item }}"
with_first_found: with_first_found:
- "{{ ansible_distribution }}.yml" - "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yml" - "{{ ansible_os_family }}.yaml"
- "default.yml" - default.yaml
- name: bare include (free-form) - name: Bare include (free-form)
include_vars: myvars.yml include_vars: myvars.yaml
- name: Include all .json and .jsn files in vars/all and all nested directories (2.3) - name: Include all .json and .jsn files in vars/all and all nested directories (2.3)
include_vars: include_vars:
dir: 'vars/all' dir: vars/all
extensions: extensions:
- json - json
- jsn - jsn
- name: Include all default extension files in vars/all and all nested directories and save the output in test. (2.2) - name: Include all default extension files in vars/all and all nested directories and save the output in test. (2.2)
include_vars: include_vars:
dir: 'vars/all' dir: vars/all
name: test name: test
- name: Include default extension files in vars/services (2.2) - name: Include default extension files in vars/services (2.2)
include_vars: include_vars:
dir: 'vars/services' dir: vars/services
depth: 1 depth: 1
- name: Include only files matching bastion.yml (2.2) - name: Include only files matching bastion.yaml (2.2)
include_vars: include_vars:
dir: 'vars' dir: vars
files_matching: 'bastion.yml' files_matching: bastion.yaml
- name: Include all .yml files except bastion.yml (2.3) - name: Include all .yaml files except bastion.yaml (2.3)
include_vars: include_vars:
dir: 'vars' dir: vars
ignore_files: 'bastion.yml' ignore_files: bastion.yaml
extensions: ['yml'] extensions: [yaml]
""" """
RETURN = ''' RETURN = '''
@ -128,6 +130,6 @@ ansible_included_var_files:
description: A list of files that were successfully included description: A list of files that were successfully included
returned: success returned: success
type: list type: list
sample: [ '/path/to/file.yml', '/path/to/file.json' ] sample: [ '/path/to/file.yaml', '/path/to/file.json' ]
version_added: 2.4 version_added: 2.4
''' '''