How to Deploy Multiple Applications

I’m just starting out with Ansible and looking for some guidance about how to deploy multiple applications with the same playbook. I created a playbook that can deploy a single application to a server, now I’m trying to make it more generic and allow the same playbook to be used to deploy any of the applications at our company. Here’s a typical setup for our applications:

Dev:
Server1 - App1, App2
Server2 - App2, App3
Server3 - App3

What I’d like to be able to do is have the option to run a playbook and have it deploy all applications, or be able to just deploy a single application. The reason I’d like a single playbook is so each application team doesn’t have to recreate the steps of the playbook, I’d like to just parameterize a single playbook somehow so every application is deployed the same way. Anyone have a suggestion for how I can accomplish this? Thank you!

  • Joe

Deploying to multiple tiers looks like this:

  • hosts: webserver
    roles:

  • monitoring_config

  • mywebapp

  • hosts: dbservers
    roles:

  • someapp

  • mydbconfig

So put servers in groups with what combos of roles you want to apply, and go from there.

Let me know if you need more info - this is only intended to be a starter-post in case I didn’t grok the question correctly.

Thanks!

Thank you for the quick response.

So each role would be an application name? In your example, when I run the playbook for the “webserver” host, will ansible run the playbook once for each role defined? Sorry if this is incredibly obvious, I haven’t done anything with roles yet.

  • Joe

Hi,

I would suggest you create an host file that would be (according to your description) :

[app1]
server1
[app2]
server1
server2
[app3]
server2
server3

Then you could order tasks as Joe mentions in your playbook :


  • name: deploy app1
    hosts: app1

roles:

  • role: foo1
  • name: deploy app2
    hosts: app2

roles:

  • role: foo2
  • name: deploy app3
    hosts: app3

roles:

  • role: foo3

Roles are not “application name” but rather a data-structure that would help you to configure a single piece of software. The main goal of cutting by roles would be to be able to compose your applications with multiple ones, and then factorize development of roles (and even sharing them on galaxy.ansible.com).

As i’m also kinda new, thanks for any correction/clarification that would help :slight_smile:

Julien

you could also have a site.yml that was nothing more than

BTW, this is a question that should be asked on ansible-project in the future :slight_smile:

Thanks for all the help guys, I’ll check out all of this tomorrow. I think my company is meeting with the people from Ansible soon to talk about this as well as Tower, so I’m sure they will be able to help.

@michael - I noticed the other forum after I posted this…I can’t stand it when people post to the wrong group and now I did it! Sorry, I’ll make sure to put it in the right place in the future.

  • Joe