ansible-nginx/tasks/config.yml

58 lines
1.6 KiB
YAML

---
- name: TEMPLATE | Deploy nginx.conf
ansible.builtin.template:
src: "etc/nginx/nginx.conf.j2"
dest: "{{ nginx_etc_dir }}/nginx.conf"
mode: 0644
owner: root
group: root
notify: Reload nginx
- name: TEMPLATE | Deploy all helpers
ansible.builtin.template:
src: "{{ item }}"
dest: "{{ nginx_helper_dir }}/{{ item | basename | regex_replace('.j2$', '') }}"
mode: 0644
owner: root
group: root
with_fileglob: '../templates/etc/nginx/helper/*.j2'
notify: Reload nginx
- name: TEMPLATE | Deploy custom http configuration
ansible.builtin.template:
src: "etc/nginx/conf.d/custom.conf.j2"
dest: "{{ nginx_etc_dir }}/conf.d/custom.conf"
mode: 0644
owner: root
group: root
notify: Reload nginx
- name: LINEINFILE | Fix path
ansible.builtin.lineinfile:
regexp: '{{ item.0.regexp }}'
line: '{{ item.0.line }}'
dest: '{{ item.1 }}'
loop: "{{ list_one | product(list_two) | list }}"
vars:
list_one:
- regexp: '^fastcgi_param SCRIPT_FILENAME'
line: 'fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;'
- regexp: '^fastcgi_param DOCUMENT_ROOT'
line: 'fastcgi_param DOCUMENT_ROOT $realpath_root;'
list_two:
- '{{ nginx_etc_dir }}/fastcgi.conf'
when: nginx_fastcgi_fix_realpath
- name: COPY | Add modules manually
ansible.builtin.copy:
content: |
{% for m in nginx_load_modules %}
load_module {{ m }};
{% endfor %}
dest: "{{ nginx_etc_dir }}/modules-enabled/000-modules.conf"
mode: 0644
owner: root
group: root
notify: Reload nginx