first commit
This commit is contained in:
5
roles/tomcat/defaults/main.yml
Normal file
5
roles/tomcat/defaults/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
task: none
|
||||
app: none
|
||||
root_dir: /tomcat
|
||||
|
3
roles/tomcat/tasks/main.yml
Normal file
3
roles/tomcat/tasks/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
- import_tasks: "{{task|lower}}.yml"
|
||||
|
4
roles/tomcat/tasks/restart_service.yml
Normal file
4
roles/tomcat/tasks/restart_service.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
- debug:
|
||||
msg: "nothing to do ..."
|
||||
|
9
roles/tomcat/tasks/revert_war.yml
Normal file
9
roles/tomcat/tasks/revert_war.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: check whether {{app}}.war.bak exists
|
||||
shell: cd {{root_dir}}/webapps/ && [ -f {{app}}.war.bak ]
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: revert {{app}}.war.bak
|
||||
when: result is succeeded
|
||||
shell: cd {{root_dir}}/webapps/ && rm -rf {{app}}.war {{app}} && mv {{app}}.war.bak {{app}}.war
|
||||
|
9
roles/tomcat/tasks/revert_zip.yml
Normal file
9
roles/tomcat/tasks/revert_zip.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: check whether {{app}}_backup.tgz exists
|
||||
shell: cd {{root_dir}}/webapps/ && [ -f {{app}}_backup.tgz ]
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: revert {{app}}_backup.tgz
|
||||
when: result is succeeded
|
||||
shell: cd {{root_dir}}/webapps/ && rm -rf {{app}} && tar zxf {{app}}_backup.tgz && rm -f {{app}}_backup.tgz
|
||||
|
8
roles/tomcat/tasks/start_service.yml
Normal file
8
roles/tomcat/tasks/start_service.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: start tomcat
|
||||
service: name=tomcat state=started
|
||||
- name: wait for tomcat to start completely
|
||||
shell: while sleep 2; do grep -m 1 'Server startup in [0-9]\+ ms$' {{root_dir}}/logs/catalina.out && break; done
|
||||
- name: link /dev/null to catalina.out
|
||||
shell: cd {{root_dir}}/logs/ && rm -f catalina.out && ln -sf /dev/null catalina.out
|
||||
|
8
roles/tomcat/tasks/stop_service.yml
Normal file
8
roles/tomcat/tasks/stop_service.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
- name: wait 4s to free tomcat connections
|
||||
shell: sleep 4
|
||||
- name: stop tomcat
|
||||
service: name=tomcat state=stopped
|
||||
- name: clean catalina.out
|
||||
shell: cd {{root_dir}}/logs/ && rm -f catalina.out && touch catalina.out
|
||||
|
15
roles/tomcat/tasks/update_war.yml
Normal file
15
roles/tomcat/tasks/update_war.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: upload {{app}}.zip
|
||||
copy: src=/var/transfer/{{app}}.zip dest={{root_dir}}/webapps/{{app}}.zip
|
||||
- name: check whether {{app}}.war exists
|
||||
shell: cd {{root_dir}}/webapps/ && [ -f {{app}}.war ]
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: remove old {{app}}.war.bak
|
||||
shell: cd {{root_dir}}/webapps/ && rm -rf {{app}}.war.bak {{app}}
|
||||
- name: create current {{app}}.war.bak
|
||||
when: result is succeeded
|
||||
shell: cd {{root_dir}}/webapps/ && mv {{app}}.war {{app}}.war.bak
|
||||
- name: unzip new {{app}}.zip
|
||||
shell: cd {{root_dir}}/webapps/ && unzip -o -qq {{app}}.zip && rm -f {{app}}.zip
|
||||
|
15
roles/tomcat/tasks/update_zip.yml
Normal file
15
roles/tomcat/tasks/update_zip.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
---
|
||||
- name: upload {{app}}.zip
|
||||
copy: src=/var/transfer/{{app}}.zip dest={{root_dir}}/webapps/{{app}}.zip
|
||||
- name: check whether {{app}} exists
|
||||
shell: cd {{root_dir}}/webapps/ && [ -d {{app}} ]
|
||||
ignore_errors: true
|
||||
register: result
|
||||
- name: remove old {{app}}_backup.tgz
|
||||
shell: cd {{root_dir}}/webapps/ && rm -rf {{app}}_backup.tgz
|
||||
- name: create current {{app}}_backup.tgz
|
||||
when: result is succeeded
|
||||
shell: cd {{root_dir}}/webapps/ && tar zcf {{app}}_backup.tgz {{app}}/
|
||||
- name: unzip new {{app}}.zip
|
||||
shell: cd {{root_dir}}/webapps/ && unzip -o -qq {{app}}.zip && rm -f {{app}}.zip
|
||||
|
Reference in New Issue
Block a user