From 0b16c0a8c714d2e25cc269efdb0a2bea62a72b3c Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Tue, 25 Aug 2020 19:38:17 +0530 Subject: [PATCH] user_guide: Fix reuse role examples (#71440) Fixes: #53919 Signed-off-by: Abhijeet Kasurde --- .../rst/user_guide/playbooks_reuse_roles.rst | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/docs/docsite/rst/user_guide/playbooks_reuse_roles.rst b/docs/docsite/rst/user_guide/playbooks_reuse_roles.rst index daa7f8ae003..e985ed46b91 100644 --- a/docs/docsite/rst/user_guide/playbooks_reuse_roles.rst +++ b/docs/docsite/rst/user_guide/playbooks_reuse_roles.rst @@ -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