Example application, improve upstream handling

This commit is contained in:
Marty Oehme 2021-07-31 21:16:42 +02:00
parent 37bd1ed2cd
commit 21fdac4f5d
Signed by: Marty
GPG key ID: B7538B8F50A1C800
4 changed files with 18 additions and 17 deletions

View file

@ -9,24 +9,23 @@
changed_when: False
register: result
become: yes
listen: "handle upstream"
listen: "update upstream"
# upstream already exists, patch it
- name: remove old whoami upstream
community.docker.docker_container_exec:
container: "{{ caddy_container_id }}"
command: >
curl -X DELETE localhost:2019/id/{{ stack.name }}_upstream/
become: yes
when: (result.stdout | from_json)['error'] is not defined
listen: "update upstream"
# upstream has to be created
- name: add whoami upstream
community.docker.docker_container_exec:
container: "{{ caddy_container_id }}"
command: >
curl -X POST -H "Content-Type: application/json" -d @/stacks/{{ stack.name }}/upstream.json localhost:2019/config/apps/http/servers/srv0/routes/0/
curl -X POST -H "Content-Type: application/json" -d @/stacks/{{ stack.name }}/upstream.json localhost:2019/config/apps/http/servers/{{ (whoami_use_https == True) | ternary(caddy_https_server_name, caddy_http_server_name) }}/routes/0/
become: yes
when: (result.stdout | from_json)['error'] is defined
listen: "handle upstream"
# upstream already exists, patch it
- name: patch whoami upstream
community.docker.docker_container_exec:
container: "{{ caddy_container_id }}"
command: >
curl -X PATCH -H "Content-Type: application/json" -d @/stacks/{{ stack.name }}/upstream.json localhost:2019/id/{{ stack.name }}_upstream/
become: yes
when: (result.stdout | from_json)['error'] is not defined
listen: "handle upstream"
listen: "update upstream"