Large or small roles?

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.

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