Ensure stacks can inject their upstream to caddy

Created bind volume for caddy which takes the json fragments which will
later be injected through the caddy api to dynamically set their
individual reverse proxy addresses.

This is not entirely necessary if the injection should be done as a
variable instead, but makes it easier to change routes and especially
more complicated ones (I'm thinking of gitea with ssh access e.g.).
This commit is contained in:
Marty Oehme 2021-07-30 11:10:05 +02:00
parent fbf930054f
commit 95832941c0
Signed by: Marty
GPG key ID: B7538B8F50A1C800
2 changed files with 34 additions and 0 deletions

View file

@ -31,3 +31,36 @@
become: yes become: yes
tags: tags:
- docker-swarm - docker-swarm
- name: Register caddy container id
ansible.builtin.command:
cmd: docker ps -q -f name={{ item.name }}
with_items: "{{ caddy_stack }}"
become: yes
register: caddy_container_info
- name: Set fact
ansible.builtin.set_fact: caddy_container_id={{ caddy_container_info.results[0].stdout }}
notify:
- debug caddy container
# FIXME this should be taken care of in Dockerfile not here
- name: Ensure caddy curl available
community.docker.docker_container_exec:
container: "{{ caddy_container_id }}"
command: >
apk add curl
become: yes
# TODO FIXME UP
# - name: Allow access to services
# firewalld:
# service: "{{ item }}"
# permanent: true
# state: enabled
# with_items:
# - http
# - https
# become: true
# tags:
# - firewall

View file

@ -8,6 +8,7 @@ services:
- "443:443" - "443:443"
volumes: volumes:
- "{{ caddy_caddyfile_dir }}:/etc/caddy" - "{{ caddy_caddyfile_dir }}:/etc/caddy"
- "{{ docker_stack_files_dir }}:/stacks:ro"
- data:/data - data:/data
- config:/config - config:/config
networks: networks: