diff options
Diffstat (limited to 'roles/nginx/tasks/main.yml')
| -rw-r--r-- | roles/nginx/tasks/main.yml | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/roles/nginx/tasks/main.yml b/roles/nginx/tasks/main.yml new file mode 100644 index 0000000..c4f55b6 --- /dev/null +++ b/roles/nginx/tasks/main.yml @@ -0,0 +1,87 @@ +--- +- name: Ensure nginx is installed + ansible.builtin.apt: + name: + - nginx + state: present + +- name: Ensure Nginx directories exist + ansible.builtin.file: + path: "{{ item }}" + state: directory + owner: root + group: root + mode: "0755" + loop: + - /etc/nginx/sites-available + - /etc/nginx/sites-enabled + - /etc/nginx/default.apps-available + - /etc/nginx/default.d + - "{{ default_web_root }}" + +- name: Deploy /etc/nginx/nginx.conf + ansible.builtin.template: + src: nginx.conf.j2 + dest: /etc/nginx/nginx.conf + owner: root + group: root + mode: "0644" + validate: "/usr/sbin/nginx -t -c %s" + notify: Reload nginx + +- name: Deploy /etc/nginx/default.apps-available/searxng.conf + ansible.builtin.template: + src: default-app-searxng.conf.j2 + dest: /etc/nginx/default.apps-available/searxng.conf + owner: root + group: root + mode: "0644" + notify: Reload nginx + +- name: Enable /etc/nginx/default.d/searxng.conf symlink + ansible.builtin.file: + src: /etc/nginx/default.apps-available/searxng.conf + dest: /etc/nginx/default.d/searxng.conf + state: link + notify: Reload nginx + +- name: Deploy /etc/nginx/sites-available/default + ansible.builtin.template: + src: site-default.conf.j2 + dest: /etc/nginx/sites-available/default + owner: root + group: root + mode: "0644" + notify: Reload nginx + +- name: Deploy /etc/nginx/sites-available/searxng.conf + ansible.builtin.template: + src: site-searxng.conf.j2 + dest: /etc/nginx/sites-available/searxng.conf + owner: root + group: root + mode: "0644" + notify: Reload nginx + +- name: Enable active Nginx sites + ansible.builtin.file: + src: "/etc/nginx/sites-available/{{ item }}" + dest: "/etc/nginx/sites-enabled/{{ item }}" + state: link + loop: + - default + - searxng.conf + notify: Reload nginx + +- name: Remove unused/stub Nginx site symlinks (clean tracking) + ansible.builtin.file: + path: "/etc/nginx/sites-enabled/{{ item }}" + state: absent + loop: "{{ nginx_remove_unused_sites | default([]) }}" + notify: Reload nginx + +- name: Ensure nginx service is enabled and running + ansible.builtin.systemd: + name: nginx.service + enabled: true + state: started |
