aboutsummaryrefslogtreecommitdiff
path: root/roles/nginx/tasks/main.yml
diff options
context:
space:
mode:
authorMiguel Dalberto Pedro <miguel.pedro@precisioninno.com>2026-10-29 12:48:06 -0300
committerMiguel Dalberto Pedro <miguel.pedro@precisioninno.com>2026-10-29 12:48:06 -0300
commit4b7379914a1865f07b2c54252234cc90158fc253 (patch)
treea476c7e08bb994034d7d04b5b1cdfce216f49c43 /roles/nginx/tasks/main.yml
downloadmy-infra-4b7379914a1865f07b2c54252234cc90158fc253.tar.gz
my-infra-4b7379914a1865f07b2c54252234cc90158fc253.zip
feat(iac): establish Ansible baseline for Nginx, SearXNG, Valkey, and Certbot
- Reverse-engineer live Debian 13 (trixie) VPS state at miguelpedro.xyz.br - Add modular Ansible roles: common, certbot, valkey, searxng, and nginx - Encrypt SearXNG secret_key using ansible-vault in group_vars/all/vault.yml - Cleanly remove unused example.com Nginx stub symlink (sites-enabled/miguelpedro.xyz.br) - Scaffold cgit + fcgiwrap role (cgit_enabled: false) for upcoming deployment - Add DISCOVERY_REPORT.md, COMMAND_LOG.md, README.md, and AGENT_INSTRUCTIONS.md with Self-Updating Protocol
Diffstat (limited to 'roles/nginx/tasks/main.yml')
-rw-r--r--roles/nginx/tasks/main.yml87
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