Ansible Role mastodon
This role installs and configures Mastodon, a federated microblogging platform, as Podman containers.
Mandatory Requirements
Enable the PostgreSQL repository. This can be done using the linuxfabrik.lfops.repo_postgresql role.
Install the PostgreSQL server. This can be done using the linuxfabrik.lfops.postgresql_server role.
Create a PostgreSQL user for Mastodon. This can be done using the linuxfabrik.lfops.postgresql_server role.
Install Redis. This can be done using the linuxfabrik.lfops.repo_remi and linuxfabrik.lfops.redis role.
Enable the Elasticsearch repository (optional). This can be done using the linuxfabrik.lfops.repo_elasticsearch_oss role.
Install Elasticsearch (optional). This can be done using the linuxfabrik.lfops.elasticsearch_oss role.
On RHEL-compatible systems, enable the EPEL repository. This can be done using the linuxfabrik.lfops.repo_epel role.
Install Apache HTTPd. This can be done using the linuxfabrik.lfops.apache_httpd role.
If you use the „Setup Mastodon“ Playbook, this is automatically done for you (you still have to take care of providing the required versions).
Make sure the container can access the databases:
# PostgreSQL
postgresql_server__conf_listen_addresses:
- 'localhost'
- 'fqdn.example.com' # Allow access from container. Make sure the DNS entry (or /etc/hosts) points to the correct ip (not 127.)
# Redis
redis__conf_bind: 'fqdn.example.com' # Allow access from container. Make sure the DNS entry (or /etc/hosts) points to the correct ip (not 127.)
# Elasticsearch (if needed)
elasticsearch_oss__network_host: 'fqdn.example.com' # Allow access from container. Make sure the DNS entry (or /etc/hosts) points to the correct ip (not 127.)
Optional Requirements
It is recommended to set
Storage=presistent
in/etc/systemd/journald.conf
to allow the user to usejournalctl --user
. This can be done using the linuxfabrik.lfops.systemd_journald role.If the host should act as a Postfix MTA, make sure it is listening on the IP address so that the container can reach it. This can be done using the linuxfabrik.lfops.postfix role.
Mandatory Role Variables
Variable |
Description |
---|---|
|
Generate with |
|
Generate with |
|
Generate with |
|
This is the unique identifier of your server in the network. This cannot be safely changed later. It has to be the public domain name the server is running under. |
|
Generate with |
|
The user account for accessing the PostgreSQL database. |
|
Generate with |
|
Generate with |
|
Generate with |
Note: Secrets can be easily generated without installing Mastodon and Ruby locally by running the bundle commands in a temporary container, e.g. podman run --rm mastodon/mastodon:latest bundle exec rails secret
.
Example:
# mandatory
mastodon__active_record_encryption_deterministic_key: 'insecure_DO_NOT_USE_IN_PRODUCTION_Sml8YNpgR5KhSgbuDu2E2Ib2U3S4laEi'
mastodon__active_record_encryption_key_derivation_salt: 'insecure_DO_NOT_USE_IN_PRODUCTION_EnLFYG1GPMQq32Q3SD5ai0FkyxvKsq4h'
mastodon__active_record_encryption_primary_key: 'insecure_DO_NOT_USE_IN_PRODUCTION_NQtf5CQ0ttTfT7qCbxhrbVKqlNTgxIEW'
mastodon__domain: 'example.com'
mastodon__otp_secret: 'insecure_DO_NOT_USE_IN_PRODUCTION_b07d3de935e63a5caa30b687f876e042a6d9f93902aebcfb880fa3ae30449f27df5e8f2dfec6e8a21ad25166a2337b711fb964bdd2389ca4fd06c40bd0cac924'
mastodon__postgresql_login:
username: 'mastodon'
password: 'linuxfabrik'
state: 'present'
mastodon__secret_key_base: 'insecure_DO_NOT_USE_IN_PRODUCTION_565c24702495cfa599cae4a31d843016f020a8548b169500a4eb64eeb8f29745fe02778dd5b7690c84f627f24da24bb3855cc56800a4a752831ce61970561a95'
mastodon__vapid_private_key: 'insecure_DO_NOT_USE_IN_PRODUCTION_06bsp_1VMSn6fsLC41qoV_Qobgk6ptrrpCQkrsxHOAk='
mastodon__vapid_public_key: 'insecure_DO_NOT_USE_IN_PRODUCTION_BIKa90fBBxJ_iXZDYI6lB6lvoIXN_NfZ44wyC-j_QKEPhq-LaPXc0x-E_PKVjsrv0iBhGMcaWbYYHrKLSbN_pHY='
Optional Role Variables
Variable |
Description |
Default Value |
---|---|---|
|
Enables or disables the service, analogous to |
|
|
Changes the state of the service, analogous to |
|
|
Whether Elasticsearch support is enabled. |
|
|
The host on which Elasticsearch is reachable. |
|
|
The port on which Elasticsearch is reachable. |
|
|
How long Mastodon should retain records of IPs (in seconds). Make sure to modify the scheduling of |
|
|
The base distinguised name for the LDAP search. |
|
|
The bind distinguished name to authenticate against the LDAP server. |
|
|
Whether to enable the LDAP integration. |
|
|
The host on which LDAP is reachable. |
|
|
The LDAP attribute which Mastodon should use as the account e-mail address. |
|
|
The method to connect to the LDAP server. Possible options: |
|
|
The password for the LDAP bind distinguished name. |
|
|
The port on which LDAP is reachable. |
|
|
LDAP search filter for mapping users. Mastodon |
|
|
Whether Mastodon should not verify SSL connections to the LDAP server (e.g. when using self-signed certificates). |
|
|
The LDAP attribute which Mastodon should use as the account username. |
|
|
Mastodon does not allow certain characters in usernames. Enable automatic conversion of usernames that do not conform. |
|
|
The name of the PostgreSQL database. |
|
|
The host on which PostgreSQL is reachable. |
|
|
The port on which PostgreSQL is reachable. |
|
|
The host on which Redis is reachable. |
|
|
The password for the Redis instance, if authentication is enabled. |
|
|
The port on which Redis is reachable. |
|
|
How long Mastodon should retain records of sessions (in seconds). |
|
|
How Mastodon should authenticate against the SMTP server. Possible options: |
|
|
The from address Mastodon should use when sending email notifications. |
|
|
The login for the SMTP server Mastodon should use in order to send email notifications. |
|
|
How Mastodon should verify/enforce SSL connections to the SMTP server. Possible options: |
|
|
The password for the SMTP server Mastodon should use in order to send email notifications. |
|
|
The port Mastodon should use in order to send email notifications. |
|
|
The SMTP server Mastodon should use in order to send email notifications. |
|
|
The port on which the Mastodon streaming service will be available. |
|
|
The home directory of the user running Mastodon. |
|
|
A list of dictionaries containing Mastodon users. Subkeys:
host_vars / group_vars (can only be used in one group at a time). |
|
|
Which Mastodon version to install. Have a look at the available releases. |
|
|
To install Mastodon on |
|
|
The port on which the Mastodon web service will be available. |
|
Example:
# optional
mastodon__container_enabled: true
mastodon__container_state: 'started'
mastodon__elasticsearch_enabled: true
mastodon__elasticsearch_host: 'elasticsearch.example.com'
mastodon__elasticsearch_port: 9200
mastodon__ip_retention_period: 172800
mastodon__ldap_base: 'dc=example,dc=com'
mastodon__ldap_bind_dn: 'uid=freeipa-reader,cn=sysaccounts,cn=etc,dc=example,dc=com'
mastodon__ldap_enabled: true
mastodon__ldap_host: 'id.example.com'
mastodon__ldap_mail: 'mail'
mastodon__ldap_method: 'simple_tls'
mastodon__ldap_password: 'linuxfabrik'
mastodon__ldap_port: 636
mastodon__ldap_search_filter: '(&(|(%<uid>s=%<email>s)(%<mail>s=%<email>s))(objectclass=inetorgperson)(memberof=cn=mastodon_user_group,cn=groups,cn=accounts,dc=example,dc=com))'
mastodon__ldap_tls_no_verify: true
mastodon__ldap_uid: 'uid'
mastodon__ldap_uid_conversion_enabled: false
mastodon__postgresql_db_name: 'mastodon-example'
mastodon__postgresql_host: 'db.example.com'
mastodon__postgresql_port: 5432
mastodon__redis_host: 'redis.example.com'
mastodon__redis_password: 'linuxfabrik'
mastodon__redis_port: 6379
mastodon__session_retention_period: 172800
mastodon__smtp_auth_method: 'login'
mastodon__smtp_from_address: 'noreply@example.com'
mastodon__smtp_login: 'mastodon'
mastodon__smtp_openssl_verify_mode: false
mastodon__smtp_password: 'linuxfabrik'
mastodon__smtp_port: 25
mastodon__smtp_server: 'mail.example.com'
mastodon__streaming_port: 8081
mastodon__user_home_directory: '/opt/Mastodon'
mastodon__users__host_var:
- name: 'owner'
email: 'owner@example.com'
approve: true
confirm: true
role: 'Owner'
mastodon__version: 'v4.3.9'
mastodon__web_domain: 'social.example.com'
mastodon__web_port: 8080