nginx: refactor role

This commit is contained in:
2024-04-14 17:53:26 -05:00
parent 7ca9b6dc8c
commit cb60bcb5f8
3 changed files with 66 additions and 27 deletions

View File

@ -44,6 +44,19 @@
mode: 0644
notify: reload nginx
- name: configure htpasswd files
ansible.builtin.copy:
dest: "{{ nginx_etc_path }}/{{ item.key }}.htpasswd"
owner: root
group: nginx
mode: 0640
content: |
{% for u, h in item.value.items() %}
{{ u }}:{{ h }}
{% endfor %}
loop: "{{ nginx_htpasswd_files | dict2items }}"
notify: reload nginx
- name: configure virtual hosts
ansible.builtin.include_tasks: vhost.yaml
loop: "{{ nginx_vhosts | dict2items }}"
@ -52,4 +65,4 @@
service:
name: "{{ nginx_service_name }}"
state: "{{ nginx_service_state }}"
enabled: "{{ nginx_service_enabled }}"
enabled: "{{ nginx_service_enabled }}"

View File

@ -3,11 +3,11 @@
block:
- name: create webroot
file:
path: "{{ vhost.root }}"
path: "{{ server.root }}"
state: directory
loop: "{{ item.value }}"
loop: "{{ item.value.server }}"
loop_control:
loop_var: vhost
loop_var: server
- name: configure virtual host
template: