Very nice approach. FWIW here is how I've been doing it and it works, 
thanks to Nathan.

/roles/common/tasks/main.yml (at the very end):
- name: 'Common | Remember that this role had been run'
  set_fact: role_common_completed=true

/roles/OTHERS/meta/main.yml
dependencies:
  - { role: common, when: role_common_completed is not defined }

Perfect !

Am Donnerstag, 5. Dezember 2013 22:52:21 UTC+1 schrieb Nathan Howell:
>
> I ended up having my common role use set_fact on its first run, then it 
> gets skipped on subsequent runs based on that fact, but it's not an ideal 
> solution. I'd be interested in a better answer for this as well.
>
> Nathan
>
> On Thursday, 5 December 2013 07:40:28 UTC-8, Jürgen Haas wrote:
>>
>> According to the documentation, role dependencies would no longer run 
>> more than once, unless the setting allow_duplicates: yes was used. I assume 
>> that is if a role is included more than once with the same play.
>>
>> In my scenario a role called common is included from almost every other 
>> role and hence gets executed every time which makes the whole thing pretty 
>> lengthy. Is there a way to stop this from happening?
>>
>> The main playbook looks more or less like this:
>>
>> - name: "Apache Servers"
>>   roles:
>>     - apache
>>
>> - name: "MySQL Servers"
>>   roles:
>>     - mysql
>>
>> - name: "Some other Servers"
>>   roles:
>>     - something
>>
>> All the roles (apache, mysql, something) are dependent on the role common 
>> and if one of my hosts has more than one role, then both roles get executed 
>> and therefore common gets executed more than once. Can I change this?
>>
>

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to