The main advantage I see to doing it with the role deps is that you can specify the mailserver_class parameter there. That means you don't have to remember to do it when you include the role, which is a mistake a new admin in your environment might make. Beyond that, these two functions are similar enough that, as you point out, there's not much of a win in refactoring them.
Role deps are definitely more suited to interconnected but non-related things, for instance a drupal stack where you're installing nginx, memcached, and php resulting in a clear chain of dependencies. On Tue, Feb 25, 2014 at 8:21 AM, <[email protected]> wrote: > I'm trying to figure out when and how best to use role dependencies. > > Currently I have a single role for handling my Postfix configuration on > ALL my hosts; some are classified as 'mail-servers' and the rest as > 'mail-clients'. Depending upon a role variable ('mailserver_class') I can > set when I call the role, I ether get one set of Postfix configuration > files or the other. > > My site-role.yml currently looks like this: > > - hosts: all:!mail-servers > roles: > - { role: postfix, tags: [mail-client] } > > - hosts: mail-servers > roles: > - { role: postfix, tags: [mail-server], mailserver_class: server } > > This works for me. however, I can see accomplishing basically the same > thing by creating 'mail-client' and 'mail-server' roles that both call > 'postfix' as a role dependency, such as: > > site-role.yml: > -hosts: all:!mail-servers > roles: > - mail-client > > -hosts: mail-servers > roles: > - mail-servers > > roles/mail-server/meta/main.yml: > > dependencies: > - { role: postfix } > > > roles/mail-server/meta/main.yml: > > dependencies: > - { role: postfix, mailserver_class: server } > > > To me, it seems that setting up actual 'mail-client' and 'mail-server' > roles each with a dependency on the 'postfix' role is more work and I'm not > sure I really gain anything in this case. On the other hand, by defining > these two roles, I can probably have my different Postfix configuration > templates live under those roles and probably not need the > 'mailserver_class' variable. [To be perfectly honest, my gut instinct is > to have everything in the Postfix role and then have internal logic > determine which config file to use - separating the configs to different > role just feel very, very wrong to me.] > > So, what thoughts do you have on these layouts? It feels like I can > accomplish the same thing with either layout. I wanted to see what other > people thought about these two cases and what advantages or disadvantages > each layout offered. Your thoughts are appreciated. > > thx > Chris. > > -- > 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/3578c34f-cdad-4916-a9b5-48fe16161781%40googlegroups.com > . > For more options, visit https://groups.google.com/groups/opt_out. > -- 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/CAFg%2Bn8SSvgqKk3skkB1vdfGyf0H5NDTTfxGQqNpFs-i232r8Xw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
