码迷,mamicode.com
首页 > 其他好文 > 详细

使用ansible-playbook实现自动打包上线

时间:2017-02-16 11:57:16      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:ansible

- hosts: ceshi

  remote_user: root

  tasks:

  - name: "192.168.55.14主机打包cms线上环境的war包"

    script: /data/script/build_xianshang_cms.sh


  - name: "从192.168.55.14拷贝war包到jenkins上"

    fetch:

      src=/buildwar/xianshang/cms/cms.war

      dest=/var/www/html/deploy/packages/cms/

  

- hosts: xianshang_01:xianshang_02

  remote_user: root

  tasks:

  - name: "从jenkins上传输到(xianshang_01),(xianshang_02)"

    copy:

      src=/var/www/html/deploy/packages/cms/192.168.55.14/buildwar/xianshang/cms/cms.war

      dest=/data/cms/war/cms.war


  - name: "得到cms进程号"

    shell: APP_PID=$(ps -ef|grep cms|grep ‘java‘|awk ‘{print $2}‘)

  - name: "杀掉cms进程"

    shell: kill $APP_PID 

  - name: "进入cms的bak目录"

    shell: cd /data/cms/bak

  - name: "移动cms文件夹到/tmp目录下"

    shell: mv cms /tmp/

  - name: "进入cms的webapps目录"

    shell: cd /data/cms/webapps/

  - name: "移动cms文件夹到/data/cms/bak备份"

    shell: mv cms /data/cms/bak/

  - name: "移动cms.war包到/tmp目录下"

    shell: mv cms.war /tmp/

  - name: "进入/data/cms/war 线上包目录"

    shell: cd /data/cms/war/

  - name: "将cms.war包移动到/data/cms/wepapps"

    shell: mv cms.war /data/cms/webapps/

  - name: "进入/data/cms/bin"

    shell: cd /data/cms/bin

  - name: "启动cms工程"

    shell: bash startup.sh

  


使用ansible-playbook实现自动打包上线

标签:ansible

原文地址:http://725689.blog.51cto.com/715689/1898297

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!