Updated nextcloud to use docker network and caddy

This commit is contained in:
tanshu committed 2026-02-27 08:17:18 +00:00
1 parent 5b8d77c839
commit b727fa7c00
12 files changed
+61 -313

No files matched your search

+5
View File
@@ -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"
+11
View File
@@ -0,0 +1,11 @@
---
- name: "Ensure {{ container_name }} Docker network exists"
docker_network:
name: "{{ docker_network }}"
state: present
connected:
- "{{ caddy_container }}"
- "{{ postgres_container }}"
- name: "{{ redis_container }}"
alias: redis
appends: yes
+2 -5
View File
@@ -24,11 +24,8 @@
POSTGRES_PASSWORD: "{{ db_pass }}"
POSTGRES_HOST: "{{ db_host }}"
REDIS_HOST: "redis"
links:
- "postgres:db"
- "redis:redis"
published_ports:
- "127.0.0.1:9000:9000"
networks:
- name: "{{ docker_network }}"
volumes:
- "/var/lib/{{ host_directory }}:/var/www/html"
-6
View File
@@ -1,6 +0,0 @@
---
# Handlers for Nginx role
- name: Reload Nginx
service:
name: nginx
state: reloaded
-24
View File
@@ -1,24 +0,0 @@
---
# Tasks for Nginx role
- name: Check if Nginx conf file exists
stat:
path: "/etc/nginx/sites-available/{{ http_conf }}"
register: status
- name: No need to reload Nginx
debug:
msg: "No need to reload Nginx as sites-available entries have already been created"
- name: Set Nginx conf file
when: status.stat.exists == false
template:
src: "files/nginx.conf.j2"
dest: "/etc/nginx/sites-available/{{ http_conf }}"
- name: Enable new site
when: status.stat.exists == false
file:
src: "/etc/nginx/sites-available/{{ http_conf }}"
dest: "/etc/nginx/sites-enabled/{{ http_conf }}"
state: link
notify: Reload Nginx
-28
View File
@@ -1,28 +0,0 @@
---
# Tasks for Nextcloud webserver role
- name: Copy dockerfile
synchronize: src=web dest=/tmp
- name: Build nginx webserver image
docker_image:
name: "{{ web_container_image }}"
build:
path: /tmp/web/
dockerfile: /tmp/web/Dockerfile
pull: yes
state: present
source: build
force_source: yes
- name: Create webserver container
docker_container:
name: "{{ web_container_name }}"
image: "{{ web_container_image }}"
state: started
restart_policy: "unless-stopped"
links:
- "{{ container_name }}:app"
published_ports:
- "127.0.0.1:9080:80"
volumes:
- "/var/lib/{{ host_directory }}:/var/www/html:ro"