# using ansible to deploy war to stage/qa env

**URL:** <https://forum.ansible.com/t/using-ansible-to-deploy-war-to-stage-qa-env/15962>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [August 15, 2014, 5:10pm UTC](https://forum.ansible.com/t/using-ansible-to-deploy-war-to-stage-qa-env/15962 "2014-08-15T17:10:54Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Subramanian\_Olagappa](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@Subramanian\_Olagappa](https://forum.ansible.com/u/Subramanian_Olagappa)\
**Post date:** [August 15, 2014, 5:10pm UTC](https://forum.ansible.com/t/using-ansible-to-deploy-war-to-stage-qa-env/15962/1 "2014-08-15T17:10:54Z")

</div>

Hi !

I currently using python tools for continuous deloy to AWS ec2 nodes and want to use ansible for continuous deploy. We have stage and qa env with different properties. Could someone point to me the right approach to setup continuous deploy to mulitple env with the right properties.

Thanks,  
Olga S

---

<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 16, 2014, 2:58pm UTC](https://forum.ansible.com/t/using-ansible-to-deploy-war-to-stage-qa-env/15962/2 "2014-08-16T14:58:41Z")

</div>

I recommend keeping your inventory in a directory, like inventory/

and then have a inventory/production and a inventory/stage

This prevents accidentally running something against both as you’ll have to -i inventory/stage (unless you type -i inventory!)

Usage of group\_vars is then the way to organize variance between them.

See [http://docs.ansible.com/playbooks\_best\_practices.html#how-to-arrange-inventory-stage-vs-production](http://docs.ansible.com/playbooks_best_practices.html#how-to-arrange-inventory-stage-vs-production)

---

<div class="post-metadata">

**Author:** ![Brian\_Finch](https://avatars.discourse-cdn.com/v4/letter/b/aeb1de/32.png) [@Brian\_Finch](https://forum.ansible.com/u/Brian_Finch)\
**Post date:** [August 24, 2014, 1:22pm UTC](https://forum.ansible.com/t/using-ansible-to-deploy-war-to-stage-qa-env/15962/3 "2014-08-24T13:22:58Z")

</div>

Sorry, I’m new here. Can you elaborate a bit on how this would work?

The docs recommend a setup like this

```auto
production # inventory file for production servers
stage # inventory file for stage environment

group_vars/
   group1 # here we assign variables to particular groups
   group2 # ""
host_vars/
   hostname1 # if systems need specific variables, put them here
   hostname2 # ""

```

So instead you’re recommending this?

```auto
inventory/production # inventory file for production servers
inventory/stage # inventory file for stage environment

group_vars/
   group1 # here we assign variables to particular groups
   group2 # ""

```

So with that setup would you need to use different group names in the inventories so you can set them separately in the global group\_vars?  
If I want to use the same group names in my production and stage inventories, will something like this work?

```auto
inventory/production/inventory # inventory file for production servers
inventory/stage/inventory # inventory file for stage environment

inventory/production/group_vars/
   group1 # here we assign variables to production group1

```

---

<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 24, 2014, 1:50pm UTC](https://forum.ansible.com/t/using-ansible-to-deploy-war-to-stage-qa-env/15962/4 "2014-08-24T13:50:48Z")

</div>

I wrote those docs 🙂

You have this part slightly off:

```auto
inventory/production # inventory file for production servers
inventory/stage # inventory file for stage environment

group_vars/
   group1 # here we assign variables to particular groups
   group2 # ""

```

```auto
Drop the group_vars directory inside inventory, so like inventory/group_vars/group1.

```

```auto
Then it just works. group_vars must be alongside the inventory files, but "-i inventory_dir" is a shortcut to run multiple inventory files at the same time, should you ever want to.  

```

```auto
Still use groups and have groups for production and stage, because you may want them in your playbooks to assign different variable settings to them. 

```

---

<div class="post-metadata">

**Author:** ![Brian\_Finch](https://avatars.discourse-cdn.com/v4/letter/b/aeb1de/32.png) [@Brian\_Finch](https://forum.ansible.com/u/Brian_Finch)\
**Post date:** [August 24, 2014, 2:29pm UTC](https://forum.ansible.com/t/using-ansible-to-deploy-war-to-stage-qa-env/15962/5 "2014-08-24T14:29:50Z")

</div>

Thanks! That clears it up.

---

<div class="post-metadata">

**Author:** ![Jordi\_Funollet](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Jordi\_Funollet](https://forum.ansible.com/u/Jordi_Funollet)\
**Post date:** [August 26, 2014, 1:41pm UTC](https://forum.ansible.com/t/using-ansible-to-deploy-war-to-stage-qa-env/15962/6 "2014-08-26T13:41:02Z")

</div>

With this schema,

```auto
inventory/production # inventory file for production servers
inventory/stage # inventory file for stage environment

inventory/group_vars/
   group1 # here we assign variables to particular groups
   group2 # ""

```

can vars have different values on every environment? Or must group names be different on every environment?

---

<div class="post-metadata">

**Author:** ![Tomasz\_Kontusz](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@Tomasz\_Kontusz](https://forum.ansible.com/u/Tomasz_Kontusz)\
**Post date:** [August 26, 2014, 4:24pm UTC](https://forum.ansible.com/t/using-ansible-to-deploy-war-to-stage-qa-env/15962/7 "2014-08-26T16:24:39Z")

</div>

Jordi Funollet \<funollet@fastmail.fm\> napisał:

> With this schema,
> 
> inventory/production # inventory file for production  
> serv  
> ers  
> inventory/stage # inventory file for stage  
> environme  
> nt
> 
> inventory/group\_vars/  
> group1 # here we assign variables to particular group  
> s  
> group2 # ""
> 
> can vars have different values on every environment? Or must  
> group names be different on every environment?

You'd have to have different group names, or move the differing vars into inventories.  
You can also use a schema like this:

production/group\_vars/...  
production/inventory  
staging/group\_vars/...  
staging/inventory

group\_vars/... # those are common  
playbookA.yml  
playbookB.yml  
site.yml

---

<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, 10:57pm UTC](https://forum.ansible.com/t/using-ansible-to-deploy-war-to-stage-qa-env/15962/8 "2014-08-26T22:57:15Z")

</div>

No, you _cannot_ do what Tomas says above and then still target “-i inventory” as one common infrastructure.

instead, do this.

Inside your inventory/production put all hosts under a group named “production”

Inside your inventory/stage, put all hosts under a group named “stage”.

---

<div class="post-metadata">

**Author:** ![Jordi\_Funollet](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Jordi\_Funollet](https://forum.ansible.com/u/Jordi_Funollet)\
**Post date:** [August 27, 2014, 9:25am UTC](https://forum.ansible.com/t/using-ansible-to-deploy-war-to-stage-qa-env/15962/9 "2014-08-27T09:25:39Z")

</div>

But then I miss the ability to run a task in a group of a specific  
environment (say, just on production hosts of group 'dbservers' ). Am I  
right? Or is there a way to express this?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [August 28, 2014, 2:03am UTC](https://forum.ansible.com/t/using-ansible-to-deploy-war-to-stage-qa-env/15962/10 "2014-08-28T02:03:00Z")

</div>

hosts can be in more than one group. all hosts in the production file should be in production group, but you can also have hosts in dbservers group.​

---

<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 28, 2014, 9:02pm UTC](https://forum.ansible.com/t/using-ansible-to-deploy-war-to-stage-qa-env/15962/11 "2014-08-28T21:02:12Z")

</div>

Take a look at --limit to refine execution to a specific subgroup, or additional parameters on the host specifier like:

- hosts: webservers:&phoenix

To select all webservers in phoenix

–limit phoenix does the same thing as adding “:&phoenix” to all host specifiers.

---

<div class="post-metadata">

**Author:** ![Jordi\_Funollet](https://avatars.discourse-cdn.com/v4/letter/j/7feea3/32.png) [@Jordi\_Funollet](https://forum.ansible.com/u/Jordi_Funollet)\
**Post date:** [August 29, 2014, 12:54pm UTC](https://forum.ansible.com/t/using-ansible-to-deploy-war-to-stage-qa-env/15962/12 "2014-08-29T12:54:47Z")

</div>

I forgot the ':&' operator. Thanks Michael.
