user_guide: Fix reuse role examples (#71440)
Fixes: #53919 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
5c1594916a
commit
0b16c0a8c7
1 changed files with 21 additions and 6 deletions
|
@ -258,12 +258,22 @@ Ansible only executes each role once, even if you define it multiple times, unle
|
||||||
- bar
|
- bar
|
||||||
- foo
|
- foo
|
||||||
|
|
||||||
You have two options to force Ansible to run a role more than once:
|
You have two options to force Ansible to run a role more than once.
|
||||||
|
|
||||||
#. Pass different parameters in each role definition.
|
Passing different parameters
|
||||||
#. Add ``allow_duplicates: true`` to the ``meta/main.yml`` file for the role.
|
----------------------------
|
||||||
|
|
||||||
Example 1 - passing different parameters:
|
You can pass different parameters in each role definition as:
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
---
|
||||||
|
- hosts: webservers
|
||||||
|
roles:
|
||||||
|
- { role: foo, vars: { message: "first" } }
|
||||||
|
- { role: foo, vars: { message: "second" } }
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
@ -273,11 +283,16 @@ Example 1 - passing different parameters:
|
||||||
- role: foo
|
- role: foo
|
||||||
vars:
|
vars:
|
||||||
message: "first"
|
message: "first"
|
||||||
- { role: foo, vars: { message: "second" } }
|
- role: foo
|
||||||
|
vars:
|
||||||
|
message: "second"
|
||||||
|
|
||||||
In this example, because each role definition has different parameters, Ansible runs ``foo`` twice.
|
In this example, because each role definition has different parameters, Ansible runs ``foo`` twice.
|
||||||
|
|
||||||
Example 2 - using ``allow_duplicates: true``:
|
Using ``allow_duplicates: true``
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
Add ``allow_duplicates: true`` to the ``meta/main.yml`` file for the role:
|
||||||
|
|
||||||
.. code-block:: yaml
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue