Move upstream logic to handler function
This commit is contained in:
parent
09f15d5b8e
commit
6036a91902
3 changed files with 36 additions and 18 deletions
|
|
@ -5,3 +5,6 @@ docker_swarm_advertise_addr: eth1
|
||||||
caddy_use_debug: yes
|
caddy_use_debug: yes
|
||||||
caddy_use_https: no
|
caddy_use_https: no
|
||||||
caddy_tls_use_staging: yes
|
caddy_tls_use_staging: yes
|
||||||
|
|
||||||
|
whoami_use_https: no
|
||||||
|
wallabag_use_https: no
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,18 @@
|
||||||
## Register reverse proxy
|
## Register reverse proxy
|
||||||
|
- name: Ensure upstream directory exists
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ whoami_upstream_file_dir }}"
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
become: yes
|
||||||
|
listen: "update upstream"
|
||||||
|
|
||||||
|
- name: Update upstream template
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: upstream.json.j2
|
||||||
|
dest: "{{ whoami_upstream_file_dir }}/upstream.json"
|
||||||
|
become: yes
|
||||||
|
listen: "update upstream"
|
||||||
|
|
||||||
# figure out if upstream id exists
|
# figure out if upstream id exists
|
||||||
- name: check {{ stack.name }} upstream
|
- name: check {{ stack.name }} upstream
|
||||||
|
|
@ -26,6 +40,14 @@
|
||||||
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/{{ (whoami_use_https == True) | ternary(caddy_https_server_name, caddy_http_server_name) }}/routes/0/
|
curl -X POST -H "Content-Type: application/json" -d @{{ whoami_upstream_file_dir }}/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
|
||||||
listen: "update upstream"
|
listen: "update upstream"
|
||||||
|
|
||||||
|
- name: Ensure upstream directory is gone again
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ whoami_upstream_file_dir }}"
|
||||||
|
state: absent
|
||||||
|
become: yes
|
||||||
|
listen: "update upstream"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,13 @@
|
||||||
---
|
---
|
||||||
# install whoami container
|
## install whoami container
|
||||||
- name: Ensure upstream directory exists
|
- name: Check upstream status
|
||||||
ansible.builtin.file:
|
community.docker.docker_container_exec:
|
||||||
path: "{{ whoami_upstream_file_dir }}"
|
container: "{{ caddy_container_id }}"
|
||||||
state: directory
|
command: >
|
||||||
mode: '0755'
|
curl localhost:2019/id/{{ stack.name }}_upstream/
|
||||||
become: true
|
register: result
|
||||||
tags:
|
changed_when: (result.stdout | from_json) != (lookup('template', 'upstream.json.j2') | from_yaml)
|
||||||
- fs
|
become: yes
|
||||||
|
|
||||||
- name: Update upstream template
|
|
||||||
ansible.builtin.template:
|
|
||||||
src: upstream.json.j2
|
|
||||||
dest: "{{ whoami_upstream_file_dir }}/upstream.json"
|
|
||||||
become: true
|
|
||||||
tags:
|
|
||||||
- fs
|
|
||||||
notify: "update upstream"
|
notify: "update upstream"
|
||||||
|
|
||||||
- name: Deploy whoami to swarm
|
- name: Deploy whoami to swarm
|
||||||
|
|
@ -30,3 +22,4 @@
|
||||||
tags:
|
tags:
|
||||||
- docker-swarm
|
- docker-swarm
|
||||||
notify: "update upstream"
|
notify: "update upstream"
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue