Track the nginx-menu playbook as it stands

It has been serving three menu Sites from an untracked directory, so today's
state was not reproducible or revertible.
This commit is contained in:
tanshu committed 2026-09-22 21:27:13 +05:30
1 parent b7c5997274
commit e54dd127ed
8 files changed
+162

No files matched your search

@@ -0,0 +1,5 @@
---
# Handlers for Caddy role
- name: Reload Caddy configuration
ansible.builtin.command: "docker exec -w /etc/caddy {{ caddy_container }} caddy reload"
listen: "Reload Caddy"
+22
View File
@@ -0,0 +1,22 @@
---
- name: Read current Caddyfile
ansible.builtin.slurp:
path: "{{ caddyfile_path }}"
register: caddyfile_raw
- name: Decode Caddyfile content
set_fact:
caddyfile_content: "{{ caddyfile_raw['content'] | b64decode }}"
- name: Check if snippet already exists
set_fact:
snippet_present: "{{ snippet_block in caddyfile_content }}"
- name: Add snippet if missing
ansible.builtin.blockinfile:
path: "{{ caddyfile_path }}"
marker: "# {mark} Ansible managed Caddy snippet for {{ host }}"
block: "{{ snippet_block }}"
create: yes
when: not snippet_present
notify: "Reload Caddy"
+8
View File
@@ -0,0 +1,8 @@
---
- name: "Ensure {{ docker_container }} Docker network exists"
docker_network:
name: "{{ docker_network }}"
state: present
connected:
- "{{ caddy_container }}"
appends: yes
+30
View File
@@ -0,0 +1,30 @@
---
# Tasks for Nginx role to serve static files
- name: Pull Nginx image
docker_image:
name: "{{ image_name }}"
source: pull
force_source: yes
- name: Ensure Host Directory exist
file:
path: "{{ host_directory }}"
state: directory
mode: 0755
# - name: Upload the Nginx config file
# template:
# src: "files/nginx.conf.j2"
# dest: "{{ host_directory }}/nginx.conf"
- name: Create caddy container
docker_container:
name: "{{ docker_container }}"
image: "{{ image_name }}"
state: started
restart_policy: unless-stopped
volumes:
# - "{{ host_directory }}/nginx.conf:/etc/nginx/nginx.conf:ro"
- "{{ host_directory }}:/usr/share/nginx/html:ro"
networks:
- name: "{{ docker_network }}"