Forked from creativewild/War File deployment ansible-playbook
Created
July 6, 2022 15:35
-
-
Save amikha33/ecdfb180ef2360907b70440498b83af2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| - hosts: tomcatServer | |
| vars: | |
| - warName: ROOT.war | |
| - warRemotePath: /home/tomcat | |
| tasks: | |
| - name: Download WAR to server | |
| command: wget http://git-internal/release.war -O {{ warRemotePath }}/{{ warName }} | |
| - name: get current date | |
| set_fact: bkpdate="{{ lookup('pipe', 'date +%Y%m%d-%H%M') }}" | |
| - name: create directory with a date in name | |
| file: path="/home/tomcat/{{ bkpdate }}" | |
| state=directory | |
| mode=0755 | |
| - name: backup war | |
| shell: "cp /usr/local/tomcat/webapps/{{ warName }} /home/tomcat/{{ bkpdate }}/" | |
| - name: Unzip WAR file | |
| unarchive: src={{ warRemotePath }}/{{ warName }} dest=/usr/local/tomcat/webapps/ROOT/ copy=no mode=0755 owner=tomcat7 group=tomcat7 | |
| notify: | |
| - restart tomcat7 | |
| - name: Delete remote war file | |
| file: path={{ warRemotePath }}/{{ warName }} state=absent | |
| - name: wait for tomcat to start | |
| wait_for: port=8080 timeout=60 | |
| handlers: | |
| - name: Restart tomcat7 | |
| service: name=tomcat7 state=restarted |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment