At the moment I have a playbook file that looks like this (though Im sure 
there is a more eligant way to do this):

- hosts: QA
  tasks:
   - name: copy war file
     action: copy src=/staging/staging.war dest=/tmp/staging.war

- hosts: AGGQA
  tasks:
   - name: rename app1 war file
     shell: mv /usr/local/tomcat1/webapps/app1.war 
/usr/local/tomcat1/webapps/app1.war.{{ ansible_date_time.year }}{{ 
ansible_date_time.month }}{{ ansible_date_time.day }}
     when: ansible_hostname == "qa01"
   - name: rename app2 war file
     shell: mv /usr/local/tomcat2/webapps/app2.war 
/usr/local/tomcat2/webapps/app2.war.{{ ansible_date_time.year }}{{ 
ansible_date_time.month }}{{ ansible_date_time.day }}
     when: ansible_hostname == "qa01"
   - name: rename app3 war file
     shell: mv /usr/local/tomcat1/webapps/app3.war 
/usr/local/tomcat1/webapps/app3.war.{{ ansible_date_time.year }}{{ 
ansible_date_time.month }}{{ ansible_date_time.day }}
     when: ansible_hostname == "qa02"
   - name: rename app4 war file
     shell: mv /usr/local/tomcat2/webapps/app4.war 
/usr/local/tomcat2/webapps/app4.war.{{ ansible_date_time.year }}{{ 
ansible_date_time.month }}{{ ansible_date_time.day }}
     when: ansible_hostname == "qa02"

  - name: copy new app1 war file   
     shell: cp /tmp/staging.war /usr/local/tomcat1/webapps/app1.war
     when: ansible_hostname == "qa01"
  - name: copy new app2 war file   
     shell: cp /tmp/staging.war /usr/local/tomcat2/webapps/app2.war
     when: ansible_hostname == "qa01"
  - name: copy new app3 war file   
     shell: cp /tmp/staging.war /usr/local/tomcat1/webapps/app3.war
     when: ansible_hostname == "qa02"
  - name: copy new app4 war file   
     shell: cp /tmp/staging.war /usr/local/tomcat3/webapps/app4.war
     when: ansible_hostname == "qa02"

  - name: Set permission's on new app1 war file   
     shell: chown tomcat:tomcat /usr/local/tomcat1/webapps/app1.war
     when: ansible_hostname == "qa01"
  - name: Set permission's on new app2 war file   
     shell: chown tomcat:tomcat /usr/local/tomcat2/webapps/app2.war
     when: ansible_hostname == "qa01"
  - name: Set permission's on new app3 war file   
     shell: chown tomcat:tomcat /usr/local/tomcat1/webapps/app3.war
     when: ansible_hostname == "qa02"
  - name: Set permission's on new app4 war file   
     shell: chown tomcat:tomcat /usr/local/tomcat2/webapps/app4.war
     when: ansible_hostname == "qa02"

On Monday, 14 September 2015 13:20:07 UTC+1, Aaron Eldridge wrote:
>
> Hi there, Im just starting with ansible so I appologise if this is a 
> stupid question.
>
> I have am wanting to try do use ansible to deploy .war web app's to 
> several QA servers. Each QA server hosts serveral instances of the app's 
> across multiple instances of tomcat per server (production is 1 per 
> server). 
>
> I was wanting to write a play book that would connect to each QA server, 
> copy the war files to each insteance on tomcat in on the server then move 
> onto the next box.
>
> The problem I originally had was I put each app as its own inventory item 
> (with the same host name), I found that this did not work. So I now have 
> just the 4 QA servers in there now. 
>
> Is there a good way do declare what app should be on what tomcat under 
> each server in the inventory or should that be in the playbook?
>
> Thank you for reading.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b1b4b02b-603f-4a9b-abdd-a3b1023e9c57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to