--- - name: Setup postgres include_role: name: postgre vars: postgres_users: - name: bridge_facebook_user password: "{{ matrix_bridge_facebook_postgre_user_pwd }}" databases: - name: bridge_facebook owner: bridge_facebook_user local: C template: template0 no_log: true - name: Install dependencies apt: name: - python3 - python3-virtualenv - python3-pip state: latest update_cache: true register: apt_result retries: 3 until: apt_result is succeeded - name: Create the mautrix-facebook user user: name: mautrix-facebook home: /opt/mautrix-facebook password_lock: yes system: yes - name: Install bridge become: yes become_user: mautrix-facebook pip: name: mautrix-facebook[animated_stickers] virtualenv: /opt/mautrix-facebook virtualenv_command: virtualenv virtualenv_python: /usr/bin/python3 - name: Check if the bridge is already configured stat: path: /opt/mautrix-facebook/config.yaml register: register_config - name: Set read token variable block: - name: read config file slurp: src: /opt/mautrix-facebook/config.yaml register: encoded_facebook_config - name: decode config file set_fact: facebook_config: "{{ encoded_facebook_config.content | b64decode | from_yaml }}" - name: extract tokens set_fact: matrix_bridge_facebook_as_token: "{{ facebook_config.appservice.as_token }}" matrix_bridge_facebook_hs_token: "{{ facebook_config.appservice.hs_token }}" when: register_config.stat.exists - name: Configure the bridge template: src: config.yaml dest: /opt/mautrix-facebook/config.yaml owner: mautrix-facebook group: nogroup mode: '0600' notify: Restart the facebook bridge no_log: true - name: Generate facebook-registration.yaml become: yes become_user: mautrix-facebook shell: cmd: "/opt/mautrix-facebook/bin/python -m mautrix_facebook -g" chdir: /opt/mautrix-facebook creates: /opt/mautrix-facebook/registration.yaml notify: Restart synapse no_log: true - name: Copy config for synapse file: src: /opt/mautrix-facebook/registration.yaml dest: /etc/matrix-synapse/registrations/facebook-registration.yaml state: link - name: Ensure the log directory exists file: path: /var/log/bridge_facebook state: directory group: nogroup owner: mautrix-facebook mode: u=rwx,g=rx,o= - name: Copy the daemon configuration template: src: bridge_facebook.service dest: /etc/systemd/system/bridge_facebook.service notify: Restart the facebook bridge - name: Enable the daemon systemd: name: bridge_facebook state: started enabled: yes