Ansible-playbook批量部署,更新war脚本,可以再完善----后续再update

- name: install tomcat admin
hosts: all
sudo: True
vars:
war_file: /root/test.war
tomcat_root: /datas/tomcat/webapps/test
tasks:
- name: 1 stop tomcat.
action: shell nohup {{ tomcat_root }}/../../bin/shutdown.sh
- name: 2 bakconfig.sh 3ge /datas/scritps/bakconfig/
shell: /datas/scritps/bakconfig/bakconfig.sh
- name: 3 rm rf test.
file:
state: absent
dest: "{{ tomcat_root }}"
- name: 4 rm rf test.war
file:
state: absent
dest: "/datas/tomcat/webapps/test.war"
- name: 5 from 23/root/war copy to /datas/soft/tomcat/webapps.
copy:
src: "{{ war_file }}"
dest: "/datas/tomcat/webapps/"
- name: 6 waitting copy war.
shell: sleep 15
- name: 7 start tomcat.
action: shell nohup /datas/tomcat/bin/startup.sh
- name: 8 waitting webapps/test.
shell: sleep 1
- name: 9 stop tomcat.
action: shell nohup {{ tomcat_root }}/../../bin/shutdown.sh
- name: 10 bakconfig2.sh 2ge wenjian
shell: /datas/scritps/bakconfig/bakconfig2.sh
- name: 11 start tomcat.
action: shell nohup {{ tomcat_root }}/../../bin/startup.sh

时间和保存文件可以根据自己具体要求再修改

 

转载于:https://www.cnblogs.com/pyoyw/p/5844310.html

你可能感兴趣的:(Ansible-playbook批量部署,更新war脚本,可以再完善----后续再update)