Implement very naive solution

This commit is contained in:
Marty Oehme 2021-07-29 22:50:41 +02:00
parent 351e1202b2
commit 1b3c14b4ce
Signed by: Marty
GPG key ID: B7538B8F50A1C800
5 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,3 @@
---
whoami_version: latest

View file

@ -0,0 +1,6 @@
---
dependencies:
- docker
- docker-swarm
- caddy

View file

@ -0,0 +1,28 @@
---
# install whoami container
- name: Deploy whoami to swarm
community.general.docker_stack:
name: "{{ item.name }}"
state: present
prune: yes
compose:
- "{{ item.compose }}"
with_items: "{{ whoami_stack }}"
when: whoami_stack is defined
become: yes
tags:
- docker-swarm
- name: Get caddy container id
ansible.builtin.command:
cmd: docker ps -q -f name=caddy_app
register: caddy_container_id
become: yes
- name: Add caddy reverse proxy
community.docker.docker_container_exec:
container: "{{ caddy_container_id.stdout }}"
command: >
curl localhost:2019/config/apps/http/servers/srv0/routes/0 -X POST -H "Content-Type: application/json" -d {{ whoami_upstream }}
become: yes

View file

@ -0,0 +1,11 @@
version: "3.7"
services:
app:
image: containous/whoami:{{ whoami_version }}
networks:
- "{{ docker_swarm_public_network_name }}"
networks:
"{{ docker_swarm_public_network_name }}":
external: true

View file

@ -0,0 +1,9 @@
---
whoami_stack:
- name: whoami
compose: "{{ lookup('template', 'docker-stack.yml.j2') | from_yaml }}"
whoami_upstream: >-
'{ "@id": "whoami_upstream", "handle": [{ "handler": "reverse_proxy", "upstreams": [{ "dial": "whoami_app:80"}]}] }'