Separate caddy container id grabbing into own role

Since other roles often rely on this not an actual new caddy server
installation we should probably have it as its own little role.
This commit is contained in:
Marty Oehme 2023-12-08 20:35:51 +01:00
parent a52cab2f61
commit 388a1d8cfc
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
8 changed files with 246 additions and 41 deletions

View file

@ -5,9 +5,9 @@
ansible.builtin.file:
path: "{{ caddy_caddyfile_dir }}"
state: directory
mode: '0755'
mode: "0755"
become: true
tags:
tags:
- fs
- name: Ensure Caddyfile exists
@ -30,44 +30,6 @@
become: true
tags:
- docker-swarm
- name: Get caddy container info
ansible.builtin.command:
cmd: docker ps -q -f name={{ caddy_stack.name }}
become: true
# bringing up the container takes some time, we have to wait
until: caddy_container_info['rc'] == 0 and caddy_container_info['stdout'] | length >= 1
retries: 5
delay: 10
changed_when: False
register: caddy_container_info
- name: Register caddy container id
ansible.builtin.set_fact: caddy_container_id={{ caddy_container_info['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: true
register: result
changed_when: "'Installing' in result.stdout"
- name: Ensure caddy api is responsive
community.docker.docker_container_exec:
container: "{{ caddy_container_id }}"
command: >
curl localhost:2019/config/
become: true
until: result.rc == 0
when: caddy_use_api == True
changed_when: False
register: result
# TODO FIXME UP
# - name: Allow access to services
# firewalld: