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

**URL:** <https://forum.ansible.com/t/examples-of-multiple-instances-of-a-thing-on-a-single-box/22598>\
**Category:** Ansible Project\
**Created:** [September 20, 2016, 5:43pm UTC](https://forum.ansible.com/t/examples-of-multiple-instances-of-a-thing-on-a-single-box/22598 "2016-09-20T17:43:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nick\_Tkach](https://avatars.discourse-cdn.com/v4/letter/n/b38774/32.png) [@Nick\_Tkach](https://forum.ansible.com/u/Nick_Tkach)\
**Post date:** [September 20, 2016, 5:43pm UTC](https://forum.ansible.com/t/examples-of-multiple-instances-of-a-thing-on-a-single-box/22598/1 "2016-09-20T17:43:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [September 22, 2016, 1:52pm UTC](https://forum.ansible.com/t/examples-of-multiple-instances-of-a-thing-on-a-single-box/22598/2 "2016-09-22T13:52:17Z")

</div>

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.
