Large or small roles?

78 views
Skip to first unread message

chris_...@sra.com

unread,
Feb 25, 2014, 9:44:36 AM2/25/14
to ansible...@googlegroups.com
Looking for feedback on what should go into a role.

I've created a 'common' role that will be applied to ALL my hosts.  It contains things like /etc/motd, snmp server settings, and ntp settings.  Currently I have defined things like this:

site-role.yml:

- hosts: all
  roles:
    - common

Directory layout:

roles/
|-- common
|   |-- handlers
|   |   `-- main.yml
|   |-- tasks
|   |   `-- main.yml
|   `-- templates
|       |-- motd
|       |-- ntp.conf
|       |-- syslog-ng.conf
|       `-- syslog-ng.logrotate

But I've been wondering if I should separate the various components into separate roles, like this:

Proposed site-role.yml

- hosts: all
  roles:
    - ntp
    - motd
    - snmp

Proposed directory layout:

roles/
|-- motd
|   |-- handlers
|   |-- tasks
|   `-- templates
|-- ntp
|   |-- handlers
|   |-- tasks
|   `-- templates
`-- snmp
    |-- handlers
    |-- tasks
    `-- templates

Again, all my hosts will get all of these things all the time, so I'm never going to have a reason to reference one of these role and not another. 

I'm happy with my current layout, but the second layout looks more like various Ansible examples I see out on the 'net and what's in the official Ansible docs. But my current layout makes more sense to me - all hosts need the stuff, so why spread it out to multiple roles versus just the one?

What's everybody else's opinions on these layouts? When is one more appropriate than the other?

thx
Chris.

James Martin

unread,
Feb 25, 2014, 12:50:41 PM2/25/14
to ansible...@googlegroups.com
If you never plan to reuse those individual components, then you don't need to separate them out as roles.  If the need ever arises for separate roles for those things, it's easy enough to re-write it to support that when the time comes.  

- James


--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/99ead413-80d1-412b-9da1-8766fde15486%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages