IOT Playbook updated with docker networks and caddy.

This commit is contained in:
tanshu committed 2025-07-09 01:16:10 +00:00
1 parent 7c2a66540f
commit 3ff953acdb
13 files changed
+73 -62

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
caddy_container: caddy
caddyfile_path: /var/lib/caddy/conf/Caddyfile
snippet_block: |
{{ host }} {
reverse_proxy {{ grafana_container }}:3000
}
+7
View File
@@ -0,0 +1,7 @@
---
# Handlers for Nginx role
- name: Restart caddy container
docker_container:
name: "{{ caddy_container }}"
state: started
restart: true
+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: Restart caddy container