Structure of role-base configuration of hosts

Hi,

I really like the idea of role-base configuration of hosts. What do I
mean with this? A role means to me e.g. "database-server", "app-
server", "web-server". Depending on the environment (test or
production) I would like to assign these roles to hosts in a different
way:

Production environment with 4 separate hosts:
  prod-db-host role(s): database-server
  prod-app1 role(s): app-server,
  prod-app2 role(s): app-server,
  prod-web-server role(s): web-server

Frank's test environment with just 1 host that is doing everything:
  test-frank-host role(s): database-server+app-server+web-server

Now I write how I try to implement this with Ansible. I would like to
get some feedback whether there are better ways to do this.

I configure playbooks for each role, i.e. I create a "database-
server.yml", "app-server.yml", "web-server.yml". These playbooks also
include some things like e.g. handlers. Each of this playbook is
restricted to only one role, i.e. the "database-server.yml" starts
with

Hi,

I really like the idea of role-base configuration of hosts.

Groups are usable for this.

Have a play for each group.

I also would like to put all together playbooks together to simply the
execution, i.e. I would like to create a “all.yml” that includes
database-server.yml", “app-server.yml”, “web-server.yml” (to simplify
the execution and to have all stuff in my version control system):
ansible-playbook all.yml --debug --inventory=prod-hosts

Just have a top level play with multiple plays for each group

The first play targets web servers and runs webserver.yml, the next targets database servers and runs dbserver.yml, etc

Unfortunately, this is impossible because nested includes are not
allowed.

It’s totally possible, see above.

Hi Michael,

Have a play for each group.

but this means that all configuration is in one big/huge file. Do you
think, this is a good idea?

Frank

I don’t think it would be very large if you had a sane number of groups.

Generally the play is intended to define a role, and the actual group name is just grouping some machines together.

Groups are not necessarily roles and may often be geographic.

Here is an example of a top level playbook where include files are used to map roles to hosts:

https://github.com/mpdehaan/ansible-examples/blob/master/monitoring.yml

Assume it was named “site.yml” instead of “monitoring.yml”, if you like.