Merge branch 'master' of https://github.com/spantaleev/matrix-docker-ansible-deploy
commit
4315b472af
@ -0,0 +1,11 @@
|
||||
# Setting up Mautrix Facebook (optional)
|
||||
|
||||
The playbook can install and configure [mautrix-facebook](https://github.com/tulir/mautrix-facebook) for you.
|
||||
|
||||
See the project's [documentation](https://github.com/tulir/mautrix-facebook/wiki#usage) to learn what it does and why it might be useful to you.
|
||||
|
||||
```yaml
|
||||
matrix_mautrix_facebook_enabled: true
|
||||
```
|
||||
|
||||
You then need to start a chat with `@facebookbot:YOUR_DOMAIN` (where `YOUR_DOMAIN` is your base domain, not the `matrix.` domain).
|
@ -0,0 +1,19 @@
|
||||
# Updating users passwords
|
||||
|
||||
If you are using the matrix-postgres container(default), you can do it via this Ansible playbook (make sure to edit the `<your-username>` and `<your-password>` part below):
|
||||
|
||||
ansible-playbook -i inventory/hosts setup.yml --extra-vars='username=<your-username> password=<your-password>' --tags=update-user-password
|
||||
|
||||
**Note**: `<your-username>` is just a plain username (like `john`), not your full `@<username>:<your-domain>` identifier.
|
||||
|
||||
**You can then log in with that user** via the riot-web service that this playbook has created for you at a URL like this: `https://riot.<domain>/`.
|
||||
|
||||
If you are NOT using the matrix-postgres container, you can generate the password hash by using the command-line after **SSH**-ing to your server (requires that [all services have been started](#starting-the-services)):
|
||||
|
||||
docker exec -it matrix-synapse /usr/local/bin/hash_password -c /data/homeserver.yaml
|
||||
|
||||
and then connecting to the postgres server and executing:
|
||||
|
||||
UPDATE users SET password_hash = '<password-hash>' WHERE name = '@someone:server.com'
|
||||
|
||||
where `<password-hash>` is the hash returned by the docker command above.
|
@ -1,3 +1,4 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
{
|
||||
"m.server": "{{ matrix_server_fqn_matrix }}:8448"
|
||||
}
|
||||
|
@ -1,2 +1,3 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
# User and password for protecting /_synapse/metrics URI
|
||||
prometheus:{{ matrix_nginx_proxy_proxy_synapse_metrics_basic_auth_key }}
|
||||
|
@ -1,3 +1,4 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
PGUSER={{ matrix_postgres_connection_username }}
|
||||
PGPASSWORD={{ matrix_postgres_connection_password }}
|
||||
PGDATABASE={{ matrix_postgres_db_name }}
|
@ -1,3 +1,4 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
POSTGRES_USER={{ matrix_postgres_connection_username }}
|
||||
POSTGRES_PASSWORD={{ matrix_postgres_connection_password }}
|
||||
POSTGRES_DB={{ matrix_postgres_db_name }}
|
@ -0,0 +1,16 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
#!/bin/bash
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
echo "Usage: "$0" <username> <password_hash>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
docker run \
|
||||
--rm \
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
|
||||
--cap-drop=ALL \
|
||||
--env-file={{ matrix_postgres_base_path }}/env-postgres-psql \
|
||||
--network {{ matrix_docker_network }} \
|
||||
{{ matrix_postgres_docker_image_to_use }} \
|
||||
psql -h {{ matrix_postgres_connection_hostname }} -c "UPDATE users set password_hash='$2' WHERE name = '@$1:{{ matrix_domain }}'"
|
@ -1,23 +1,24 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
{
|
||||
"default_hs_url": {{ matrix_riot_web_default_hs_url|to_json }},
|
||||
"default_is_url": {{ matrix_riot_web_default_is_url|to_json }},
|
||||
"default_hs_url": {{ matrix_riot_web_default_hs_url|string|to_json }},
|
||||
"default_is_url": {{ matrix_riot_web_default_is_url|string|to_json }},
|
||||
"disable_custom_urls": {{ matrix_riot_web_disable_custom_urls|to_json }},
|
||||
"disable_guests": {{ matrix_riot_web_disable_guests|to_json }},
|
||||
"brand": "Riot",
|
||||
"integrations_ui_url": {{ matrix_riot_web_integrations_ui_url|to_json }},
|
||||
"integrations_rest_url": {{ matrix_riot_web_integrations_rest_url|to_json }},
|
||||
"integrations_ui_url": {{ matrix_riot_web_integrations_ui_url|string|to_json }},
|
||||
"integrations_rest_url": {{ matrix_riot_web_integrations_rest_url|string|to_json }},
|
||||
"integrations_widgets_urls": {{ matrix_riot_web_integrations_widgets_urls|to_json }},
|
||||
"integrations_jitsi_widget_url": {{ matrix_riot_web_integrations_jitsi_widget_url|to_json }},
|
||||
"integrations_jitsi_widget_url": {{ matrix_riot_web_integrations_jitsi_widget_url|string|to_json }},
|
||||
"bug_report_endpoint_url": "https://riot.im/bugreports/submit",
|
||||
"enableLabs": true,
|
||||
"roomDirectory": {
|
||||
"servers": {{ matrix_riot_web_roomdir_servers|to_json }}
|
||||
},
|
||||
"welcomeUserId": {{ matrix_riot_web_welcome_user_id|to_json }},
|
||||
"welcomeUserId": {{ matrix_riot_web_welcome_user_id|string|to_json }},
|
||||
{% if matrix_riot_web_enable_presence_by_hs_url is not none %}
|
||||
"enable_presence_by_hs_url": {{ matrix_riot_web_enable_presence_by_hs_url|to_json }},
|
||||
{% endif %}
|
||||
"embeddedPages": {
|
||||
"homeUrl": {{ matrix_riot_web_embedded_pages_home_url|to_json }}
|
||||
"homeUrl": {{ matrix_riot_web_embedded_pages_home_url|string|to_json }}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
- set_fact:
|
||||
matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-mautrix-facebook'] }}"
|
||||
when: matrix_mautrix_facebook_enabled
|
@ -0,0 +1,101 @@
|
||||
---
|
||||
|
||||
- name: Ensure Mautrix Facebook image is pulled
|
||||
docker_image:
|
||||
name: "{{ matrix_mautrix_facebook_docker_image }}"
|
||||
when: "matrix_mautrix_facebook_enabled"
|
||||
|
||||
- name: Ensure Mautrix Facebook configuration path exists
|
||||
file:
|
||||
path: "{{ matrix_mautrix_facebook_base_path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_username }}"
|
||||
when: "matrix_mautrix_facebook_enabled"
|
||||
|
||||
- name: Check if a mautrix-facebook configuration file exists
|
||||
stat:
|
||||
path: "{{ matrix_mautrix_facebook_base_path }}/config.yaml"
|
||||
register: mautrix_facebook_config_file_stat
|
||||
when: "matrix_mautrix_facebook_enabled"
|
||||
|
||||
- name: Ensure Matrix Mautrix facebook config installed
|
||||
template:
|
||||
src: "{{ role_path }}/templates/ext/mautrix-facebook/config.yaml.j2"
|
||||
dest: "{{ matrix_mautrix_facebook_base_path }}/config.yaml"
|
||||
mode: 0644
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_username }}"
|
||||
when: "matrix_mautrix_facebook_enabled and not mautrix_facebook_config_file_stat.stat.exists"
|
||||
|
||||
- name: (Migration) Fix up old configuration
|
||||
lineinfile:
|
||||
path: "{{ matrix_mautrix_facebook_base_path }}/config.yaml"
|
||||
regexp: "{{ item.regexp }}"
|
||||
line: "{{ item.line }}"
|
||||
backrefs: yes
|
||||
with_items:
|
||||
- {'regexp': '^(\s+)filename: \./mautrix-facebook.log', 'line': '\1filename: /data/mautrix-facebook.log'}
|
||||
- {'regexp': '^(\s+)database:', 'line': '\1database: sqlite:////data/mautrix-facebook.db'}
|
||||
when: "matrix_mautrix_facebook_enabled and mautrix_facebook_config_file_stat.stat.exists"
|
||||
|
||||
- name: Ensure matrix-mautrix-facebook.service installed
|
||||
template:
|
||||
src: "{{ role_path }}/templates/ext/mautrix-facebook/systemd/matrix-mautrix-facebook.service.j2"
|
||||
dest: "/etc/systemd/system/matrix-mautrix-facebook.service"
|
||||
mode: 0644
|
||||
register: matrix_mautrix_facebook_systemd_service_result
|
||||
when: "matrix_mautrix_facebook_enabled"
|
||||
|
||||
- name: Ensure systemd reloaded after matrix-mautrix-facebook.service installation
|
||||
service:
|
||||
daemon_reload: yes
|
||||
when: "matrix_mautrix_facebook_enabled and matrix_mautrix_facebook_systemd_service_result.changed"
|
||||
|
||||
- name: Check if a mautrix-facebook registration file exists
|
||||
stat:
|
||||
path: "{{ matrix_mautrix_facebook_base_path }}/registration.yaml"
|
||||
register: mautrix_facebook_registration_file_stat
|
||||
when: "matrix_mautrix_facebook_enabled"
|
||||
|
||||
- name: Generate matrix-mautrix-facebook registration.yaml if it doesn't exist
|
||||
shell:
|
||||
cmd: >-
|
||||
/usr/bin/docker run
|
||||
--rm
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }}
|
||||
--cap-drop=ALL
|
||||
--name matrix-mautrix-facebook-gen
|
||||
-v {{ matrix_mautrix_facebook_base_path }}:/data:z
|
||||
{{ matrix_mautrix_facebook_docker_image }}
|
||||
python3 -m mautrix_facebook -g -c /data/config.yaml -r /data/registration.yaml
|
||||
when: "matrix_mautrix_facebook_enabled and not mautrix_facebook_registration_file_stat.stat.exists"
|
||||
|
||||
- set_fact:
|
||||
matrix_synapse_app_service_config_file_mautrix_facebook: '/app-registration/mautrix-facebook.yml'
|
||||
when: "matrix_mautrix_facebook_enabled"
|
||||
|
||||
- set_fact:
|
||||
matrix_synapse_container_additional_volumes: >
|
||||
{{ matrix_synapse_container_additional_volumes }}
|
||||
+
|
||||
{{ [{'src': '{{ matrix_mautrix_facebook_base_path }}/registration.yaml', 'dst': '{{ matrix_synapse_app_service_config_file_mautrix_facebook }}', 'options': 'ro'}] }}
|
||||
when: "matrix_mautrix_facebook_enabled"
|
||||
|
||||
- set_fact:
|
||||
matrix_synapse_app_service_config_files: >
|
||||
{{ matrix_synapse_app_service_config_files }}
|
||||
+
|
||||
{{ ["{{ matrix_synapse_app_service_config_file_mautrix_facebook }}"] | to_nice_json }}
|
||||
when: "matrix_mautrix_facebook_enabled"
|
||||
|
||||
#
|
||||
# Tasks related to getting rid of matrix-mautrix-facebook (if it was previously enabled)
|
||||
#
|
||||
|
||||
- name: Ensure matrix-mautrix-facebook.service doesn't exist
|
||||
file:
|
||||
path: "/etc/systemd/system/matrix-mautrix-facebook.service"
|
||||
state: absent
|
||||
when: "not matrix_mautrix_facebook_enabled"
|
@ -0,0 +1,48 @@
|
||||
---
|
||||
|
||||
- name: Fail if playbook called incorrectly
|
||||
fail:
|
||||
msg: "The `username` variable needs to be provided to this playbook, via --extra-vars"
|
||||
when: "username is not defined or username == '<your-username>'"
|
||||
|
||||
- name: Fail if playbook called incorrectly
|
||||
fail:
|
||||
msg: "The `password` variable needs to be provided to this playbook, via --extra-vars"
|
||||
when: "password is not defined or password == '<your-password>'"
|
||||
|
||||
- name: Fail if not using matrix-postgres container
|
||||
fail:
|
||||
msg: "This command is working only when matrix-postgres container is being used"
|
||||
when: "not matrix_postgres_enabled"
|
||||
|
||||
- name: Ensure matrix-synapse is started
|
||||
service:
|
||||
name: matrix-synapse
|
||||
state: started
|
||||
daemon_reload: yes
|
||||
register: start_result
|
||||
|
||||
- name: Ensure matrix-postgres is started
|
||||
service:
|
||||
name: matrix-postgres
|
||||
state: started
|
||||
daemon_reload: yes
|
||||
register: postgres_start_result
|
||||
|
||||
|
||||
- name: Wait a while, so that Matrix Synapse can manage to start
|
||||
pause:
|
||||
seconds: 7
|
||||
when: start_result.changed
|
||||
|
||||
- name: Wait a while, so that Matrix Postgres can manage to start
|
||||
pause:
|
||||
seconds: 7
|
||||
when: postgres_start_result.changed
|
||||
|
||||
- name: Generate password hash
|
||||
shell: "/usr/bin/docker exec matrix-synapse /usr/local/bin/hash_password -c /data/homeserver.yaml -p {{ password }}"
|
||||
register: password_hash
|
||||
|
||||
- name: Update user password hash
|
||||
shell: "/usr/local/bin/matrix-postgres-update-user-password-hash {{ username }} '{{ password_hash.stdout }}'"
|
@ -0,0 +1,109 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
# Homeserver details
|
||||
homeserver:
|
||||
# The address that this appservice can use to connect to the homeserver.
|
||||
address: https://{{ matrix_server_fqn_matrix }}
|
||||
# The domain of the homeserver (for MXIDs, etc).
|
||||
domain: {{ matrix_domain }}
|
||||
# Whether or not to verify the SSL certificate of the homeserver.
|
||||
# Only applies if address starts with https://
|
||||
verify_ssl: true
|
||||
|
||||
# Application service host/registration related details
|
||||
# Changing these values requires regeneration of the registration.
|
||||
appservice:
|
||||
# The address that the homeserver can use to connect to this appservice.
|
||||
address: http://matrix-mautrix-facebook:8080
|
||||
|
||||
# The hostname and port where this appservice should listen.
|
||||
hostname: 0.0.0.0
|
||||
port: 8080
|
||||
# The maximum body size of appservice API requests (from the homeserver) in mebibytes
|
||||
# Usually 1 is enough, but on high-traffic bridges you might need to increase this to avoid 413s
|
||||
max_body_size: 1
|
||||
|
||||
# The full URI to the database. SQLite and Postgres are fully supported.
|
||||
# Other DBMSes supported by SQLAlchemy may or may not work.
|
||||
# Format examples:
|
||||
# SQLite: sqlite:///filename.db
|
||||
# Postgres: postgres://username:password@hostname/dbname
|
||||
database: sqlite:////data/mautrix-facebook.db
|
||||
|
||||
# The unique ID of this appservice.
|
||||
id: facebook
|
||||
# Username of the appservice bot.
|
||||
bot_username: facebookbot
|
||||
# Display name and avatar for bot. Set to "remove" to remove display name/avatar, leave empty
|
||||
# to leave display name/avatar as-is.
|
||||
bot_displayname: Facebook bridge bot
|
||||
bot_avatar: mxc://maunium.net/ddtNPZSKMNqaUzqrHuWvUADv
|
||||
|
||||
# Authentication tokens for AS <-> HS communication. Autogenerated; do not modify.
|
||||
as_token: "This value is generated when generating the registration"
|
||||
hs_token: "This value is generated when generating the registration"
|
||||
|
||||
# Bridge config
|
||||
bridge:
|
||||
# Localpart template of MXIDs for Facebook users.
|
||||
# {userid} is replaced with the user ID of the Facebook user.
|
||||
username_template: "facebook_{userid}"
|
||||
|
||||
# The prefix for commands. Only required in non-management rooms.
|
||||
command_prefix: "!fb"
|
||||
|
||||
# Number of chats to sync (and create portals for) on startup/login.
|
||||
# Maximum 20, set 0 to disable automatic syncing.
|
||||
initial_chat_sync: 10
|
||||
# Whether or not the Facebook users of logged in Matrix users should be
|
||||
# invited to private chats when the user sends a message from another client.
|
||||
invite_own_puppet_to_pm: false
|
||||
# Whether or not to use /sync to get presence, read receipts and typing notifications when using
|
||||
# your own Matrix account as the Matrix puppet for your Facebook account.
|
||||
sync_with_custom_puppets: true
|
||||
# Whether or not to bridge presence in both directions. Facebook allows users not to broadcast
|
||||
# presence, but then it won't send other users' presence to the client.
|
||||
presence: true
|
||||
|
||||
# Permissions for using the bridge.
|
||||
# Permitted values:
|
||||
# user - Use the bridge with puppeting.
|
||||
# admin - Use and administrate the bridge.
|
||||
# Permitted keys:
|
||||
# * - All Matrix users
|
||||
# domain - All users on that homeserver
|
||||
# mxid - Specific user
|
||||
permissions:
|
||||
'{{ matrix_domain }}': user
|
||||
|
||||
# Python logging configuration.
|
||||
#
|
||||
# See section 16.7.2 of the Python documentation for more info:
|
||||
# https://docs.python.org/3.6/library/logging.config.html#configuration-dictionary-schema
|
||||
logging:
|
||||
version: 1
|
||||
formatters:
|
||||
colored:
|
||||
(): mautrix_facebook.util.ColorFormatter
|
||||
format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s"
|
||||
normal:
|
||||
format: "[%(asctime)s] [%(levelname)s@%(name)s] %(message)s"
|
||||
handlers:
|
||||
file:
|
||||
class: logging.handlers.RotatingFileHandler
|
||||
formatter: normal
|
||||
filename: /data/mautrix-facebook.log
|
||||
maxBytes: 10485760
|
||||
backupCount: 10
|
||||
console:
|
||||
class: logging.StreamHandler
|
||||
formatter: colored
|
||||
loggers:
|
||||
mau:
|
||||
level: DEBUG
|
||||
fbchat:
|
||||
level: DEBUG
|
||||
aiohttp:
|
||||
level: INFO
|
||||
root:
|
||||
level: DEBUG
|
||||
handlers: [file, console]
|
@ -0,0 +1,34 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
[Unit]
|
||||
Description=Matrix Mautrix Facebook server
|
||||
After=docker.service
|
||||
Requires=docker.service
|
||||
Requires=matrix-synapse.service
|
||||
After=matrix-synapse.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStartPre=-/usr/bin/docker kill matrix-mautrix-facebook
|
||||
ExecStartPre=-/usr/bin/docker rm matrix-mautrix-facebook
|
||||
ExecStartPre=/usr/bin/docker run --rm --name matrix-mautrix-facebook-db \
|
||||
--log-driver=none \
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
|
||||
--cap-drop=ALL \
|
||||
-v {{ matrix_mautrix_facebook_base_path }}:/data:z \
|
||||
{{ matrix_mautrix_facebook_docker_image }} \
|
||||
alembic -x config=/data/config.yaml upgrade head
|
||||
ExecStart=/usr/bin/docker run --rm --name matrix-mautrix-facebook \
|
||||
--log-driver=none \
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
|
||||
--cap-drop=ALL \
|
||||
--network={{ matrix_docker_network }} \
|
||||
-v {{ matrix_mautrix_facebook_base_path }}:/data:z \
|
||||
{{ matrix_mautrix_facebook_docker_image }} \
|
||||
python3 -m mautrix_facebook -c /data/config.yaml
|
||||
ExecStop=-/usr/bin/docker kill matrix-mautrix-facebook
|
||||
ExecStop=-/usr/bin/docker rm matrix-mautrix-facebook
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,2 +1,3 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
AWS_ACCESS_KEY={{ matrix_s3_media_store_aws_access_key }}
|
||||
AWS_SECRET_KEY={{ matrix_s3_media_store_aws_secret_key }}
|
||||
|
@ -1,2 +1,3 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
SYNAPSE_CONFIG_PATH=/data/homeserver.yaml
|
||||
SYNAPSE_CACHE_FACTOR={{ matrix_synapse_cache_factor }}
|
||||
|
Loading…
Reference in new issue