Rename variables of Postmoogle to handle it as a bridge (#3698)

* Rename variables matrix_bot_postmoogle_* with matrix_postmoogle_*

Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>

* Rename file names and references to those files

Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>

* Move variables block for /matrix-bridge-postmoogle

Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>

* Rename matrix_playbook_bot_postmoogle_ to matrix_playbook_bridge_postmoogle_

Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>

* Add matrix_playbook_migration_matrix_postmoogle_migration_validation_enabled

Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>

* Replace an install tag example with "-bot" prefix

The previous example seems to have been selected to show how components whose name contains "-bot-" needed to be specified.

Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>

---------

Signed-off-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
Co-authored-by: Suguru Hirahara <acioustick@noreply.codeberg.org>
This commit is contained in:
Suguru Hirahara
2024-10-31 17:33:46 +09:00
committed by GitHub
parent fd39392ec5
commit 652feba9cc
18 changed files with 472 additions and 452 deletions

View File

@ -1,179 +0,0 @@
---
# postmoogle is an email to Matrix bridge using its bot user
# Project source code URL: https://github.com/etkecc/postmoogle
matrix_bot_postmoogle_enabled: true
matrix_bot_postmoogle_container_image_self_build: false
matrix_bot_postmoogle_docker_repo: "https://github.com/etkecc/postmoogle.git"
matrix_bot_postmoogle_docker_repo_version: "{{ 'main' if matrix_bot_postmoogle_version == 'latest' else matrix_bot_postmoogle_version }}"
matrix_bot_postmoogle_docker_src_files_path: "{{ matrix_base_data_path }}/postmoogle/docker-src"
# renovate: datasource=docker depName=ghcr.io/etkecc/postmoogle
matrix_bot_postmoogle_version: v0.9.23
matrix_bot_postmoogle_docker_image: "{{ matrix_bot_postmoogle_docker_image_name_prefix }}etkecc/postmoogle:{{ matrix_bot_postmoogle_version }}"
matrix_bot_postmoogle_docker_image_name_prefix: "{{ 'localhost/' if matrix_bot_postmoogle_container_image_self_build else 'ghcr.io/' }}"
matrix_bot_postmoogle_docker_image_force_pull: "{{ matrix_bot_postmoogle_docker_image.endswith(':latest') }}"
matrix_bot_postmoogle_base_path: "{{ matrix_base_data_path }}/postmoogle"
matrix_bot_postmoogle_config_path: "{{ matrix_bot_postmoogle_base_path }}/config"
matrix_bot_postmoogle_data_path: "{{ matrix_bot_postmoogle_base_path }}/data"
matrix_bot_postmoogle_container_network: ""
matrix_bot_postmoogle_container_additional_networks: "{{ matrix_bot_postmoogle_container_additional_networks_auto + matrix_bot_postmoogle_container_additional_networks_custom }}"
matrix_bot_postmoogle_container_additional_networks_auto: []
matrix_bot_postmoogle_container_additional_networks_custom: []
# A list of extra arguments to pass to the container
matrix_bot_postmoogle_container_extra_arguments: []
# List of systemd services that matrix-bot-postmoogle.service depends on
matrix_bot_postmoogle_systemd_required_services_list: "{{ matrix_bot_postmoogle_systemd_required_services_list_default + matrix_bot_postmoogle_systemd_required_services_list_auto + matrix_bot_postmoogle_systemd_required_services_list_custom }}"
matrix_bot_postmoogle_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}"
matrix_bot_postmoogle_systemd_required_services_list_auto: []
matrix_bot_postmoogle_systemd_required_services_list_custom: []
# List of systemd services that matrix-bot-postmoogle.service wants
matrix_bot_postmoogle_systemd_wanted_services_list: []
# Database-related configuration fields.
#
# To use SQLite, stick to these defaults.
#
# To use Postgres:
# - change the engine (`matrix_bot_postmoogle_database_engine: 'postgres'`)
# - adjust your database credentials via the `matrix_bot_postmoogle_database_*` variables
matrix_bot_postmoogle_database_engine: 'sqlite'
matrix_bot_postmoogle_sqlite_database_path_local: "{{ matrix_bot_postmoogle_data_path }}/bot.db"
matrix_bot_postmoogle_sqlite_database_path_in_container: "/data/bot.db"
matrix_bot_postmoogle_database_username: 'postmoogle'
matrix_bot_postmoogle_database_password: 'some-password'
matrix_bot_postmoogle_database_hostname: ''
matrix_bot_postmoogle_database_port: 5432
matrix_bot_postmoogle_database_name: 'postmoogle'
matrix_bot_postmoogle_database_sslmode: disable
matrix_bot_postmoogle_database_connection_string: 'postgres://{{ matrix_bot_postmoogle_database_username }}:{{ matrix_bot_postmoogle_database_password }}@{{ matrix_bot_postmoogle_database_hostname }}:{{ matrix_bot_postmoogle_database_port }}/{{ matrix_bot_postmoogle_database_name }}?sslmode={{ matrix_bot_postmoogle_database_sslmode }}'
matrix_bot_postmoogle_storage_database: "{{
{
'sqlite': matrix_bot_postmoogle_sqlite_database_path_in_container,
'postgres': matrix_bot_postmoogle_database_connection_string,
}[matrix_bot_postmoogle_database_engine]
}}"
matrix_bot_postmoogle_database_dialect: "{{
{
'sqlite': 'sqlite3',
'postgres': 'postgres',
}[matrix_bot_postmoogle_database_engine]
}}"
# The bot's username. This user needs to be created manually beforehand.
# Also see `matrix_bot_postmoogle_password` or `matrix_bot_postmoogle_sharedsecret`
matrix_bot_postmoogle_login: "postmoogle"
# The password that the bot uses to authenticate.
matrix_bot_postmoogle_password: ''
# Alternative to password - shared secret requires matrix_bot_postmoogle_login to be MXID
matrix_bot_postmoogle_sharedsecret: ''
matrix_bot_postmoogle_homeserver: ""
# Command prefix
matrix_bot_postmoogle_prefix: '!pm'
# Max email size in megabytes, including attachments
matrix_bot_postmoogle_maxsize: '1024'
# Optional SMTP relay mode
matrix_bot_postmoogle_relay_host: ''
matrix_bot_postmoogle_relay_port: ''
matrix_bot_postmoogle_relay_username: ''
matrix_bot_postmoogle_relay_password: ''
# A list of admins
# Example set of rules:
# matrix_bot_postmoogle_admins:
# - '@someone:example.com'
# - '@another:example.com'
# - '@bot.*:example.com'
# - '@*:example.net'
matrix_bot_postmoogle_admins: "{{ [matrix_admin] if matrix_admin else [] }}"
# Sentry DSN. Deprecated, use matrix_bot_postmoogle_monitoring_sentry_dsn
matrix_bot_postmoogle_sentry: ''
# Sentry integration
matrix_bot_postmoogle_monitoring_sentry_dsn: "{{ matrix_bot_postmoogle_sentry }}"
matrix_bot_postmoogle_monitoring_sentry_rate: 20
# healthchecks.io integration
matrix_bot_postmoogle_monitoring_healthchecks_uuid: ''
matrix_bot_postmoogle_monitoring_healthchecks_duration: 60
# Log level
matrix_bot_postmoogle_loglevel: 'INFO'
# deprecated, use matrix_bot_postmoogle_domains
matrix_bot_postmoogle_domain: "{{ matrix_server_fqn_matrix }}"
matrix_bot_postmoogle_domains:
- "{{ matrix_bot_postmoogle_domain }}" # backward compatibility
# Password (passphrase) to encrypt account data
matrix_bot_postmoogle_data_secret: ""
# in-container ports
matrix_bot_postmoogle_port: '2525'
matrix_bot_postmoogle_tls_port: '25587'
# on-host ports
matrix_bot_postmoogle_smtp_host_bind_port: '25'
matrix_bot_postmoogle_submission_host_bind_port: '587'
### SSL
## on-host SSL dir
matrix_bot_postmoogle_ssl_path: ""
## in-container SSL paths
# matrix_bot_postmoogle_tls_cert is the SSL certificates' certificates.
# This var is likely set via group_vars/matrix_servers, so you don't need to set certs manually.
# If you do need to set it manually, note that this is an in-container path.
# To mount a certificates volumes into the container, use matrix_bot_postmoogle_ssl_path
# Example value: /ssl/live/{{ matrix_bot_postmoogle_domain }}/fullchain.pem
matrix_bot_postmoogle_tls_cert: ""
# matrix_bot_postmoogle_tls_key is the SSL certificates' keys.
# This var is likely set via group_vars/matrix_servers, so you don't need to set keys manually.
# If you do need to set it manually, note that this is an in-container path.
# To mount a certificates volumes into the container, use matrix_bot_postmoogle_ssl_path
# Example value: /ssl/live/{{ matrix_bot_postmoogle_domain }}/privkey.pem
matrix_bot_postmoogle_tls_key: ""
# Mandatory TLS, even on plain SMTP port
matrix_bot_postmoogle_tls_required: false
# trusted proxies
matrix_bot_postmoogle_proxies: []
# known forwarders
matrix_bot_postmoogle_mailboxes_forwarded: []
# reserved mailboxes
matrix_bot_postmoogle_mailboxes_reserved: []
# mailbox activation flow
matrix_bot_postmoogle_mailboxes_activation: none
# Additional environment variables to pass to the postmoogle container
#
# Example:
# matrix_bot_postmoogle_environment_variables_extension: |
# postmoogle_TEXT_DONE=Done
matrix_bot_postmoogle_environment_variables_extension: ''

View File

@ -1,94 +0,0 @@
---
- when: "matrix_bot_postmoogle_database_engine == 'postgres'"
block:
- name: Check if an SQLite database already exists
ansible.builtin.stat:
path: "{{ matrix_bot_postmoogle_sqlite_database_path_local }}"
register: matrix_bot_postmoogle_sqlite_database_path_local_stat_result
- when: "matrix_bot_postmoogle_sqlite_database_path_local_stat_result.stat.exists | bool"
block:
- ansible.builtin.include_role:
name: galaxy/postgres
tasks_from: migrate_db_to_postgres
vars:
postgres_db_migration_request:
src: "{{ matrix_bot_postmoogle_sqlite_database_path_local }}"
dst: "{{ matrix_bot_postmoogle_database_connection_string }}"
caller: "{{ role_path | basename }}"
engine_variable_name: 'matrix_bot_postmoogle_database_engine'
engine_old: 'sqlite'
systemd_services_to_stop: ['matrix-bot-postmoogle.service']
- ansible.builtin.set_fact:
matrix_bot_postmoogle_requires_restart: true
- name: Ensure postmoogle paths exist
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
mode: 0750
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
with_items:
- {path: "{{ matrix_bot_postmoogle_config_path }}", when: true}
- {path: "{{ matrix_bot_postmoogle_data_path }}", when: true}
- {path: "{{ matrix_bot_postmoogle_docker_src_files_path }}", when: matrix_bot_postmoogle_container_image_self_build}
when: "item.when | bool"
- name: Ensure postmoogle environment variables file created
ansible.builtin.template:
src: "{{ role_path }}/templates/env.j2"
dest: "{{ matrix_bot_postmoogle_config_path }}/env"
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
mode: 0640
- name: Ensure postmoogle image is pulled
community.docker.docker_image:
name: "{{ matrix_bot_postmoogle_docker_image }}"
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_bot_postmoogle_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_postmoogle_docker_image_force_pull }}"
when: "not matrix_bot_postmoogle_container_image_self_build | bool"
register: result
retries: "{{ devture_playbook_help_container_retries_count }}"
delay: "{{ devture_playbook_help_container_retries_delay }}"
until: result is not failed
- name: Ensure postmoogle repository is present on self-build
ansible.builtin.git:
repo: "{{ matrix_bot_postmoogle_docker_repo }}"
version: "{{ matrix_bot_postmoogle_docker_repo_version }}"
dest: "{{ matrix_bot_postmoogle_docker_src_files_path }}"
force: "yes"
become: true
become_user: "{{ matrix_user_username }}"
register: matrix_bot_postmoogle_git_pull_results
when: "matrix_bot_postmoogle_container_image_self_build | bool"
- name: Ensure postmoogle image is built
community.docker.docker_image:
name: "{{ matrix_bot_postmoogle_docker_image }}"
source: build
force_source: "{{ matrix_bot_postmoogle_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_postmoogle_git_pull_results.changed }}"
build:
dockerfile: Dockerfile
path: "{{ matrix_bot_postmoogle_docker_src_files_path }}"
pull: true
when: "matrix_bot_postmoogle_container_image_self_build | bool"
- name: Ensure postmoogle container network is created
community.general.docker_network:
enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
name: "{{ matrix_bot_postmoogle_container_network }}"
driver: bridge
driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
- name: Ensure matrix-bot-postmoogle.service installed
ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-bot-postmoogle.service.j2"
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-postmoogle.service"
mode: 0644
register: matrix_bot_postmoogle_systemd_service_result

View File

@ -1,12 +0,0 @@
---
- name: Fail if required Postmoogle settings not defined
ansible.builtin.fail:
msg: >-
You need to define a required configuration setting (`{{ item.name }}`).
when: "item.when | bool and vars[item.name] == ''"
with_items:
- {'name': 'matrix_bot_postmoogle_password', when: true}
- {'name': 'matrix_bot_postmoogle_container_network', when: true}
- {'name': 'matrix_bot_postmoogle_homeserver', when: true}
- {'name': 'matrix_bot_postmoogle_database_hostname', when: "{{ matrix_bot_postmoogle_database_engine == 'postgres' }}"}

View File

@ -1,31 +0,0 @@
POSTMOOGLE_LOGIN={{ matrix_bot_postmoogle_login }}
POSTMOOGLE_PASSWORD={{ matrix_bot_postmoogle_password }}
POSTMOOGLE_SHAREDSECRET={{ matrix_bot_postmoogle_sharedsecret }}
POSTMOOGLE_HOMESERVER={{ matrix_bot_postmoogle_homeserver }}
POSTMOOGLE_DOMAINS={{ matrix_bot_postmoogle_domains | join(' ') }}
POSTMOOGLE_PORT={{ matrix_bot_postmoogle_port }}
POSTMOOGLE_DB_DSN={{ matrix_bot_postmoogle_database_connection_string }}
POSTMOOGLE_DB_DIALECT={{ matrix_bot_postmoogle_database_dialect }}
POSTMOOGLE_PREFIX={{ matrix_bot_postmoogle_prefix }}
POSTMOOGLE_MAXSIZE={{ matrix_bot_postmoogle_maxsize }}
POSTMOOGLE_LOGLEVEL={{ matrix_bot_postmoogle_loglevel }}
POSTMOOGLE_ADMINS={{ matrix_bot_postmoogle_admins | join(' ') }}
POSTMOOGLE_TLS_PORT={{ matrix_bot_postmoogle_tls_port }}
POSTMOOGLE_TLS_CERT={{ matrix_bot_postmoogle_tls_cert }}
POSTMOOGLE_TLS_KEY={{ matrix_bot_postmoogle_tls_key }}
POSTMOOGLE_TLS_REQUIRED={{ matrix_bot_postmoogle_tls_required }}
POSTMOOGLE_DATA_SECRET={{ matrix_bot_postmoogle_data_secret }}
POSTMOOGLE_PROXIES={{ matrix_bot_postmoogle_proxies | join(' ') }}
POSTMOOGLE_RELAY_HOST={{ matrix_bot_postmoogle_relay_host }}
POSTMOOGLE_RELAY_PORT={{ matrix_bot_postmoogle_relay_port }}
POSTMOOGLE_RELAY_USERNAME={{ matrix_bot_postmoogle_relay_username }}
POSTMOOGLE_RELAY_PASSWORD={{ matrix_bot_postmoogle_relay_password }}
POSTMOOGLE_MONITORING_SENTRY_DSN={{ matrix_bot_postmoogle_monitoring_sentry_dsn }}
POSTMOOGLE_MONITORING_SENTRY_RATE={{ matrix_bot_postmoogle_monitoring_sentry_rate }}
POSTMOOGLE_MONITORING_HEALTHCHECKS_UUID={{ matrix_bot_postmoogle_monitoring_healthchecks_uuid }}
POSTMOOGLE_MONITORING_HEALTHCHECKS_DURATION={{ matrix_bot_postmoogle_monitoring_healthchecks_duration }}
POSTMOOGLE_MAILBOXES_FORWARDED={{ matrix_bot_postmoogle_mailboxes_forwarded | join(' ') }}
POSTMOOGLE_MAILBOXES_RESERVED={{ matrix_bot_postmoogle_mailboxes_reserved | join(' ') }}
POSTMOOGLE_MAILBOXES_ACTIVATION={{ matrix_bot_postmoogle_mailboxes_activation }}
{{ matrix_bot_postmoogle_environment_variables_extension }}

View File

@ -0,0 +1,179 @@
---
# postmoogle is an email to Matrix bridge using its bot user
# Project source code URL: https://github.com/etkecc/postmoogle
matrix_postmoogle_enabled: true
matrix_postmoogle_container_image_self_build: false
matrix_postmoogle_docker_repo: "https://github.com/etkecc/postmoogle.git"
matrix_postmoogle_docker_repo_version: "{{ 'main' if matrix_postmoogle_version == 'latest' else matrix_postmoogle_version }}"
matrix_postmoogle_docker_src_files_path: "{{ matrix_base_data_path }}/postmoogle/docker-src"
# renovate: datasource=docker depName=ghcr.io/etkecc/postmoogle
matrix_postmoogle_version: v0.9.23
matrix_postmoogle_docker_image: "{{ matrix_postmoogle_docker_image_name_prefix }}etkecc/postmoogle:{{ matrix_postmoogle_version }}"
matrix_postmoogle_docker_image_name_prefix: "{{ 'localhost/' if matrix_postmoogle_container_image_self_build else 'ghcr.io/' }}"
matrix_postmoogle_docker_image_force_pull: "{{ matrix_postmoogle_docker_image.endswith(':latest') }}"
matrix_postmoogle_base_path: "{{ matrix_base_data_path }}/postmoogle"
matrix_postmoogle_config_path: "{{ matrix_postmoogle_base_path }}/config"
matrix_postmoogle_data_path: "{{ matrix_postmoogle_base_path }}/data"
matrix_postmoogle_container_network: ""
matrix_postmoogle_container_additional_networks: "{{ matrix_postmoogle_container_additional_networks_auto + matrix_postmoogle_container_additional_networks_custom }}"
matrix_postmoogle_container_additional_networks_auto: []
matrix_postmoogle_container_additional_networks_custom: []
# A list of extra arguments to pass to the container
matrix_postmoogle_container_extra_arguments: []
# List of systemd services that matrix-postmoogle.service depends on
matrix_postmoogle_systemd_required_services_list: "{{ matrix_postmoogle_systemd_required_services_list_default + matrix_postmoogle_systemd_required_services_list_auto + matrix_postmoogle_systemd_required_services_list_custom }}"
matrix_postmoogle_systemd_required_services_list_default: "{{ [devture_systemd_docker_base_docker_service_name] if devture_systemd_docker_base_docker_service_name else [] }}"
matrix_postmoogle_systemd_required_services_list_auto: []
matrix_postmoogle_systemd_required_services_list_custom: []
# List of systemd services that matrix-postmoogle.service wants
matrix_postmoogle_systemd_wanted_services_list: []
# Database-related configuration fields.
#
# To use SQLite, stick to these defaults.
#
# To use Postgres:
# - change the engine (`matrix_postmoogle_database_engine: 'postgres'`)
# - adjust your database credentials via the `matrix_postmoogle_database_*` variables
matrix_postmoogle_database_engine: 'sqlite'
matrix_postmoogle_sqlite_database_path_local: "{{ matrix_postmoogle_data_path }}/bot.db"
matrix_postmoogle_sqlite_database_path_in_container: "/data/bot.db"
matrix_postmoogle_database_username: 'postmoogle'
matrix_postmoogle_database_password: 'some-password'
matrix_postmoogle_database_hostname: ''
matrix_postmoogle_database_port: 5432
matrix_postmoogle_database_name: 'postmoogle'
matrix_postmoogle_database_sslmode: disable
matrix_postmoogle_database_connection_string: 'postgres://{{ matrix_postmoogle_database_username }}:{{ matrix_postmoogle_database_password }}@{{ matrix_postmoogle_database_hostname }}:{{ matrix_postmoogle_database_port }}/{{ matrix_postmoogle_database_name }}?sslmode={{ matrix_postmoogle_database_sslmode }}'
matrix_postmoogle_storage_database: "{{
{
'sqlite': matrix_postmoogle_sqlite_database_path_in_container,
'postgres': matrix_postmoogle_database_connection_string,
}[matrix_postmoogle_database_engine]
}}"
matrix_postmoogle_database_dialect: "{{
{
'sqlite': 'sqlite3',
'postgres': 'postgres',
}[matrix_postmoogle_database_engine]
}}"
# The bot's username. This user needs to be created manually beforehand.
# Also see `matrix_postmoogle_password` or `matrix_postmoogle_sharedsecret`
matrix_postmoogle_login: "postmoogle"
# The password that the bot uses to authenticate.
matrix_postmoogle_password: ''
# Alternative to password - shared secret requires matrix_postmoogle_login to be MXID
matrix_postmoogle_sharedsecret: ''
matrix_postmoogle_homeserver: ""
# Command prefix
matrix_postmoogle_prefix: '!pm'
# Max email size in megabytes, including attachments
matrix_postmoogle_maxsize: '1024'
# Optional SMTP relay mode
matrix_postmoogle_relay_host: ''
matrix_postmoogle_relay_port: ''
matrix_postmoogle_relay_username: ''
matrix_postmoogle_relay_password: ''
# A list of admins
# Example set of rules:
# matrix_postmoogle_admins:
# - '@someone:example.com'
# - '@another:example.com'
# - '@bot.*:example.com'
# - '@*:example.net'
matrix_postmoogle_admins: "{{ [matrix_admin] if matrix_admin else [] }}"
# Sentry DSN. Deprecated, use matrix_postmoogle_monitoring_sentry_dsn
matrix_postmoogle_sentry: ''
# Sentry integration
matrix_postmoogle_monitoring_sentry_dsn: "{{ matrix_postmoogle_sentry }}"
matrix_postmoogle_monitoring_sentry_rate: 20
# healthchecks.io integration
matrix_postmoogle_monitoring_healthchecks_uuid: ''
matrix_postmoogle_monitoring_healthchecks_duration: 60
# Log level
matrix_postmoogle_loglevel: 'INFO'
# deprecated, use matrix_postmoogle_domains
matrix_postmoogle_domain: "{{ matrix_server_fqn_matrix }}"
matrix_postmoogle_domains:
- "{{ matrix_postmoogle_domain }}" # backward compatibility
# Password (passphrase) to encrypt account data
matrix_postmoogle_data_secret: ""
# in-container ports
matrix_postmoogle_port: '2525'
matrix_postmoogle_tls_port: '25587'
# on-host ports
matrix_postmoogle_smtp_host_bind_port: '25'
matrix_postmoogle_submission_host_bind_port: '587'
### SSL
## on-host SSL dir
matrix_postmoogle_ssl_path: ""
## in-container SSL paths
# matrix_postmoogle_tls_cert is the SSL certificates' certificates.
# This var is likely set via group_vars/matrix_servers, so you don't need to set certs manually.
# If you do need to set it manually, note that this is an in-container path.
# To mount a certificates volumes into the container, use matrix_postmoogle_ssl_path
# Example value: /ssl/live/{{ matrix_postmoogle_domain }}/fullchain.pem
matrix_postmoogle_tls_cert: ""
# matrix_postmoogle_tls_key is the SSL certificates' keys.
# This var is likely set via group_vars/matrix_servers, so you don't need to set keys manually.
# If you do need to set it manually, note that this is an in-container path.
# To mount a certificates volumes into the container, use matrix_postmoogle_ssl_path
# Example value: /ssl/live/{{ matrix_postmoogle_domain }}/privkey.pem
matrix_postmoogle_tls_key: ""
# Mandatory TLS, even on plain SMTP port
matrix_postmoogle_tls_required: false
# trusted proxies
matrix_postmoogle_proxies: []
# known forwarders
matrix_postmoogle_mailboxes_forwarded: []
# reserved mailboxes
matrix_postmoogle_mailboxes_reserved: []
# mailbox activation flow
matrix_postmoogle_mailboxes_activation: none
# Additional environment variables to pass to the postmoogle container
#
# Example:
# matrix_postmoogle_environment_variables_extension: |
# postmoogle_TEXT_DONE=Done
matrix_postmoogle_environment_variables_extension: ''

View File

@ -2,19 +2,19 @@
- tags:
- setup-all
- setup-bot-postmoogle
- setup-postmoogle
- install-all
- install-bot-postmoogle
- install-postmoogle
block:
- when: matrix_bot_postmoogle_enabled | bool
- when: matrix_postmoogle_enabled | bool
ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml"
- when: matrix_bot_postmoogle_enabled | bool
- when: matrix_postmoogle_enabled | bool
ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_install.yml"
- tags:
- setup-all
- setup-bot-postmoogle
- setup-postmoogle
block:
- when: not matrix_bot_postmoogle_enabled | bool
- when: not matrix_postmoogle_enabled | bool
ansible.builtin.include_tasks: "{{ role_path }}/tasks/setup_uninstall.yml"

View File

@ -0,0 +1,94 @@
---
- when: "matrix_postmoogle_database_engine == 'postgres'"
block:
- name: Check if an SQLite database already exists
ansible.builtin.stat:
path: "{{ matrix_postmoogle_sqlite_database_path_local }}"
register: matrix_postmoogle_sqlite_database_path_local_stat_result
- when: "matrix_postmoogle_sqlite_database_path_local_stat_result.stat.exists | bool"
block:
- ansible.builtin.include_role:
name: galaxy/postgres
tasks_from: migrate_db_to_postgres
vars:
postgres_db_migration_request:
src: "{{ matrix_postmoogle_sqlite_database_path_local }}"
dst: "{{ matrix_postmoogle_database_connection_string }}"
caller: "{{ role_path | basename }}"
engine_variable_name: 'matrix_postmoogle_database_engine'
engine_old: 'sqlite'
systemd_services_to_stop: ['matrix-postmoogle.service']
- ansible.builtin.set_fact:
matrix_postmoogle_requires_restart: true
- name: Ensure postmoogle paths exist
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
mode: 0750
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
with_items:
- {path: "{{ matrix_postmoogle_config_path }}", when: true}
- {path: "{{ matrix_postmoogle_data_path }}", when: true}
- {path: "{{ matrix_postmoogle_docker_src_files_path }}", when: matrix_postmoogle_container_image_self_build}
when: "item.when | bool"
- name: Ensure postmoogle environment variables file created
ansible.builtin.template:
src: "{{ role_path }}/templates/env.j2"
dest: "{{ matrix_postmoogle_config_path }}/env"
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
mode: 0640
- name: Ensure postmoogle image is pulled
community.docker.docker_image:
name: "{{ matrix_postmoogle_docker_image }}"
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_postmoogle_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_postmoogle_docker_image_force_pull }}"
when: "not matrix_postmoogle_container_image_self_build | bool"
register: result
retries: "{{ devture_playbook_help_container_retries_count }}"
delay: "{{ devture_playbook_help_container_retries_delay }}"
until: result is not failed
- name: Ensure postmoogle repository is present on self-build
ansible.builtin.git:
repo: "{{ matrix_postmoogle_docker_repo }}"
version: "{{ matrix_postmoogle_docker_repo_version }}"
dest: "{{ matrix_postmoogle_docker_src_files_path }}"
force: "yes"
become: true
become_user: "{{ matrix_user_username }}"
register: matrix_postmoogle_git_pull_results
when: "matrix_postmoogle_container_image_self_build | bool"
- name: Ensure postmoogle image is built
community.docker.docker_image:
name: "{{ matrix_postmoogle_docker_image }}"
source: build
force_source: "{{ matrix_postmoogle_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_postmoogle_git_pull_results.changed }}"
build:
dockerfile: Dockerfile
path: "{{ matrix_postmoogle_docker_src_files_path }}"
pull: true
when: "matrix_postmoogle_container_image_self_build | bool"
- name: Ensure postmoogle container network is created
community.general.docker_network:
enable_ipv6: "{{ devture_systemd_docker_base_ipv6_enabled }}"
name: "{{ matrix_postmoogle_container_network }}"
driver: bridge
driver_options: "{{ devture_systemd_docker_base_container_networks_driver_options }}"
- name: Ensure matrix-postmoogle.service installed
ansible.builtin.template:
src: "{{ role_path }}/templates/systemd/matrix-postmoogle.service.j2"
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-postmoogle.service"
mode: 0644
register: matrix_postmoogle_systemd_service_result

View File

@ -2,24 +2,24 @@
- name: Check existence of matrix-postmoogle service
ansible.builtin.stat:
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-postmoogle.service"
register: matrix_bot_postmoogle_service_stat
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-postmoogle.service"
register: matrix_postmoogle_service_stat
- when: matrix_bot_postmoogle_service_stat.stat.exists | bool
- when: matrix_postmoogle_service_stat.stat.exists | bool
block:
- name: Ensure matrix-postmoogle is stopped
ansible.builtin.service:
name: matrix-bot-postmoogle
name: matrix-postmoogle
state: stopped
enabled: false
daemon_reload: true
- name: Ensure matrix-bot-postmoogle.service doesn't exist
- name: Ensure matrix-postmoogle.service doesn't exist
ansible.builtin.file:
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-bot-postmoogle.service"
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-postmoogle.service"
state: absent
- name: Ensure Matrix postmoogle paths don't exist
ansible.builtin.file:
path: "{{ matrix_bot_postmoogle_base_path }}"
path: "{{ matrix_postmoogle_base_path }}"
state: absent

View File

@ -0,0 +1,12 @@
---
- name: Fail if required Postmoogle settings not defined
ansible.builtin.fail:
msg: >-
You need to define a required configuration setting (`{{ item.name }}`).
when: "item.when | bool and vars[item.name] == ''"
with_items:
- {'name': 'matrix_postmoogle_password', when: true}
- {'name': 'matrix_postmoogle_container_network', when: true}
- {'name': 'matrix_postmoogle_homeserver', when: true}
- {'name': 'matrix_postmoogle_database_hostname', when: "{{ matrix_postmoogle_database_engine == 'postgres' }}"}

View File

@ -0,0 +1,31 @@
POSTMOOGLE_LOGIN={{ matrix_postmoogle_login }}
POSTMOOGLE_PASSWORD={{ matrix_postmoogle_password }}
POSTMOOGLE_SHAREDSECRET={{ matrix_postmoogle_sharedsecret }}
POSTMOOGLE_HOMESERVER={{ matrix_postmoogle_homeserver }}
POSTMOOGLE_DOMAINS={{ matrix_postmoogle_domains | join(' ') }}
POSTMOOGLE_PORT={{ matrix_postmoogle_port }}
POSTMOOGLE_DB_DSN={{ matrix_postmoogle_database_connection_string }}
POSTMOOGLE_DB_DIALECT={{ matrix_postmoogle_database_dialect }}
POSTMOOGLE_PREFIX={{ matrix_postmoogle_prefix }}
POSTMOOGLE_MAXSIZE={{ matrix_postmoogle_maxsize }}
POSTMOOGLE_LOGLEVEL={{ matrix_postmoogle_loglevel }}
POSTMOOGLE_ADMINS={{ matrix_postmoogle_admins | join(' ') }}
POSTMOOGLE_TLS_PORT={{ matrix_postmoogle_tls_port }}
POSTMOOGLE_TLS_CERT={{ matrix_postmoogle_tls_cert }}
POSTMOOGLE_TLS_KEY={{ matrix_postmoogle_tls_key }}
POSTMOOGLE_TLS_REQUIRED={{ matrix_postmoogle_tls_required }}
POSTMOOGLE_DATA_SECRET={{ matrix_postmoogle_data_secret }}
POSTMOOGLE_PROXIES={{ matrix_postmoogle_proxies | join(' ') }}
POSTMOOGLE_RELAY_HOST={{ matrix_postmoogle_relay_host }}
POSTMOOGLE_RELAY_PORT={{ matrix_postmoogle_relay_port }}
POSTMOOGLE_RELAY_USERNAME={{ matrix_postmoogle_relay_username }}
POSTMOOGLE_RELAY_PASSWORD={{ matrix_postmoogle_relay_password }}
POSTMOOGLE_MONITORING_SENTRY_DSN={{ matrix_postmoogle_monitoring_sentry_dsn }}
POSTMOOGLE_MONITORING_SENTRY_RATE={{ matrix_postmoogle_monitoring_sentry_rate }}
POSTMOOGLE_MONITORING_HEALTHCHECKS_UUID={{ matrix_postmoogle_monitoring_healthchecks_uuid }}
POSTMOOGLE_MONITORING_HEALTHCHECKS_DURATION={{ matrix_postmoogle_monitoring_healthchecks_duration }}
POSTMOOGLE_MAILBOXES_FORWARDED={{ matrix_postmoogle_mailboxes_forwarded | join(' ') }}
POSTMOOGLE_MAILBOXES_RESERVED={{ matrix_postmoogle_mailboxes_reserved | join(' ') }}
POSTMOOGLE_MAILBOXES_ACTIVATION={{ matrix_postmoogle_mailboxes_activation }}
{{ matrix_postmoogle_environment_variables_extension }}

View File

@ -1,11 +1,11 @@
#jinja2: lstrip_blocks: "True"
[Unit]
Description=Matrix Postmoogle bot
{% for service in matrix_bot_postmoogle_systemd_required_services_list %}
Description=Matrix Postmoogle bridge
{% for service in matrix_postmoogle_systemd_required_services_list %}
Requires={{ service }}
After={{ service }}
{% endfor %}
{% for service in matrix_bot_postmoogle_systemd_wanted_services_list %}
{% for service in matrix_postmoogle_systemd_wanted_services_list %}
Wants={{ service }}
{% endfor %}
DefaultDependencies=no
@ -13,42 +13,42 @@ DefaultDependencies=no
[Service]
Type=simple
Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}"
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop --time={{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-bot-postmoogle 2>/dev/null || true'
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-bot-postmoogle 2>/dev/null || true'
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop --time={{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-postmoogle 2>/dev/null || true'
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-postmoogle 2>/dev/null || true'
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
--rm \
--name=matrix-bot-postmoogle \
--name=matrix-postmoogle \
--log-driver=none \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
--cap-drop=ALL \
--read-only \
--network={{ matrix_bot_postmoogle_container_network }} \
--env-file={{ matrix_bot_postmoogle_config_path }}/env \
-p {{ matrix_bot_postmoogle_smtp_host_bind_port }}:{{ matrix_bot_postmoogle_port }} \
{% if matrix_bot_postmoogle_ssl_path %}
-p {{ matrix_bot_postmoogle_submission_host_bind_port }}:{{ matrix_bot_postmoogle_tls_port }} \
--network={{ matrix_postmoogle_container_network }} \
--env-file={{ matrix_postmoogle_config_path }}/env \
-p {{ matrix_postmoogle_smtp_host_bind_port }}:{{ matrix_postmoogle_port }} \
{% if matrix_postmoogle_ssl_path %}
-p {{ matrix_postmoogle_submission_host_bind_port }}:{{ matrix_postmoogle_tls_port }} \
{% endif %}
--mount type=bind,src={{ matrix_bot_postmoogle_data_path }},dst=/data \
{% if matrix_bot_postmoogle_ssl_path %}
--mount type=bind,src={{ matrix_bot_postmoogle_ssl_path }},dst=/ssl \
--mount type=bind,src={{ matrix_postmoogle_data_path }},dst=/data \
{% if matrix_postmoogle_ssl_path %}
--mount type=bind,src={{ matrix_postmoogle_ssl_path }},dst=/ssl \
{% endif %}
{% for arg in matrix_bot_postmoogle_container_extra_arguments %}
{% for arg in matrix_postmoogle_container_extra_arguments %}
{{ arg }} \
{% endfor %}
{{ matrix_bot_postmoogle_docker_image }}
{{ matrix_postmoogle_docker_image }}
{% for network in matrix_bot_postmoogle_container_additional_networks %}
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-bot-postmoogle
{% for network in matrix_postmoogle_container_additional_networks %}
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-postmoogle
{% endfor %}
ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-bot-postmoogle
ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-postmoogle
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop --time={{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-bot-postmoogle 2>/dev/null || true'
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-bot-postmoogle 2>/dev/null || true'
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop --time={{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-postmoogle 2>/dev/null || true'
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-postmoogle 2>/dev/null || true'
Restart=always
RestartSec=30
SyslogIdentifier=matrix-bot-postmoogle
SyslogIdentifier=matrix-postmoogle
[Install]
WantedBy=multi-user.target

View File

@ -27,6 +27,9 @@ matrix_playbook_migration_matrix_aux_migration_validation_enabled: true
# Controls if (`matrix_jitsi` -> `jitsi`) validation will run.
matrix_playbook_migration_matrix_jitsi_migration_validation_enabled: true
# Controls if (`matrix_bot_postmoogle_` -> `matrix_postmoogle_`) validation will run.
matrix_playbook_migration_matrix_postmoogle_migration_validation_enabled: true
# Controls if the old apt repository (likely without a `signed-by` option) on Debian-based systems will be removed.
#
# Older versions of the Docker role (5.x, 6.x) used to install a repository at a path like: `/etc/apt/sources.list.d/download_docker_com_linux_*`

View File

@ -223,6 +223,20 @@
We found usage of the following variables: {{ matrix_playbook_migration_jitsi_migration_vars.keys() | join(', ') }}
when: "matrix_playbook_migration_jitsi_migration_vars | length > 0"
- when: matrix_playbook_migration_matrix_postmoogle_migration_validation_enabled | bool
block:
- ansible.builtin.set_fact:
matrix_playbook_migration_postmoogle_migration_vars: |-
{{ vars | dict2items | selectattr('key', 'match', 'matrix_postmoogle_.*') | list | items2dict }}
- name: (Deprecation) Catch and report matrix_bot_postmoogle variables
ansible.builtin.fail:
msg: >-
Your configuration contains a variable, which now has a different name.
Please change your configuration (vars.yml) to rename all variables (`matrix_bot_postmoogle_` -> `matrix_postmoogle_`).
We found usage of the following variables: {{ matrix_playbook_migration_postmoogle_migration_vars.keys() | join(', ') }}
when: "matrix_playbook_migration_postmoogle_migration_vars | length > 0"
- when: matrix_playbook_migration_matrix_nginx_proxy_elimination_variable_transition_checks_enabled | bool
block:
- name: (Deprecation) Catch and report transitioned playbook settings during the matrix-nginx-proxy elimination