ansible/roles/nginx/tasks/main.yml

68 lines
1.7 KiB
YAML
Raw Permalink Normal View History

2019-10-27 23:32:25 +00:00
---
2020-09-21 03:44:45 +00:00
- name: gather os specific variables
2022-08-31 03:19:06 +00:00
ansible.builtin.include_vars: "{{ lookup('first_found', params) }}"
2020-09-21 03:44:45 +00:00
vars:
2022-08-31 03:19:06 +00:00
params:
2020-09-21 03:44:45 +00:00
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- vars
- name: include os specific tasks
2022-08-31 03:19:06 +00:00
ansible.builtin.include_tasks: "{{ lookup('first_found', params) }}"
2020-09-21 03:44:45 +00:00
vars:
2022-08-31 03:19:06 +00:00
params:
2020-09-21 03:44:45 +00:00
files:
- "{{ ansible_distribution }}-{{ ansible_distribution_version }}.yaml"
- "{{ ansible_distribution }}.yaml"
- "{{ ansible_os_family }}.yaml"
- "default.yaml"
paths:
- tasks
2019-10-27 23:32:25 +00:00
- name: install passlib
package:
name: "{{ item }}"
state: present
loop:
- python3-passlib
- name: install package
package:
name: "{{ nginx_package_name }}"
state: "{{ nginx_package_state }}"
2020-09-21 03:44:45 +00:00
- name: configure nginx
template:
2020-09-21 03:44:45 +00:00
src: nginx.conf.j2
dest: "{{ nginx_etc_path }}/nginx.conf"
owner: root
group: root
mode: 0644
notify: reload nginx
2024-04-14 22:53:26 +00:00
- 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
2022-08-30 11:54:38 +00:00
- name: configure virtual hosts
2022-08-31 03:19:06 +00:00
ansible.builtin.include_tasks: vhost.yaml
2022-08-30 11:54:38 +00:00
loop: "{{ nginx_vhosts | dict2items }}"
2019-10-27 23:32:25 +00:00
- name: manage service
service:
name: "{{ nginx_service_name }}"
state: "{{ nginx_service_state }}"
2024-04-14 22:53:26 +00:00
enabled: "{{ nginx_service_enabled }}"