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

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

  • 相关阅读:
    Java补漏(一)
    PHP实现程序单例执行
    zabbix 配置外部邮件server发送邮件报警
    HTML+JavaScript实现链式运动特效
    对思归者的建议
    去除Notepad++打开文件后文字下面出现红色波浪线的问题
    ANSI是什么?
    Eclipse各版本代号一览表以及官网上有很多版本的eclipse,下载哪个版本比较合适呢?
    Java语言的发展史
    win10 64位JLink v8固件丢失修复总结
  • 原文地址:https://www.cnblogs.com/FRESHMANS/p/8304279.html
Copyright © 2011-2022 走看看