mirror of
https://github.com/famedly/ansible-collection-matrix
synced 2024-11-10 13:44:16 +00:00
feat(hedwig): add role to deploy hedwig
This commit is contained in:
parent
61cdada9ed
commit
ac2d8dc04a
5 changed files with 97 additions and 0 deletions
12
roles/hedwig/README.md
Normal file
12
roles/hedwig/README.md
Normal 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.
|
28
roles/hedwig/defaults/main.yml
Normal file
28
roles/hedwig/defaults/main.yml
Normal 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"
|
39
roles/hedwig/tasks/main.yml
Normal file
39
roles/hedwig/tasks/main.yml
Normal 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
|
||||
|
12
roles/hedwig/templates/config.toml.j2
Normal file
12
roles/hedwig/templates/config.toml.j2
Normal 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 }}"
|
6
roles/hedwig/vars/main.yml
Normal file
6
roles/hedwig/vars/main.yml
Normal 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 }}"
|
Loading…
Reference in a new issue