user_guide: Fix reuse role examples (#71440)

Fixes: #53919

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Abhijeet Kasurde 2020-08-25 19:38:17 +05:30 committed by GitHub
parent 5c1594916a
commit 0b16c0a8c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -258,12 +258,22 @@ Ansible only executes each role once, even if you define it multiple times, unle
- bar
- 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.
#. Add ``allow_duplicates: true`` to the ``meta/main.yml`` file for the role.
Passing different parameters
----------------------------
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
@ -273,11 +283,16 @@ Example 1 - passing different parameters:
- role: foo
vars:
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.
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