2021-08-06 02:40:52 +02:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Setup postgres
|
|
|
|
include_role:
|
|
|
|
name: postgre
|
|
|
|
vars:
|
|
|
|
postgres_users:
|
|
|
|
- name: bridge_discor_user
|
2021-08-06 04:10:46 +02:00
|
|
|
password: "{{ matrix_bridge_discord_postgre_user_pwd }}"
|
2021-08-06 02:40:52 +02:00
|
|
|
databases:
|
|
|
|
- name: bridge_discord
|
|
|
|
owner: bridge_discor_user
|
|
|
|
local: C
|
|
|
|
template: template0
|
2021-08-06 05:54:20 +02:00
|
|
|
no_log: true
|
2021-08-06 02:40:52 +02:00
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- npm
|
|
|
|
- git
|
|
|
|
- pgloader
|
|
|
|
state: latest
|
|
|
|
update_cache: true
|
|
|
|
register: apt_result
|
|
|
|
retries: 3
|
|
|
|
until: apt_result is succeeded
|
|
|
|
|
2021-08-06 03:06:37 +02:00
|
|
|
- name: Ensure the /srv folder exist
|
|
|
|
file:
|
|
|
|
path: /srv
|
|
|
|
state: directory
|
|
|
|
group: root
|
|
|
|
owner: root
|
|
|
|
mode: u=rwx,g=rx,o=rx
|
2021-08-06 02:40:52 +02:00
|
|
|
|
2021-08-06 03:06:37 +02:00
|
|
|
- name: Dowload the sources of the bot
|
|
|
|
git:
|
2021-08-06 05:48:08 +02:00
|
|
|
repo: 'https://github.com/Half-Shot/matrix-appservice-discord.git'
|
2021-08-06 03:06:37 +02:00
|
|
|
dest: /srv/matrix-appservice-discord
|
2021-08-06 04:10:46 +02:00
|
|
|
update: no # because this module is stupid and cannot ignore local changes
|
|
|
|
# notify: Re-build discord bridge
|
|
|
|
|
|
|
|
- name: Install dependencies
|
|
|
|
npm:
|
|
|
|
path: /srv/matrix-appservice-discord
|
|
|
|
state: latest
|
|
|
|
executable: /usr/bin/npm --force
|
2021-08-06 05:48:08 +02:00
|
|
|
retries: 3
|
|
|
|
delay: 1
|
|
|
|
register: npm_install_result
|
|
|
|
until: npm_install_result is succeeded
|
|
|
|
# The dependencies are screwed up...
|
2021-08-06 03:28:11 +02:00
|
|
|
|
|
|
|
- name: Build typescript
|
|
|
|
shell:
|
|
|
|
cmd: npm run build
|
|
|
|
chdir: /srv/matrix-appservice-discord
|
|
|
|
creates: /srv/matrix-appservice-discord/build
|
2021-08-06 04:55:58 +02:00
|
|
|
notify: Restart the discord bridge
|
2021-08-06 03:28:11 +02:00
|
|
|
|
2021-08-06 03:06:37 +02:00
|
|
|
- name: Configure the bridge
|
|
|
|
template:
|
|
|
|
src: config.yaml
|
|
|
|
dest: /srv/matrix-appservice-discord/config.yaml
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: '0660'
|
2021-08-06 04:55:58 +02:00
|
|
|
notify: Restart the discord bridge
|
2021-08-06 05:54:20 +02:00
|
|
|
no_log: true
|
2021-08-06 03:06:37 +02:00
|
|
|
|
|
|
|
- name: Generate discord-registration.yaml
|
2021-08-06 03:28:11 +02:00
|
|
|
shell:
|
|
|
|
cmd: "node build/src/discordas.js -r -u 'http://localhost:9005' -c config.yaml"
|
|
|
|
chdir: /srv/matrix-appservice-discord
|
|
|
|
creates: /srv/matrix-appservice-discord/discord-registration.yaml
|
|
|
|
notify: Restart synapse
|
2021-08-06 05:54:20 +02:00
|
|
|
no_log: true
|
2021-08-06 03:06:37 +02:00
|
|
|
|
2021-08-06 03:28:11 +02:00
|
|
|
- name: Copy config for synapse
|
2021-08-06 03:06:37 +02:00
|
|
|
file:
|
|
|
|
src: /srv/matrix-appservice-discord/discord-registration.yaml
|
|
|
|
dest: /etc/matrix-synapse/discord-registration.yaml
|
|
|
|
state: link
|
2021-08-06 04:55:58 +02:00
|
|
|
|
|
|
|
- name: Copy the daemon configuration
|
|
|
|
template:
|
|
|
|
src: bridge_discord.service
|
|
|
|
dest: /etc/systemd/system/bridge_discord.service
|
|
|
|
notify: Restart the discord bridge
|
|
|
|
|
2021-10-02 21:07:47 +02:00
|
|
|
- name: Ensure the log directory exists
|
|
|
|
file:
|
|
|
|
path: /var/log/bridge_discord
|
|
|
|
state: directory
|
|
|
|
group: root
|
|
|
|
owner: root
|
|
|
|
mode: u=rwx,g=rx,o=
|
|
|
|
|
2021-08-06 04:55:58 +02:00
|
|
|
- name: Enable the daemon
|
|
|
|
systemd:
|
|
|
|
name: bridge_discord
|
|
|
|
state: started
|
|
|
|
enabled: yes
|