zoukankan      html  css  js  c++  java
  • ansible-playbook 单个yml文件部署tomcat简单示例

    #单yaml配置
    [root@jenkins pb]# cat tomcat.yml --- - hosts: eee vars:                                           #设置变量 war_files: /var/lib/jenkins/workspace/java_test/target/huizhongph.war    #本地war包路径 tomcat_root: /root/tomcat_hzph_pc_9090/webapps/huizhongph           #远端tomcat目录 tasks: - name: 关闭tomcat shell: chdir={{ tomcat_root }}/../../bin nohup ./shutdown.sh & - name: backup old code                            #备份当前正在使用的源码 shell: chdir={{ tomcat_root }}/../ tar -czf /bak/huizhongph_$(date -d "today" +"%Y%m%d_%H%M%S").tar.gz huizhongph & - name: 删除旧版本的配置文件 file: state: absent dest: "{{ tomcat_root }}" - name: clean cache|清除缓存 shell: chdir={{ tomcat_root }}/../../ nohup rm -rf work & - name: 创建目录 file: state: directory dest: "{{ tomcat_root }}" mode: 755 - name: 解压war包 unarchive: src: "{{ war_files }}" dest: "{{ tomcat_root }}" copy: yes - name: 覆盖(替换)配置文件 copy: src=/root/{{ item }} dest=/root/test/{{ item }}    #这里指定配置文件的路径为本地路径 with_items:                              #要替换的配置文件 - a.txt - b.txt - c.txt - d.txt - shell (目录) - name: 启动tomcat shell: chdir={{ tomcat_root }}/../../bin nohup ./startup.sh &

    执行命令

    ansible-playbook -i /xxx/xxx/host tomcat.yml

     回滚操作目前还没有确定用哪种,暂时没贴

  • 相关阅读:
    angular笔记_6
    angular笔记_5(全选/反选)
    angular笔记_4(函数)
    angular笔记_3
    angular笔记_2
    常用Sql语句
    IIS服务器环境下某路径下所有PHP接口无法运行报500.19错误
    #前端#文字、图像等元素居中方式之
    nginx如何设置禁止访问文件或文件夹
    git克隆和上传项目
  • 原文地址:https://www.cnblogs.com/FRESHMANS/p/8304279.html
Copyright © 2011-2022 走看看