ansible/roles/matrix-bridge-discord/tasks/main.yml
2021-08-06 05:54:20 +02:00

96 lines
2.3 KiB
YAML

---
- name: Setup postgres
include_role:
name: postgre
vars:
postgres_users:
- name: bridge_discor_user
password: "{{ matrix_bridge_discord_postgre_user_pwd }}"
databases:
- name: bridge_discord
owner: bridge_discor_user
local: C
template: template0
no_log: true
- name: Install dependencies
apt:
name:
- npm
- git
- pgloader
state: latest
update_cache: true
register: apt_result
retries: 3
until: apt_result is succeeded
- name: Ensure the /srv folder exist
file:
path: /srv
state: directory
group: root
owner: root
mode: u=rwx,g=rx,o=rx
- name: Dowload the sources of the bot
git:
repo: 'https://github.com/Half-Shot/matrix-appservice-discord.git'
dest: /srv/matrix-appservice-discord
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
retries: 3
delay: 1
register: npm_install_result
until: npm_install_result is succeeded
# The dependencies are screwed up...
- name: Build typescript
shell:
cmd: npm run build
chdir: /srv/matrix-appservice-discord
creates: /srv/matrix-appservice-discord/build
notify: Restart the discord bridge
- name: Configure the bridge
template:
src: config.yaml
dest: /srv/matrix-appservice-discord/config.yaml
owner: root
group: root
mode: '0660'
notify: Restart the discord bridge
no_log: true
- name: Generate discord-registration.yaml
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
no_log: true
- name: Copy config for synapse
file:
src: /srv/matrix-appservice-discord/discord-registration.yaml
dest: /etc/matrix-synapse/discord-registration.yaml
state: link
- name: Copy the daemon configuration
template:
src: bridge_discord.service
dest: /etc/systemd/system/bridge_discord.service
notify: Restart the discord bridge
- name: Enable the daemon
systemd:
name: bridge_discord
state: started
enabled: yes