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

12 views
Skip to first unread message

Nick Tkach

unread,
Sep 20, 2016, 1:43:06 PM9/20/16
to Ansible Project
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.

Dick Davies

unread,
Sep 22, 2016, 9:53:10 AM9/22/16
to ansible list
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.
> --
> 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/27dfd044-d57c-4c46-96a1-c2e1ad405570%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages