Examples of Multiple Instances of a "thing" on a single box

Does anyone know of any good examples of having more than one instance of an app per box? Most examples seem to be grouped into something like web_servers group has boxes 1,2,3 and has a nice, neat one httpd on 1, one httpd on 2, and one httpd on 3. Problem I’m having is that I’m working with an Apache httpd setup where there aren’t any nice, neat divisions like that. Apache httpd is on all the boxes, but box 1 might have conf appA, appB, and appC and box2 might have appB, appC, and appQ.

I’ve got something that sort of works based on a combination of group_vars files (appA.yml, appB.yml, etc) and clunky site.yml tasks like

  • hosts: all
    become: true
    become_user: my_webadm
    vars_files:

  • group_vars/appA.yml
    roles:

  • httpd
    tags:

  • appA

  • hosts: all
    become: true
    become_user: my_webadm
    vars_files:

  • group_vars/appB.yml
    roles:

  • httpd
    tags:

  • appB

And inventory is a flat file like

box1
box2
box3

My concern is it doesn’t easily scale to add in other environments or apps. Eventually we’ll need to add in “dev” and “qa” and “staging”. I realize this isn’t a great description and I don’t expect a full solution. I’m just looking for examples beyond just okay here’s a tomcat on box1, box2, and box4 and an apache on box 2 and box 4.

If you're talking about one httpd install with multiple vhosts, I'd
have an httpd role
that sets up a standard apache layout and then other roles to create
.vhost files
(Apaches 'Include' directive helps here).

Apply the httpd role everywhere you need it and add the other roles on top.
If you mark the vhost roles as having a dependency on the httpd roles
you can also
access the httpd roles vars and handlers, which keeps things manageable.