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

行动起来,活在当下

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

目 录CONTENT

文章目录

ansible-playbook平滑升级nginx

Administrator
2018-03-29 / 0 评论 / 0 点赞 / 10 阅读 / 0 字
---
- hosts: "{{ hosts }}"
  vars:
    old_nginx_dir: /usr/local/nginx
    src: /usr/local/src
    version: nginx-1.12.2
  remote_user: root
  tasks:
    - name: yum install devel
      yum: name={{ item }} state=present
      with_items:
        - gcc
        - gcc-c++
        - wget
    - name: down {{ version }} and unzip
      shell: cd {{ src }}&&wget http://nginx.org/download/{{ version }}.tar.gz&&tar -xf {{ version }}.tar.gz
    - name: get old vars
      shell: "{{ old_nginx_dir }}/sbin/nginx -V 2>&1|grep  configure|cut -d : -f2"
      register: old_argv
    - name: install nginx 
      shell: cd {{ src }}/{{ version }}&&./configure {{ old_argv.stdout }}&&make
    - name: mv old nginx
      shell: mv -f {{ old_nginx_dir }}/sbin/nginx{,.bak}
    - name: copy nginx bin to new nginx bin
      shell: cp -a {{src}}/{{version}}/objs/nginx {{ old_nginx_dir }}/sbin/nginx
    - name: update process
      shell: cd {{src}}/{{version}}&&make upgrade
0

评论区