Ease caddy stack variable setup

This commit is contained in:
Marty Oehme 2021-07-30 23:25:47 +02:00
parent 241ce71f46
commit bebdf72b19
Signed by: Marty
GPG key ID: B7538B8F50A1C800
2 changed files with 19 additions and 10 deletions

View file

@ -21,26 +21,26 @@
- name: Deploy caddy to swarm
community.general.docker_stack:
name: "{{ item.name }}"
name: "{{ caddy_stack.name }}"
state: present
prune: yes
compose:
- "{{ item.compose }}"
with_items: "{{ caddy_stack }}"
- "{{ caddy_stack.compose }}"
when: caddy_stack is defined
become: yes
tags:
- docker-swarm
- name: Register caddy container id
- name: Get caddy container info
ansible.builtin.command:
cmd: docker ps -q -f name={{ item.name }}
with_items: "{{ caddy_stack }}"
cmd: docker ps -q -f name={{ caddy_stack.name }}
become: yes
# bringing up the container takes some time, we have to wait
until: caddy_container_info['rc'] == 0 and caddy_container_info['stdout'] | length >= 1
register: caddy_container_info
- name: Set fact
ansible.builtin.set_fact: caddy_container_id={{ caddy_container_info.results[0].stdout }}
- name: Register caddy container id
ansible.builtin.set_fact: caddy_container_id={{ caddy_container_info['stdout'] }}
notify:
- debug caddy container
@ -52,6 +52,15 @@
apk add curl
become: yes
- name: Ensure caddy api is responsive
community.docker.docker_container_exec:
container: "{{ caddy_container_id }}"
command: >
curl localhost:2019/config/
until: result.rc == 0
register: result
become: yes
# TODO FIXME UP
# - name: Allow access to services
# firewalld: