Skip to content

Commit

Permalink
user_guide: Fix reuse role examples (ansible#71440)
Browse files Browse the repository at this point in the history
Fixes: ansible#53919

Signed-off-by: Abhijeet Kasurde <[email protected]>
  • Loading branch information
Akasurde authored Aug 25, 2020
1 parent 5c15949 commit 0b16c0a
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions docs/docsite/rst/user_guide/playbooks_reuse_roles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0b16c0a

Please sign in to comment.