ansible-collection-kit/roles/nginx_config/tasks/main.yml
2026-05-25 02:02:16 +02:00

50 lines
1.6 KiB
YAML

---
- name: Add and enable sites.
become: "{{ nginx_config_become }}"
become_user: "{{ nginx_config_become_user }}"
block:
- name: Add nginx config file {{ item.path }}
ansible.builtin.copy:
content: "{{ item.content }}"
dest: "{{ item.path }}"
owner: root
group: root
mode: "0640"
loop: "{{ nginx_config_files }}"
notify: systemctl reload nginx
- name: Create nginx site directory {{ item.name }}
ansible.builtin.file:
path: "{{ nginx_config_root }}/{{ item.name }}"
state: directory
owner: root
group: www-data
mode: "0755"
loop: "{{ nginx_config_sites }}"
- name: Create nginx site log directory {{ item.name }}
ansible.builtin.file:
path: "{{ nginx_config_root }}/{{ item.name }}/logs"
state: directory
owner: root
group: www-data
mode: "0755"
loop: "{{ nginx_config_sites }}"
- name: Add nginx site configuration {{ item.name }}
ansible.builtin.copy:
content: "{{ item.content }}"
dest: "{{ nginx_config_sites_available_dir }}/{{ item.name }}.vhost"
owner: root
group: root
mode: "0640"
loop: "{{ nginx_config_sites }}"
notify: systemctl reload nginx
- name: Enable nginx site configuration {{ item.name }}
ansible.builtin.file:
src: "{{ nginx_config_sites_available_dir }}/{{ item.name }}.vhost"
dest: "{{ nginx_config_sites_enabled_dir }}/{{ item.name }}.vhost"
state: link
loop: "{{ nginx_config_sites }}"
notify: systemctl reload nginx