Example application, improve upstream handling
This commit is contained in:
parent
37bd1ed2cd
commit
21fdac4f5d
4 changed files with 18 additions and 17 deletions
|
|
@ -3,3 +3,5 @@
|
||||||
whoami_version: latest
|
whoami_version: latest
|
||||||
|
|
||||||
whoami_upstream_file_dir: "{{ docker_stack_files_dir }}/whoami"
|
whoami_upstream_file_dir: "{{ docker_stack_files_dir }}/whoami"
|
||||||
|
|
||||||
|
whoami_use_https: true
|
||||||
|
|
|
||||||
|
|
@ -9,24 +9,23 @@
|
||||||
changed_when: False
|
changed_when: False
|
||||||
register: result
|
register: result
|
||||||
become: yes
|
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
|
# upstream has to be created
|
||||||
- name: add whoami upstream
|
- name: add whoami upstream
|
||||||
community.docker.docker_container_exec:
|
community.docker.docker_container_exec:
|
||||||
container: "{{ caddy_container_id }}"
|
container: "{{ caddy_container_id }}"
|
||||||
command: >
|
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
|
become: yes
|
||||||
when: (result.stdout | from_json)['error'] is defined
|
listen: "update upstream"
|
||||||
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"
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
become: true
|
become: true
|
||||||
tags:
|
tags:
|
||||||
- fs
|
- fs
|
||||||
notify: "handle upstream"
|
notify: "update upstream"
|
||||||
|
|
||||||
- name: Deploy whoami to swarm
|
- name: Deploy whoami to swarm
|
||||||
community.general.docker_stack:
|
community.general.docker_stack:
|
||||||
|
|
@ -29,4 +29,4 @@
|
||||||
become: yes
|
become: yes
|
||||||
tags:
|
tags:
|
||||||
- docker-swarm
|
- docker-swarm
|
||||||
notify: "handle upstream"
|
notify: "update upstream"
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"match": [
|
"match": [
|
||||||
{
|
{
|
||||||
"host": [
|
"host": [
|
||||||
"{{ stack.name }}.{{ domain }}"
|
"{{ stack.name }}.{{ server_domain }}"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue