Files
deploy_home/ansible/roles/http/tasks/http.yml
2022-04-12 01:43:26 -04:00

89 lines
2.0 KiB
YAML

---
- name: setup nginx base configuration
become: true
ansible.builtin.copy:
src: files/nginx/nginx.conf
dest: /etc/nginx/nginx.conf
mode: 0644
notify: restart_nginx
tags: http
- name: setup nginx directories
become: true
ansible.builtin.file:
path: "/etc/nginx/{{ item }}"
state: directory
mode: 0755
loop:
- sites-enabled
- sites-available
tags: http
- name: ensure http and letsencrypt directories exist
become: true
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: http
group: http
mode: 0644
loop:
- /srv/http
- /srv/http/letsencrypt
tags: http
- name: chown http user home
become: true
ansible.builtin.file:
path: /srv/http
owner: http
group: http
mode: 0644
recurse: true
tags: http
- name: template nginx http sites-available
become: true
ansible.builtin.template:
src: "templates/nginx/sites/{{ item }}.j2"
dest: "/etc/nginx/sites-available/{{ item }}"
mode: 0644
loop:
- "{{ ci_server_name }}.http.conf"
- "{{ pi_server_name }}.conf"
- "{{ home_server_name }}.conf"
- "{{ assistant_server_name }}.conf"
- "{{ video_server_name }}.conf"
- "{{ parts_server_name }}.conf"
notify: restart_nginx
tags: http
- name: remove pihole from sites-enabled if there
become: true
ansible.builtin.file:
path: "/etc/nginx/sites-enabled/pi.hole.conf"
state: absent
tags: http
- name: enable desired nginx http sites
become: true
ansible.builtin.file:
src: "/etc/nginx/sites-available/{{ item }}"
dest: "/etc/nginx/sites-enabled/{{ item }}"
state: link
loop:
- "{{ ci_server_name }}.http.conf"
- "{{ pi_server_name }}.conf"
- "{{ parts_server_name }}.conf"
- "{{ home_server_name }}.conf"
- "{{ assistant_server_name }}.conf"
- "{{ video_server_name }}.conf"
notify: restart_nginx
tags: http
- name: validate nginx configurations
become: true
ansible.builtin.command: nginx -t
changed_when: false
tags: http