web-nginx.yml 1.32 KB
---
- hosts: web-nginx
  remote_user: root
  vars_prompt:
    - name: "confirmation"
      prompt: "Sync and reload java nginx. Please Enter [YES] to continue"
      private: no
  vars:
    - path: /usr/local/openresty

  tasks:
    # make sure path exist
    - name: "make sure path exist"
      shell: ls /usr/local/openresty
      ignore_errors: True
      register: result

    - name: "make sure openresty path exist"
      fail:
        msg: " openresty {{ path }} not exist!"
      when:  result is failed
  
    #  make sure group exists
    - name: make sure groups exist in inventory file
      fail:
        msg: "group {{ item }} not exist!"
      when: item not in groups
      with_items:
        - web-nginx
    - name: copy statics files to openresty
      copy:
        src: 'templates/web-nginx/node/yohobuywap-node/current/yohobuywap-node/public/static/'
        dest: "/Data/node/yohobuywap-node/current/yohobuywap-node/public/static/"

    - name: copy vhosts conf files to openresty
      template:
        src: web-nginx/vhosts/activity.yohocn.conf
        dest: "{{ path }}/nginx/conf/vhosts/"

    - name: update nginx upstream for nginx.conf
      template:
        src: web-nginx/nginx.conf
        dest: "{{ path }}/nginx/conf/nginx.conf"

    - name: reload nginx
      command: "{{ path }}/nginx/sbin/nginx -s reload"