侧边栏壁纸
博主头像
爱运维 博主等级

行动起来,活在当下

  • 累计撰写 197 篇文章
  • 累计创建 143 个标签
  • 累计收到 21 条评论

目 录CONTENT

文章目录

ansible playbook之Tomcat上线脚本

Administrator
2017-08-14 / 0 评论 / 0 点赞 / 1 阅读 / 0 字

说明:

tomcat_home:tomcat安装目录

bak_home:备份Tomcat目录

war_name:war包名字,后面不要加.war



- hosts: pay
  vars:
    tomcat_home: /usr/local/apache-tomcat
    bak_home: /var/storages/bak
    war_name: pay
  remote_user: root
  tasks:
    - name: backup  {{ war_name }}.war to {{ bak_home }}
      shell: cp -pr {{ tomcat_home }}/webapps/{{ war_name }}.war /var/storages/bak/{{ war_name }}-`date +%F-%H-%M`.war
    - name: stop tomcat
      shell: ps -ef | grep {{ tomcat_home }} | grep -v grep | awk '{print $2}'| xargs kill -9
      ignore_errors: yes
    - name: stop tomcat2
      shell: ps -ef | grep {{ tomcat_home }} | grep -v grep | awk '{print $2}'| xargs kill -9
      ignore_errors: yes
    - name: stop tomcat3
      shell: ps -ef | grep {{ tomcat_home }} | grep -v grep | awk '{print $2}'| xargs kill -9
      ignore_errors: yes
    - name: check tomcat
      shell: ps -ef | grep {{ tomcat_home }}
    - name: delete {{ tomcat_home }} {{ war_name }}
      shell: rm -rf {{ tomcat_home }}/webapps/{{ war_name }}*
      ignore_errors: yes
    - name: delete tomcat work dir
      shell: rm -f {{ tomcat_home }}/work/*
    - name: delete catalina.out
      shell: rm -f {{ tomcat_home }}/logs/catalina.out
      ignore_errors: yes
    - name: update {{ war_name }}.war to {{ tomcat_home }}
      copy: src=/tmp/{{ war_name }}.war dest={{ tomcat_home }}/webapps/{{ war_name }}.war
    - name: start tomcat
      shell: "source /etc/profile;nohup {{ tomcat_home }}/bin/startup.sh &"
    - name: check tomcat
      shell: ps -ef | grep {{ tomcat_home }}


0

评论区