You can try to set a condition on the whole role (you can use an empty
main.yml with an inmport: ... when: common_executed is defined) based
upon a fact/variable that you can define at the end of the common role,
thus if it has been executed once, it will be skipped afterwards.
On 17/07/14 00:01, Ahmad Khayyat wrote:
I have a common role, which i always want executed, but only once. It
is also a dependency of a few other roles that may be executed on
their own (via dedicated playbooks).
The problem is: in a top-level playbook, e.g. site.yml, if the common
role is listed anywhere (in site.yml or an included playbook), and is
also a dependency of any other role, its tasks are executed twice.
What I'm thinking is to create a dummy role that depends on 'common',
and include the dummy role in the top-level playbook for all hosts.
That way, 'common' is *always* a dependency, and is always executed
exactly once.
Is there a better solution?
More generally, how can I avoid executing a role more than once,
whether it's listed explicitly or pulled in as a dependency?
If a role is a dependency of multiple other roles, it's executed once,
but if it's also listed explicitly, it is executed twice.
--
You received this message because you are subscribed to the Google
Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to ansible-project+unsubscr...@googlegroups.com
<mailto:ansible-project+unsubscr...@googlegroups.com>.
To post to this group, send email to ansible-project@googlegroups.com
<mailto:ansible-project@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAM19uTCnyStH4yH9hkLg58T2MqG5Vv9CWXR1FB11%3D5hBkvXcdQ%40mail.gmail.com
<https://groups.google.com/d/msgid/ansible-project/CAM19uTCnyStH4yH9hkLg58T2MqG5Vv9CWXR1FB11%3D5hBkvXcdQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.
--
Email Signature | Swiss Mobility Solutions a Gemalto company
Swiss Mobility Solutions <http://www.swissmobilitysolutions.com/>
Tony Marin
DevOps Manager
Swiss Mobility Solutions
a Gemalto Company
Mobile+34 637402568 <tel:+34%20637402568>
Office Telephone+34 966370055 <tel:+34%20966370055>
Skypeantonymcs <skype:antonymcs?call>
LocationAv. Locutor Vicente HipĆ³lito 39
03540 Alicante Spain
<https://maps.google.com/maps?q=Swiss+Mobility+Solutions+S.L,+Alicante,+Spain&hl=en&sll=37.0625,-95.677068&sspn=76.273886,78.837891&oq=swiss+mobility+so&hq=swiss+mobility+solutions+sl&hnear=Alicante,+Valencian+Community,+Spain&t=m&z=13>
Email <mailto:tony.ma...@gemalto.com> LinkedIn
<http://es.linkedin.com/in/antonymcs/> Website
<http://www.swissmobilitysolutions.com/>
--
You received this message because you are subscribed to the Google Groups "Ansible
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/53C77BEF.9060002%40swissms.ch.
For more options, visit https://groups.google.com/d/optout.