Add monica deployment

Added basic monica docker deployment.

A key which is required for monica is automatically generated on
deployment.
Optionally, geolocation and weather api can be enabled.
Mail-sending functionality is disabled by default but can be enabled
with any compatible smtp server set up.
This commit is contained in:
Marty Oehme 2021-10-25 20:23:04 +02:00
parent 3f944df048
commit 010d8f93c4
Signed by: Marty
GPG key ID: B7538B8F50A1C800
12 changed files with 353 additions and 1 deletions

View file

@ -0,0 +1,53 @@
## Register reverse proxy
- name: Ensure upstream directory exists
ansible.builtin.file:
path: "{{ monica_upstream_file_dir }}"
state: directory
mode: '0755'
become: yes
listen: "update monica upstream"
- name: Update upstream template
ansible.builtin.template:
src: upstream.json.j2
dest: "{{ monica_upstream_file_dir }}/upstream.json"
become: yes
listen: "update monica upstream"
# figure out if upstream id exists
- name: check {{ stack_name }} upstream
community.docker.docker_container_exec:
container: "{{ caddy_container_id }}"
command: >
curl localhost:2019/id/{{ stack_name }}_upstream/
changed_when: False
register: result
become: yes
listen: "update monica upstream"
# upstream already exists, patch it
- name: remove old {{ stack_name }} 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 monica upstream"
# upstream has to be created
- name: add {{ stack_name }} upstream
community.docker.docker_container_exec:
container: "{{ caddy_container_id }}"
command: >
curl -X POST -H "Content-Type: application/json" -d @{{ monica_upstream_file_dir }}/upstream.json localhost:2019/config/apps/http/servers/{{ (monica_use_https == True) | ternary(caddy_https_server_name, caddy_http_server_name) }}/routes/0/
become: yes
listen: "update monica upstream"
- name: Ensure upstream directory is gone again
ansible.builtin.file:
path: "{{ monica_upstream_file_dir }}"
state: absent
become: yes
listen: "update monica upstream"