feat(hedwig): add role to deploy hedwig

This commit is contained in:
transcaffeine 2021-03-17 10:15:52 +01:00
parent 61cdada9ed
commit ac2d8dc04a
No known key found for this signature in database
GPG key ID: 03624C433676E465
5 changed files with 97 additions and 0 deletions

12
roles/hedwig/README.md Normal file
View file

@ -0,0 +1,12 @@
# Hedwig pushgateway server role
[Hedwig](https://gitlab.com/famedly/services/hedwig) is a
pushgateway for matrix notifications, it implements the
[Matrix Push Notification API r0.1.1](https://matrix.org/docs/spec/push_gateway/r0.1.1)
and only supports [Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/).
## Usage
You need to configure atleast `hedwig_fcm_admin_key` for the
FCM pushgateway to be able to talk to FCM, and the `hedwig_app_id`
and `hedwig_fcm_notification_click_action` values to the app you're pushing to.

View file

@ -0,0 +1,28 @@
---
hedwig_user: hedwig
hedwig_base_path: /opt/hedwig
hedwig_config_file: "{{ hedwig_base_path }}/config.toml"
hedwig_version: "0.1.0"
hedwig_container_name: "hedwig"
hedwig_container_image_name: "registry.gitlab.com/famedly/services/hedwig"
hedwig_container_image: "{{ hedwig_container_image_name }}:{{ hedwig_container_image_tag|default(['v', hedwig_version]|join()) }}"
hedwig_container_env: {}
hedwig_container_ports: []
hedwig_container_labels: {}
hedwig_container_restart_policy: "unless-stopped"
hedwig_container_extra_volumes: []
#hedwig_fcm_admin_key: "my_secret_key_here"
hedwig_listen_port: 7022
hedwig_bind_ip: "::"
#hedwig_app_id: "org.matrix.awesome_client"
hedwig_fcm_collapse_key: "org.matrix.default_notification"
#hedwig_fcm_notification_click_action: "FLUTTER_NOTIFICATION_CLICK"
hedwig_fcm_notification_title: "<count> unread rooms"
hedwig_fcm_notification_body: "Open app to read the messages"
hedwig_fcm_notification_sound: "default"
hedwig_fcm_notification_icon: "notifications_icon"
hedwig_fcm_notification_tag: "org.matrix.default_notification"
hedwig_fcm_notification_android_channel_id: "org.matrix.app.message"

View file

@ -0,0 +1,39 @@
---
- name: Create hedwig system user
user:
name: "{{ hedwig_user }}"
state: present
system: yes
register: hedwig_user_res
- name: Ensure host directories are present
file:
path: "{{ hedwig_base_path }}"
state: directory
owner: "{{ hedwig_user_res.uid }}"
group: "{{ hedwig_user_res.group }}"
- name: Template configuration file for hedwig
template:
src: config.toml.j2
dest: "{{ hedwig_config_file }}"
owner: "{{ hedwig_user_res.uid }}"
group: "{{ hedwig_user_res.group }}"
mode: 0770
- name: Start hedwig container
docker_container:
name: "{{ hedwig_container_name }}"
image: "{{ hedwig_container_image }}"
env: "{{ hedwig_container_env }}"
user: "{{ hedwig_user_res.uid }}:{{ hedwig_user_res.group }}"
ports: "{{ hedwig_container_ports }}"
labels: "{{ hedwig_container_labels }}"
volumes: "{{ hedwig_container_volumes }}"
restart_policy: "{{ hedwig_container_restart_policy }}"
pull: true
healthcheck:
test: >-
curl http://127.0.0.1:{{ hedwig_listen_port }}/health || exit 1

View file

@ -0,0 +1,12 @@
fcm_admin_key = "{{ hedwig_fcm_admin_key }}"
server_bind_ip = "{{ hedwig_bind_ip }}"
server_port = "{{ hedwig_listen_port|int }}"
app_id = "{{ hedwig_app_id }}"
fcm_collapse_key = "{{ hedwig_fcm_collapse_key }}"
fcm_notification_click_action = "{{ hedwig_fcm_notification_click_action }}"
fcm_notification_title = "{{ hedwig_fcm_notification_title }}"
fcm_notification_body = "{{ hedwig_fcm_notification_body }}"
fcm_notification_sound = "{{ hedwig_fcm_notification_sound }}"
fcm_notification_icon = "{{ hedwig_fcm_notification_icon }}"
fcm_notification_tag = "{{ hedwig_fcm_notification_tag }}"
fcm_notification_android_channel_id = "{{ hedwig_fcm_notification_android_channel_id }}"

View file

@ -0,0 +1,6 @@
---
hedwig_container_base_volumes:
- "{{ hedwig_config_file }}:/opt/hedwig/config.toml:ro"
hedwig_container_volumes: "{{ hedwig_container_base_volumes + hedwig_container_extra_volumes }}"