first commit

This commit is contained in:
2021-08-28 23:54:41 +08:00
commit 06f4bf327a
55 changed files with 650 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
---
task: none
app: none
root_dir: /tomcat

View File

@@ -0,0 +1,3 @@
---
- import_tasks: "{{task|lower}}.yml"

View File

@@ -0,0 +1,4 @@
---
- debug:
msg: "nothing to do ..."

View 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

View 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

View 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

View 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

View 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

View 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