Skip to content

Commit c046ac0

Browse files
committed
add module defaults doc section
Signed-off-by: Andrew Twydell <[email protected]>
1 parent a222502 commit c046ac0

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

docs/source/playbooks.rst

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.. ...............................................................................
2-
.. © Copyright IBM Corporation 2020 .
2+
.. © Copyright IBM Corporation 2020,2023 .
33
.. Apache License, Version 2.0 (see https://opensource.org/licenses/Apache-2.0) .
44
.. ...............................................................................
55
@@ -173,6 +173,40 @@ The included sample variables file (all.yml) looks like this:
173173

174174

175175

176+
Module Defaults
177+
---------------
178+
179+
Ansible has a module defaults feature to use the same values during every use of
180+
a task, rather than repeating the values. Here we can set the host url and
181+
credentials of the **cmci_get** task to be the same throughout the playbook.
182+
183+
.. code-block:: yaml
184+
module_defaults:
185+
ibm.ibm_zos_cics.cmci_get:
186+
cmci_host: "{{ cmci_host }}"
187+
cmci_user: "{{ cmci_user }}"
188+
cmci_password: "{{ cmci_password }}"
189+
190+
191+
If you wish to use the same values in **all** CMCI tasks, you can assign them
192+
to the group called **cmci_group**.
193+
194+
.. code-block:: yaml
195+
196+
module_defaults:
197+
group/ibm.ibm_zos_cics.cmci_group:
198+
cmci_host: "my.system.host"
199+
cmci_port: "system.port.number"
200+
cmci_user: "my.username"
201+
cmci_password: "my.password"
202+
203+
.. note::
204+
Group module defaults are only available in ``ansible-core`` 2.12 or later. If
205+
this syntax is used with ``ansible-core`` 2.11 or earlier, the values are
206+
perceived as not present, and a 'missing required arguments' error is thrown.
207+
208+
209+
176210
Run the playbook
177211
----------------
178212

0 commit comments

Comments
 (0)