main.yml 1.37 KB
---
# tasks file for openresty


# make sure user type YES
- name: "make sure user type YES to confirm"
  fail: 
    msg: "user do not type YES"
  when: confirmation != 'YES'

# make sure user www exist
- name: "make sure user www exist"
  user:
    name: www

# make sure log path exist
- name: "make sure log path exist"
  file:
    path: /Data/logs/nginx/
    state: directory
    mode: 0755
    owner: www
    group: www

# make sure path exist
- stat:
    path:  "{{ path }}"
  register: stat_result
- name: "make sure openresty path exist" 
  fail:
    msg: " openresty {{ path }} not exist!"
  when:  stat_result.stat.exists == False



#  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:
    - nameservers
    - ufo-nginx
    - java-ufo-fore
    - java-ufo-platform


- name: copy ufo api conf files to openresty
  template:
    src: vhosts/api.ufo.conf
    dest: "{{ path }}/nginx/conf/vhosts/api.ufo.conf"
  notify:
    - reload nginx

- name: copy ufo admin conf files to openresty
  template:
    src: vhosts/platform.ufo.conf.j2
    dest: "{{ path }}/nginx/conf/vhosts/platform.ufo.conf"
  notify:
    - reload nginx

- name: update nginx upstream for file -nginx.conf
  template:
    src: nginx.conf.j2
    dest: "{{ path }}/nginx/conf/nginx.conf"
  notify:
    - reload nginx