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,12 @@
---
## install requisites
- name: Ensure openssl installed
ansible.builtin.package:
name: "openssl"
state: present
become: yes
tags:
- apt
- download
- packages

View file

@ -0,0 +1,40 @@
---
- name: "Select tasks for {{ ansible_distribution }} {{ ansible_distribution_major_version }}"
include_tasks: "{{ distribution }}"
with_first_found:
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_distribution }}.yml"
- "{{ ansible_os_family }}.yml"
loop_control:
loop_var: distribution
- name: Generate key
ansible.builtin.shell: echo -n 'base64:'; openssl rand -base64 32
register: monica_app_key
- set_fact:
monica_app_key={{ monica_app_key.stdout }}
## install 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 monica upstream"
- name: Deploy to swarm
community.general.docker_stack:
name: "{{ stack_name }}"
state: present
prune: yes
compose:
- "{{ stack_compose }}"
become: yes
tags:
- docker-swarm
notify: "update monica upstream"