You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/docsite/rst/playbook_guide/playbooks_module_defaults.rst
+54-51Lines changed: 54 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,57 +102,10 @@ Setting a default AWS region for specific EC2-related modules.
102
102
Module defaults groups
103
103
----------------------
104
104
105
-
.. versionadded:: 2.7
106
-
107
-
Ansible 2.7 adds a preview-status feature to group together modules that share common sets of parameters. This makes it easier to author playbooks making heavy use of API-based modules such as cloud modules.
* The `docker_stack <docker_stack_module>`_ module is not included in the ``docker`` defaults group.
105
+
Module default groups allow to provide common parameters to groups of modules that belong together. Collections can define such groups in their ``meta/runtime.yml`` file.
132
106
133
-
Use the groups with ``module_defaults`` by prefixing the group name with ``group/`` - for example ``group/aws``.
134
-
135
-
In a playbook, you can set module defaults for whole groups of modules, such as setting a common AWS region.
136
-
137
-
.. code-block:: YAML
138
-
139
-
# example_play.yml
140
-
- hosts: localhost
141
-
module_defaults:
142
-
group/aws:
143
-
region: us-west-2
144
-
tasks:
145
-
- name: Get info
146
-
aws_s3_bucket_info:
147
-
148
-
# now the region is shared between both info modules
149
-
150
-
- name: Get info
151
-
ec2_ami_info:
152
-
filters:
153
-
name: 'RHEL*7.5*'
154
-
155
-
In ansible-core 2.12, collections can define their own groups in the ``meta/runtime.yml`` file. ``module_defaults`` does not take the ``collections`` keyword into account, so the fully qualified group name must be used for new groups in ``module_defaults``.
107
+
.. note::
108
+
``module_defaults`` does not take the ``collections`` keyword into account, so the fully qualified group name must be used for new groups in ``module_defaults``.
156
109
157
110
Here is an example ``runtime.yml`` file for the ``ns.coll`` collection.
158
111
This file defines an action group named ``ns.coll.my_group`` and places the ``sample_module`` from ``ns.coll`` and ``another_module`` from ``another.collection`` into the group.
@@ -175,4 +128,54 @@ This group can now be used in a playbook like this:
175
128
option_name: option_value
176
129
tasks:
177
130
- ns.coll.sample_module:
178
-
- another.collection.another_module:
131
+
- another.collection.another_module:
132
+
133
+
For historical reasons and backwards compatibility, there are some special groups:
0 commit comments