#单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

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

相关文章:

  • 2021-12-02
  • 2021-07-19
  • 2021-06-23
  • 2021-07-06
  • 2021-09-20
  • 2021-11-20
  • 2022-12-23
  • 2021-06-10
猜你喜欢
  • 2022-02-05
  • 2022-01-07
  • 2022-02-25
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2021-07-14
相关资源
相似解决方案