ansible-nginx/tasks/install_FreeBSD.yml

81 lines
2.0 KiB
YAML

---
- name: PKGNG | Install nginx and related tools
pkgng:
name: "{{ item }}"
state: present
with_items:
- acme.sh
- "{{ nginx_pkgng_package }}"
- py27-passlib
- curl
#
# Bypass https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224166#c1
#
- block:
- name: COMMAND | Create /usr/local/etc/fdfs/http.conf
command: touch /usr/local/etc/fdfs/http.conf
args:
creates: /usr/local/etc/fdfs/http.conf
register: fd1
- name: LINEINFILE | Tune fdfs
lineinfile:
regexp: ^load_fdfs_parameters_from_tracker
line: load_fdfs_parameters_from_tracker=false
path: /usr/local/etc/fdfs/mod_fastdfs.conf
register: fd2
- name: SERVICE | Restart nginx when fdfs is tuned
service:
name: nginx
state: restarted
when: fd1.changed or fd2.changed
when: true
- name: FILE | Create configuration dir (like Debian)
file:
path: "{{ nginx_etc_dir }}/{{ item }}"
state: directory
with_items:
- conf.d
- sites-available
- sites-enabled
- name: STAT | Check fastcgi.conf
stat:
path: "{{ nginx_etc_dir }}/fastcgi.conf"
register: conf
- name: COPY | config
command: "cp {{ nginx_etc_dir }}/fastcgi_params {{ nginx_etc_dir }}/fastcgi.conf"
when: not conf.stat.exists
notify: reload nginx
- name: LINEINFILE | Add fastcgi config
lineinfile:
line: "fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;"
dest: "{{ nginx_etc_dir }}/fastcgi.conf"
notify: reload nginx
- name: COPY | Populate proxy_params
copy:
content: "proxy_set_header Host $http_host;\nproxy_set_header X-Real-IP $remote_addr;\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;"
dest: "{{ nginx_etc_dir }}/proxy_params"
- name: FILE | Create log directory
file:
path: "{{ nginx_log_dir }}"
owner: "{{ nginx_user }}"
group: wheel
mode: 0755
state: directory
- name: SERVICE | Enable nginx
service:
name: nginx
enabled: yes