123 lines
3 KiB
YAML
123 lines
3 KiB
YAML
|
---
|
||
|
|
||
|
- name: Setup postgres
|
||
|
include_role:
|
||
|
name: postgre
|
||
|
vars:
|
||
|
postgres_users:
|
||
|
- name: bridge_instagram_user
|
||
|
password: "{{ matrix_bridge_instagram_postgre_user_pwd }}"
|
||
|
databases:
|
||
|
- name: bridge_instagram
|
||
|
owner: bridge_instagram_user
|
||
|
local: C
|
||
|
template: template0
|
||
|
no_log: true
|
||
|
|
||
|
- name: Install dependencies
|
||
|
apt:
|
||
|
name:
|
||
|
- 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
|
||
|
|
||
|
- name: Create the mautrix-instagram user
|
||
|
user:
|
||
|
name: mautrix-instagram
|
||
|
home: /opt/mautrix-instagram
|
||
|
password_lock: yes
|
||
|
system: yes
|
||
|
|
||
|
- name: Install bridge
|
||
|
become: yes
|
||
|
become_user: mautrix-instagram
|
||
|
pip:
|
||
|
name:
|
||
|
- Pillow
|
||
|
- mautrix-instagram[all]
|
||
|
virtualenv: /opt/mautrix-instagram
|
||
|
virtualenv_command: virtualenv
|
||
|
virtualenv_python: /usr/bin/python3
|
||
|
|
||
|
- name: Check if the bridge is already configured
|
||
|
stat:
|
||
|
path: /opt/mautrix-instagram/config.yaml
|
||
|
register: register_config
|
||
|
|
||
|
- name: Set read token variable
|
||
|
block:
|
||
|
- name: read config file
|
||
|
slurp:
|
||
|
src: /opt/mautrix-instagram/config.yaml
|
||
|
register: encoded_config
|
||
|
- name: decode config file
|
||
|
set_fact:
|
||
|
instagram_config: "{{ encoded_config.content | b64decode | from_yaml }}"
|
||
|
- name: extract tokens
|
||
|
set_fact:
|
||
|
matrix_bridge_instagram_as_token: "{{ instagram_config.appservice.as_token }}"
|
||
|
matrix_bridge_instagram_hs_token: "{{ instagram_config.appservice.hs_token }}"
|
||
|
when: register_config.stat.exists
|
||
|
|
||
|
- name: Configure the bridge
|
||
|
template:
|
||
|
src: config.yaml
|
||
|
dest: /opt/mautrix-instagram/config.yaml
|
||
|
owner: mautrix-instagram
|
||
|
group: nogroup
|
||
|
mode: '0600'
|
||
|
notify: Restart the instagram bridge
|
||
|
no_log: true
|
||
|
|
||
|
- name: Generate instagram-registration.yaml
|
||
|
become: yes
|
||
|
become_user: mautrix-instagram
|
||
|
shell:
|
||
|
cmd: "/opt/mautrix-instagram/bin/python -m mautrix_instagram -g"
|
||
|
chdir: /opt/mautrix-instagram
|
||
|
creates: /opt/mautrix-instagram/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-instagram/registration.yaml
|
||
|
dest: /etc/matrix-synapse/registrations/instagram-registration.yaml
|
||
|
state: link
|
||
|
|
||
|
- name: Ensure the log directory exists
|
||
|
file:
|
||
|
path: /var/log/bridge_instagram
|
||
|
state: directory
|
||
|
group: nogroup
|
||
|
owner: mautrix-instagram
|
||
|
mode: u=rwx,g=rx,o=
|
||
|
|
||
|
- name: Copy the daemon configuration
|
||
|
template:
|
||
|
src: bridge_instagram.service
|
||
|
dest: /etc/systemd/system/bridge_instagram.service
|
||
|
notify: Restart the instagram bridge
|
||
|
|
||
|
- name: Enable the daemon
|
||
|
systemd:
|
||
|
name: bridge_instagram
|
||
|
state: started
|
||
|
enabled: yes
|