matrix-bridge-signal/tasks/main.yml

141 lines
3.3 KiB
YAML
Raw Normal View History

2022-03-06 17:54:44 +01:00
---
- name: Setup postgres
include_role:
name: postgre
vars:
postgres_users:
- name: bridge_signal_user
password: "{{ matrix_bridge_signal_postgre_user_pwd }}"
databases:
- name: bridge_signal
owner: bridge_signal_user
local: C
template: template0
no_log: true
2022-03-06 18:37:00 +01:00
- name: Install the pgp key for the signald repo.
copy:
src: signald-keyring.gpg
2022-03-06 19:27:15 +01:00
dest: /etc/apt/trusted.gpg.d/signald-keyring.gpg
2022-03-06 18:37:00 +01:00
mode: 0644
2022-03-06 19:27:15 +01:00
- name: Add signald repo to source list
2022-03-06 18:37:00 +01:00
ansible.builtin.apt_repository:
2022-03-06 19:27:15 +01:00
repo: "deb https://updates.signald.org unstable main"
2022-03-06 18:37:00 +01:00
state: present
2022-03-06 17:54:44 +01:00
- name: Install dependencies
apt:
name:
2022-03-06 18:37:00 +01:00
- signald
2022-03-06 17:54:44 +01:00
- python3
- python3-virtualenv
- python3-pip
- libolm-dev # for encryption
- python3-dev #
- build-essential #
state: latest
update_cache: true
register: apt_result
retries: 3
until: apt_result is succeeded
2022-03-06 18:37:00 +01:00
- name: Enable the signald daemon
systemd:
name: signald
state: started
enabled: yes
2022-03-06 17:54:44 +01:00
- name: Create the mautrix-signal user
user:
name: mautrix-signal
home: /opt/mautrix-signal
2022-03-06 20:49:43 +01:00
groups:
- signald
2022-03-06 17:54:44 +01:00
password_lock: yes
system: yes
- name: Install bridge
become: yes
become_user: mautrix-signal
pip:
name: mautrix-signal[all]
virtualenv: /opt/mautrix-signal
virtualenv_command: virtualenv
virtualenv_python: /usr/bin/python3
- name: Check if the bridge is already configured
stat:
path: /opt/mautrix-signal/config.yaml
register: register_config
- name: Set read token variable
block:
- name: read config file
slurp:
src: /opt/mautrix-signal/config.yaml
register: encoded_config
- name: decode config file
set_fact:
signal_config: "{{ encoded_config.content | b64decode | from_yaml }}"
- name: extract tokens
set_fact:
matrix_bridge_signal_as_token: "{{ signal_config.appservice.as_token }}"
2022-03-06 21:17:00 +01:00
matrix_bridge_signal_hs_token: "{{ signal_config.appservice.hs_token }}"
2022-03-06 17:54:44 +01:00
when: register_config.stat.exists
- name: Configure the bridge
template:
src: config.yaml
dest: /opt/mautrix-signal/config.yaml
owner: mautrix-signal
group: nogroup
mode: '0600'
notify: Restart the signal bridge
no_log: true
- name: Generate signal-registration.yaml
become: yes
become_user: mautrix-signal
shell:
cmd: "/opt/mautrix-signal/bin/python -m mautrix_signal -g"
chdir: /opt/mautrix-signal
creates: /opt/mautrix-signal/registration.yaml
notify: Restart synapse
no_log: true
- name: Ensure the registration directory exists
file:
path: /etc/matrix-synapse/registrations
state: directory
group: root
owner: root
mode: u=rwx,g=rx,o=rx
- name: Copy registration for synapse
file:
src: /opt/mautrix-signal/registration.yaml
dest: /etc/matrix-synapse/registrations/signal-registration.yaml
state: link
- name: Ensure the log directory exists
file:
path: /var/log/bridge_signal
state: directory
group: nogroup
owner: mautrix-signal
mode: u=rwx,g=rx,o=
- name: Copy the daemon configuration
template:
src: bridge_signal.service
dest: /etc/systemd/system/bridge_signal.service
notify: Restart the signal bridge
- name: Enable the daemon
systemd:
name: bridge_signal
state: started
enabled: yes