Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix stuff and add Podman/Fedora support (#986 rebase) #1133

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/roles/*/files/scratchpad
.DS_Store
.python-version
.ansible-retry
3 changes: 2 additions & 1 deletion ansible.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[defaults]
retry_files_enabled = False
retry_files_enabled = True
stdout_callback = yaml
retry_files_save_path = ./.ansible-retry

[connection]
pipelining = True
1 change: 1 addition & 0 deletions docs/configuring-playbook-bridge-mautrix-signal.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Use the following playbook configuration:

```yaml
matrix_mautrix_signal_enabled: true
matrix_mautrix_signal_admins: {"@YOUR_USER:YOUR_DOMAIN": "admin"}
```

## Set up Double Puppeting
Expand Down
7 changes: 6 additions & 1 deletion group_vars/matrix_servers
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ matrix_mautrix_instagram_database_password: "{{ matrix_synapse_macaroon_secret_k
# We don't enable bridges by default.
matrix_mautrix_signal_enabled: false

matrix_mautrix_signal_container_image_self_build: "{{ matrix_architecture not in ['amd64', 'arm64'] }}"

matrix_mautrix_signal_systemd_required_services_list: |
{{
['docker.service']
Expand Down Expand Up @@ -433,6 +435,8 @@ matrix_mautrix_telegram_database_password: "{{ matrix_synapse_macaroon_secret_ke
# We don't enable bridges by default.
matrix_mautrix_whatsapp_enabled: false

matrix_mautrix_whatsapp_container_image_self_build: "{{ matrix_architecture not in ['amd64', 'arm64'] }}"

matrix_mautrix_whatsapp_systemd_required_services_list: |
{{
['docker.service']
Expand Down Expand Up @@ -1013,6 +1017,7 @@ matrix_etherpad_database_password: "{{ matrix_synapse_macaroon_secret_key | pass
######################################################################

matrix_dynamic_dns_enabled: false
matrix_dynamic_dns_container_image_self_build: "{{ matrix_architecture != 'amd64'}}"

######################################################################
#
Expand Down Expand Up @@ -1325,7 +1330,7 @@ matrix_postgres_architecture: "{{ matrix_architecture }}"
# and tell users they need to set it (either here or in those variables).
matrix_postgres_connection_hostname: "{{ 'matrix-postgres' if matrix_postgres_enabled else '' }}"

matrix_postgres_pgloader_container_image_self_build: "{{ matrix_architecture != 'amd64' }}"
matrix_postgres_pgloader_container_image_self_build: false

matrix_postgres_additional_databases: |
{{
Expand Down
2 changes: 1 addition & 1 deletion roles/matrix-base/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ matrix_well_known_matrix_server_enabled: true
matrix_docker_installation_enabled: true

# Controls the Docker package that is installed.
# Possible values are "docker-ce" (default) and "docker.io" (Debian).
# Possible values are "docker-ce" (default), "docker.io" (Debian) and "podman-docker" (Fedora)
matrix_docker_package_name: docker-ce

# Variables to Control which parts of our roles run.
Expand Down
21 changes: 21 additions & 0 deletions roles/matrix-base/tasks/server_base/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
- include_tasks: "{{ role_path }}/tasks/server_base/setup_centos.yml"
when: ansible_distribution == 'CentOS'

- include_tasks: "{{ role_path }}/tasks/server_base/setup_fedora.yml"
when: ansible_distribution == 'Fedora'

- block:
# ansible_lsb is only available if lsb-release is installed.
- name: Ensure lsb-release installed
Expand All @@ -27,6 +30,18 @@
- include_tasks: "{{ role_path }}/tasks/server_base/setup_archlinux.yml"
when: ansible_distribution == 'Archlinux'

- name: Ensure Docker.service is available
template:
src: "{{ role_path }}/templates/systemd/docker.service"
dest: "{{ matrix_systemd_path }}/docker.service"
mode: 0644
register: matrix_docker_systemd_service_result

- name: Ensure systemd reloaded after docker.service installation
service:
daemon_reload: yes
when: "matrix_docker_systemd_service_result.changed|bool"

- name: Ensure Docker is started and autoruns
service:
name: docker
Expand All @@ -38,3 +53,9 @@
name: "{{ matrix_ntpd_service }}"
state: started
enabled: yes

- name: Ensure matrix.target is installed
template:
src: "{{ role_path }}/templates/systemd/matrix.target"
dest: "{{ matrix_systemd_path }}/matrix.target"
mode: 0644
1 change: 1 addition & 0 deletions roles/matrix-base/tasks/server_base/setup_archlinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# TODO This needs to be verified. Which version do we need?
- fuse3
- python-dnspython
- git
state: latest
update_cache: yes

Expand Down
1 change: 1 addition & 0 deletions roles/matrix-base/tasks/server_base/setup_centos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
name:
- "{{ matrix_ntpd_package }}"
- fuse
- git
state: latest
update_cache: yes

Expand Down
1 change: 1 addition & 0 deletions roles/matrix-base/tasks/server_base/setup_debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
name:
- "{{ matrix_ntpd_package }}"
- fuse
- git
state: latest
update_cache: yes

Expand Down
21 changes: 21 additions & 0 deletions roles/matrix-base/tasks/server_base/setup_fedora.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---

- name: Ensure dnf packages are installed
yum:
name:
- "{{ matrix_ntpd_package }}"
- fuse
- git
state: latest
update_cache: yes

- name: Ensure Docker is installed
yum:
name:
- "{{ matrix_docker_package_name }}"
state: latest
when: matrix_docker_installation_enabled|bool

- name: Ensure Docker python library is installed
pip:
name: docker
1 change: 1 addition & 0 deletions roles/matrix-base/tasks/server_base/setup_raspbian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
name:
- "{{ matrix_ntpd_package }}"
- fuse
- git
state: latest
update_cache: yes

Expand Down
9 changes: 9 additions & 0 deletions roles/matrix-base/templates/systemd/docker.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Start Podman Docker link

[Service]
Restart=on-failure
TimeoutStopSec=70
ExecStart={{ matrix_host_command_docker }} system service --time 0
Type=simple

5 changes: 5 additions & 0 deletions roles/matrix-base/templates/systemd/matrix.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Unit]
Description=Start all Matrix-related services

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ After={{ service }}
Wants={{ service }}
{% endfor %}
DefaultDependencies=no
PartOf=matrix.target

[Service]
Type=simple
Environment="HOME={{ matrix_systemd_unit_home_path }}"
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-bot-go-neb 2>/dev/null'
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} stop matrix-bot-go-neb 2>/dev/null'
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-bot-go-neb 2>/dev/null'

ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-bot-go-neb \
Expand All @@ -39,11 +40,12 @@ ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-bot-go-neb \
{{ matrix_bot_go_neb_docker_image }} \
-c "go-neb /config/config.yaml"

ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-bot-go-neb 2>/dev/null'
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} stop matrix-bot-go-neb 2>/dev/null'
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-bot-go-neb 2>/dev/null'
Restart=always
RestartSec=30
SyslogIdentifier=matrix-bot-go-neb

[Install]
WantedBy=multi-user.target
WantedBy=matrix.target

Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ After={{ service }}
Wants={{ service }}
{% endfor %}
DefaultDependencies=no
PartOf=matrix.target

[Service]
Type=simple
Environment="HOME={{ matrix_systemd_unit_home_path }}"
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-bot-matrix-reminder-bot 2>/dev/null'
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} stop matrix-bot-matrix-reminder-bot 2>/dev/null'
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-bot-matrix-reminder-bot 2>/dev/null'

ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-bot-matrix-reminder-bot \
Expand All @@ -32,11 +33,12 @@ ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-bot-matrix-rem
{{ matrix_bot_matrix_reminder_bot_docker_image }} \
-c "matrix-reminder-bot /config/config.yaml"

ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-bot-matrix-reminder-bot 2>/dev/null'
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} stop matrix-bot-matrix-reminder-bot 2>/dev/null'
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-bot-matrix-reminder-bot 2>/dev/null'
Restart=always
RestartSec=30
SyslogIdentifier=matrix-bot-matrix-reminder-bot

[Install]
WantedBy=multi-user.target
WantedBy=matrix.target

Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ After={{ service }}
Wants={{ service }}
{% endfor %}
DefaultDependencies=no
PartOf=matrix.target

[Service]
Type=simple
Environment="HOME={{ matrix_systemd_unit_home_path }}"
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-bot-mjolnir 2>/dev/null'
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} stop matrix-bot-mjolnir 2>/dev/null'
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-bot-mjolnir 2>/dev/null'

# Intentional delay, so that the homeserver (we likely depend on) can manage to start.
Expand All @@ -32,11 +33,11 @@ ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-bot-mjolnir \
{% endfor %}
{{ matrix_bot_mjolnir_docker_image }}

ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-bot-mjolnir 2>/dev/null'
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} stop matrix-bot-mjolnir 2>/dev/null'
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-bot-mjolnir 2>/dev/null'
Restart=always
RestartSec=30
SyslogIdentifier=matrix-bot-mjolnir

[Install]
WantedBy=multi-user.target
WantedBy=matrix.target
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ After={{ service }}
Wants={{ service }}
{% endfor %}
DefaultDependencies=no
PartOf=matrix.target

[Service]
Type=simple
Environment="HOME={{ matrix_systemd_unit_home_path }}"
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-appservice-discord 2>/dev/null'
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} stop matrix-appservice-discord 2>/dev/null'
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-appservice-discord 2>/dev/null'

# Intentional delay, so that the homeserver (we likely depend on) can manage to start.
ExecStartPre={{ matrix_host_command_sleep }} 5

ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-appservice-discord \
--log-driver=none \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
Expand All @@ -35,11 +33,12 @@ ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-appservice-dis
{{ matrix_appservice_discord_docker_image }} \
node /build/src/discordas.js -p 9005 -c /cfg/config.yaml -f /cfg/registration.yaml

ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-appservice-discord 2>/dev/null'
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} stop matrix-appservice-discord 2>/dev/null'
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-appservice-discord 2>/dev/null'
Restart=always
RestartSec=30
SyslogIdentifier=matrix-appservice-discord

[Install]
WantedBy=multi-user.target
[Install]
WantedBy=matrix.target

1 change: 0 additions & 1 deletion roles/matrix-bridge-appservice-irc/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

matrix_appservice_irc_enabled: true

matrix_appservice_irc_container_self_build: false
matrix_appservice_irc_docker_repo: "https://github.com/matrix-org/matrix-appservice-irc.git"
matrix_appservice_irc_docker_src_files_path: "{{ matrix_base_data_path }}/appservice-irc/docker-src"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ After={{ service }}
Wants={{ service }}
{% endfor %}
DefaultDependencies=no
PartOf=matrix.target

[Service]
Type=simple
Environment="HOME={{ matrix_systemd_unit_home_path }}"
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-appservice-irc 2>/dev/null'
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} stop matrix-appservice-irc 2>/dev/null'
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-appservice-irc 2>/dev/null'

# Intentional delay, so that the homeserver (we likely depend on) can manage to start.
ExecStartPre={{ matrix_host_command_sleep }} 5

ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-appservice-irc \
--log-driver=none \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
Expand All @@ -36,11 +34,12 @@ ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-appservice-irc
{{ matrix_appservice_irc_docker_image }} \
-c 'node app.js -c /config/config.yaml -f /config/registration.yaml -p 9999'

ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-appservice-irc 2>/dev/null'
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} stop matrix-appservice-irc 2>/dev/null'
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-appservice-irc 2>/dev/null'
Restart=always
RestartSec=30
SyslogIdentifier=matrix-appservice-irc

[Install]
WantedBy=multi-user.target
WantedBy=matrix.target

1 change: 0 additions & 1 deletion roles/matrix-bridge-appservice-slack/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

matrix_appservice_slack_enabled: true

matrix_appservice_slack_container_self_build: false
matrix_appservice_slack_docker_repo: "https://github.com/matrix-org/matrix-appservice-slack.git"
matrix_appservice_slack_docker_src_files_path: "{{ matrix_base_data_path }}/appservice-slack/docker-src"

Expand Down
2 changes: 1 addition & 1 deletion roles/matrix-bridge-appservice-slack/tasks/init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
location {{ matrix_appservice_slack_public_endpoint }} {
{% if matrix_nginx_proxy_enabled|default(False) %}
{# Use the embedded DNS resolver in Docker containers to discover the service #}
resolver 127.0.0.11 valid=5s;
resolver {{ matrix_docker_dns_resolver_ip }} valid=5s;
set $backend "{{ matrix_appservice_slack_appservice_url }}:{{ matrix_appservice_slack_slack_port }}";
proxy_pass $backend;
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ After={{ service }}
Wants={{ service }}
{% endfor %}
DefaultDependencies=no
PartOf=matrix.target

[Service]
Type=simple
Environment="HOME={{ matrix_systemd_unit_home_path }}"
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-appservice-slack 2>/dev/null'
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} stop matrix-appservice-slack 2>/dev/null'
ExecStartPre=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-appservice-slack 2>/dev/null'

# Intentional delay, so that the homeserver (we likely depend on) can manage to start.
ExecStartPre={{ matrix_host_command_sleep }} 5

ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-appservice-slack \
--log-driver=none \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
Expand All @@ -35,11 +33,12 @@ ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-appservice-sla
{{ matrix_appservice_slack_docker_image }} \
node app.js -p {{matrix_appservice_slack_matrix_port}} -c /config/config.yaml -f /config/slack-registration.yaml

ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-appservice-slack 2>/dev/null'
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} stop matrix-appservice-slack 2>/dev/null'
ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-appservice-slack 2>/dev/null'
Restart=always
RestartSec=30
SyslogIdentifier=matrix-appservice-slack

[Install]
WantedBy=multi-user.target
WantedBy=matrix.target

2 changes: 1 addition & 1 deletion roles/matrix-bridge-appservice-webhooks/tasks/init.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
{% if matrix_nginx_proxy_enabled|default(False) %}
{# Use the embedded DNS resolver in Docker containers to discover the service #}
location ~ ^{{ matrix_appservice_webhooks_public_endpoint }}/(.*)$ {
resolver 127.0.0.11 valid=5s;
resolver {{ matrix_docker_dns_resolver_ip }} valid=5s;
set $backend "matrix-appservice-webhooks:{{ matrix_appservice_webhooks_matrix_port }}";
proxy_pass http://$backend/$1;
}
Expand Down
Loading