# How to Deploy Multiple Applications

**URL:** <https://forum.ansible.com/t/how-to-deploy-multiple-applications/16016>\
**Category:** Ansible Developer\
**Created:** [August 22, 2014, 3:10pm UTC](https://forum.ansible.com/t/how-to-deploy-multiple-applications/16016 "2014-08-22T15:10:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joseph\_Athman](https://avatars.discourse-cdn.com/v4/letter/j/49beb7/32.png) [@Joseph\_Athman](https://forum.ansible.com/u/Joseph_Athman)\
**Post date:** [August 22, 2014, 3:10pm UTC](https://forum.ansible.com/t/how-to-deploy-multiple-applications/16016/1 "2014-08-22T15:10:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 22, 2014, 3:32pm UTC](https://forum.ansible.com/t/how-to-deploy-multiple-applications/16016/2 "2014-08-22T15:32:59Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Joseph\_Athman](https://avatars.discourse-cdn.com/v4/letter/j/49beb7/32.png) [@Joseph\_Athman](https://forum.ansible.com/u/Joseph_Athman)\
**Post date:** [August 22, 2014, 3:52pm UTC](https://forum.ansible.com/t/how-to-deploy-multiple-applications/16016/3 "2014-08-22T15:52:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![julien\_barbay](https://avatars.discourse-cdn.com/v4/letter/j/90db22/32.png) [@julien\_barbay](https://forum.ansible.com/u/julien_barbay)\
**Post date:** [August 26, 2014, 8:22pm UTC](https://forum.ansible.com/t/how-to-deploy-multiple-applications/16016/4 "2014-08-26T20:22:25Z")

</div>

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](http://galaxy.ansible.com)).

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

Julien

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 26, 2014, 11:13pm UTC](https://forum.ansible.com/t/how-to-deploy-multiple-applications/16016/5 "2014-08-26T23:13:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 26, 2014, 11:13pm UTC](https://forum.ansible.com/t/how-to-deploy-multiple-applications/16016/6 "2014-08-26T23:13:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Joseph\_Athman](https://avatars.discourse-cdn.com/v4/letter/j/49beb7/32.png) [@Joseph\_Athman](https://forum.ansible.com/u/Joseph_Athman)\
**Post date:** [August 27, 2014, 1:14am UTC](https://forum.ansible.com/t/how-to-deploy-multiple-applications/16016/7 "2014-08-27T01:14:39Z")

</div>

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
