Right! Good plan.
You could do a "set_fact: role_has_executed=1" at the end of the role
and then on the role:
- role: { name: foo, when: "role_has_executed is defined" }
On Thu, Jul 17, 2014 at 3:31 AM, Tony Marin <[email protected]> wrote:
> 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 [email protected].
> To post to this group, send email to [email protected].
> 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.
>
>
> --
> [image: Swiss Mobility Solutions]
> <http://www.swissmobilitysolutions.com/>
> Tony Marin
>
> DevOps Manager
>
> Swiss Mobility Solutions
> a Gemalto Company
>
> [image: Mobile]+34 637402568 <+34%20637402568>
>
> [image: Office Telephone]+34 966370055 <+34%20966370055>
>
> [image: Skype]antonymcs
>
> [image: Location]Av. 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>
> [image: Email] <[email protected]> [image: LinkedIn]
> <http://es.linkedin.com/in/antonymcs/> [image: 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/53C77BEF.9060002%40swissms.ch
> <https://groups.google.com/d/msgid/ansible-project/53C77BEF.9060002%40swissms.ch?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgwYHDhAA9xUKiBp6t%3DRby7%3DmSbsy_DcqiO9KE_%2Bannq%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.