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.

Reply via email to