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_https: no
|
||||
caddy_tls_use_staging: yes
|
||||
|
||||
whoami_use_https: no
|
||||
wallabag_use_https: no
|
||||
|
|
|
|||
|
|
@ -1,4 +1,18 @@
|
|||
## 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
|
||||
- name: check {{ stack.name }} upstream
|
||||
|
|
@ -26,6 +40,14 @@
|
|||
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/{{ (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
|
||||
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
|
||||
- name: Ensure upstream directory exists
|
||||
ansible.builtin.file:
|
||||
path: "{{ whoami_upstream_file_dir }}"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
become: true
|
||||
tags:
|
||||
- fs
|
||||
|
||||
- name: Update upstream template
|
||||
ansible.builtin.template:
|
||||
src: upstream.json.j2
|
||||
dest: "{{ whoami_upstream_file_dir }}/upstream.json"
|
||||
become: true
|
||||
tags:
|
||||
- fs
|
||||
## install whoami container
|
||||
- name: Check upstream status
|
||||
community.docker.docker_container_exec:
|
||||
container: "{{ caddy_container_id }}"
|
||||
command: >
|
||||
curl localhost:2019/id/{{ stack.name }}_upstream/
|
||||
register: result
|
||||
changed_when: (result.stdout | from_json) != (lookup('template', 'upstream.json.j2') | from_yaml)
|
||||
become: yes
|
||||
notify: "update upstream"
|
||||
|
||||
- name: Deploy whoami to swarm
|
||||
|
|
@ -30,3 +22,4 @@
|
|||
tags:
|
||||
- docker-swarm
|
||||
notify: "update upstream"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue