feat(mastodon): release mastodon

This commit is contained in:
il
2026-07-05 23:25:42 +09:00
parent 3c8469e604
commit e0df8cfba5
24 changed files with 1338 additions and 62 deletions
+26 -12
View File
@@ -140,9 +140,9 @@ services:
dependency:
web: "auth-public"
db: "postgresql"
# app
redis:
subuid: "100998"
# app
homepage:
domain:
public: "@"
@@ -179,6 +179,18 @@ services:
dependency:
web: "app-public"
db: "postgresql"
mastodon:
domain:
public: "mastodon"
internal: "mastodon.app"
ports:
http: "3006"
streaming: "4000"
redis: "6385"
subuid: "100990"
dependency:
web: "app-public"
db: "postgresql"
nextcloud:
domain:
public: "nextcloud"
@@ -277,11 +289,11 @@ services:
version:
packages:
sops: "3.13.1"
sops: "3.13.2"
step: "0.30.2"
kopia: "0.23.1"
blocky: "0.32.1"
alloy: "1.17.0"
blocky: "0.33.0"
alloy: "1.17.1"
containers:
# common
caddy: "2.11.4"
@@ -290,30 +302,32 @@ version:
## Postgresql
postgresql: "18.4"
### For immich - https://github.com/immich-app/base-images/blob/main/postgres/versions.yaml
### pgvector: "v0.8.1"
vectorchord: "1.1.1"
### For bonfire
postgis: "3"
## lldap
ldap: "v0.6.3"
## maddy
maddy: "0.9.5"
x509-exporter: "4.1.0"
prometheus: "v3.12.0"
prometheus: "v3.13.0"
loki: "3.7.3"
grafana: "13.0.2"
grafana: "13.1.0"
# Auth
authelia: "4.39.20"
# App
vaultwarden: "1.36.0"
gitea: "1.26.4"
redis: "8.8.0"
immich: "v2.7.5"
immich: "v3.0.1"
paperless: "2.20.15"
nextcloud: "34.0.0"
collabora: "26.04.1.4.1"
sure: "0.7.1-hotfix.1"
nextcloud: "34.0.1"
collabora: "26.04.2.1.1"
sure: "0.7.2"
outline: "1.8.1"
memos: "0.29.1"
mealie: "v3.19.2"
mealie: "v3.20.1"
homebox: "0.26.2"
homepage: "v1.13.2"
snappymail: "v2.38.2"
mastodon: "v4.6.3"
+14 -3
View File
@@ -22,12 +22,23 @@ hardware:
slot: "0x02"
function: "0x0"
disk:
# NVMe is set when the hypervisor is initiated manually.
nvme:
serials:
- "S5GXNX0T228635E"
fs:
type: "ext4"
label: ""
mount_point:
- "/"
- "/var/lib/libvirt"
mount_opts: ""
data:
serials:
- "WMC6N0E617S8"
- "P6HVTL0W"
- "P2GH354H"
- "P6GJKSMP"
- "PN1134P6HVTL0W"
- "PN1138P2GH354H"
- "PN2131P6GJKSMP"
fs:
type: "btrfs"
label: "DATA"
+8
View File
@@ -266,6 +266,14 @@
tags: ["site", "homebox"]
tags: ["site", "homebox"]
- name: Set mastodon
ansible.builtin.include_role:
name: "app"
tasks_from: "services/set_mastodon"
apply:
tags: ["site", "mastodon"]
tags: ["site", "mastodon"]
- name: Set homepage
ansible.builtin.include_role:
name: "app"
+15
View File
@@ -157,3 +157,18 @@
changed_when: false
listen: "notification_restart_snappymail"
ignore_errors: true # noqa: ignore-errors
- name: Restart mastodon
ansible.builtin.systemd:
name: "{{ item }}"
state: "restarted"
enabled: true
scope: "user"
daemon_reload: true
loop:
- "mastodon-web.service"
- "mastodon-worker.service"
- "mastodon-streaming.service"
changed_when: false
listen: "notification_restart_mastodon"
ignore_errors: true # noqa: ignore-errors
@@ -0,0 +1,276 @@
---
- name: Set redis service name
ansible.builtin.set_fact:
redis_service: "mastodon"
- name: Create redis_mastodon directory
ansible.builtin.file:
path: "{{ node['home_path'] }}/{{ item }}"
state: "directory"
owner: "{{ services['redis']['subuid'] }}"
group: "{{ node['group'] }}"
mode: "0770"
loop:
- "containers/redis"
- "containers/redis/{{ redis_service }}"
- "containers/redis/{{ redis_service }}/data"
become: true
- name: Deploy redis config file
ansible.builtin.template:
src: "{{ hostvars['console']['node']['config_path'] }}/services/containers/app/redis/redis.conf.j2"
dest: "{{ node['home_path'] }}/containers/redis/{{ redis_service }}/redis.conf"
owner: "{{ ansible_user }}"
group: "{{ node['group'] }}"
mode: "0644"
register: "is_redis_conf"
- name: Deploy redis container file
ansible.builtin.template:
src: "{{ hostvars['console']['node']['config_path'] }}/services/containers/app/redis/redis.container.j2"
dest: "{{ node['home_path'] }}/.config/containers/systemd/redis_{{ redis_service }}.container"
owner: "{{ ansible_user }}"
group: "{{ node['group'] }}"
mode: "0644"
register: "is_redis_containerfile"
- name: Enable (Restart) redis service
ansible.builtin.systemd:
name: "redis_{{ redis_service }}.service"
state: "restarted"
enabled: true
daemon_reload: true
scope: "user"
when: is_redis_conf.changed or is_redis_containerfile.changed # noqa: no-handler
- name: Create mastodon directory
ansible.builtin.file:
path: "{{ node['home_path'] }}/{{ item }}"
state: "directory"
owner: "{{ services['mastodon']['subuid'] }}"
group: "{{ node['group'] }}"
mode: "0770"
loop:
- "data/containers/mastodon"
- "data/containers/mastodon/system"
- "containers/mastodon"
- "containers/mastodon/ssl"
become: true
- name: Check data directory empty
ansible.builtin.stat:
path: "{{ node['home_path'] }}/data/containers/mastodon/.init"
register: "is_mastodon_init"
- name: Check migrate file
ansible.builtin.stat:
path: "{{ node['home_path'] }}/data/containers/mastodon/.migrated_{{ version['containers']['mastodon'] }}"
register: "is_mastodon_migrated"
- name: Deploy root certificate
ansible.builtin.copy:
content: |
{{ hostvars['console']['ca']['root']['crt'] }}
dest: "{{ node['home_path'] }}/containers/mastodon/ssl/{{ root_cert_filename }}"
owner: "{{ services['mastodon']['subuid'] }}"
group: "{{ node['group'] }}"
mode: "0440"
become: true
notify: "notification_restart_mastodon"
no_log: true
- name: Register secret value to podman secret
containers.podman.podman_secret:
name: "{{ item.name }}"
data: "{{ item.value }}"
state: "present"
force: true
loop:
- name: "MASTODON_SECRET_KEY_BASE"
value: "{{ hostvars['console']['mastodon']['secret_key'] }}"
- name: "MASTODON_ENCRYPTION_PRIMARY_KEY"
value: "{{ hostvars['console']['mastodon']['encryption']['primary_key'] }}"
- name: "MASTODON_ENCRYPTION_DETERMINISTIC_KEY"
value: "{{ hostvars['console']['mastodon']['encryption']['deterministic_key'] }}"
- name: "MASTODON_ENCRYPTION_SALT"
value: "{{ hostvars['console']['mastodon']['encryption']['salt'] }}"
- name: "MASTODON_POSTGRES_PASSWORD"
value: "{{ hostvars['console']['postgresql']['password']['mastodon'] }}"
- name: "MASTODON_OIDC_CLIENT_SECRET"
value: "{{ hostvars['console']['mastodon']['oidc']['secret'] }}"
- name: "MASTODON_VAPID_PRIVATE_KEY"
value: "{{ hostvars['console']['mastodon']['vapid']['private_key'] }}"
- name: "MASTODON_VAPID_PUBLIC_KEY"
value: "{{ hostvars['console']['mastodon']['vapid']['public_key'] }}"
notify: "notification_restart_mastodon"
no_log: true
- name: Pull image
containers.podman.podman_image:
name: "{{ item }}"
tag: "{{ version['containers']['mastodon'] }}"
state: "present"
pull: true
loop:
- "ghcr.io/mastodon/mastodon"
- "ghcr.io/mastodon/mastodon-streaming"
- name: Initialize mastodon
when: not is_mastodon_init.stat.exists
block:
- name: Execute init command
containers.podman.podman_container:
name: "mastodon_init"
image: "ghcr.io/mastodon/mastodon:{{ version['containers']['mastodon'] }}"
command: "bundle exec rails db:prepare"
state: "started"
rm: true
detach: false
env:
LOCAL_DOMAIN: "{{ services['mastodon']['domain']['public'] }}.{{ domain['public'] }}"
SAFETY_ASSURED: "1"
DB_HOST: "{{ services['postgresql']['domain']['internal'] }}.{{ domain['internal'] }}"
DB_PORT: "{{ services['postgresql']['ports']['tcp'] }}"
DB_NAME: "mastodon_db"
DB_USER: "mastodon"
DB_PASS: "{{ hostvars['console']['postgresql']['password']['mastodon'] }}"
DB_SSLMODE: "verify-full"
PGSSLROOTCERT: "/etc/ssl/mastodon/{{ root_cert_filename }}"
REDIS_URL: "redis://host.containers.internal:{{ services['mastodon']['ports']['redis'] }}"
SECRET_KEY_BASE: "{{ hostvars['console']['mastodon']['secret_key'] }}"
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: "{{ hostvars['console']['mastodon']['encryption']['primary_key'] }}"
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: "{{ hostvars['console']['mastodon']['encryption']['deterministic_key'] }}"
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT: "{{ hostvars['console']['mastodon']['encryption']['salt'] }}"
volume:
- "{{ node['home_path'] }}/containers/mastodon/ssl:/etc/ssl/mastodon:ro"
- "{{ node['home_path'] }}/data/containers/mastodon/system:/mastodon/public/system:rw"
no_log: true
- name: Create .init file
ansible.builtin.file:
path: "{{ node['home_path'] }}/data/containers/mastodon/.init"
state: "touch"
mode: "0644"
owner: "{{ ansible_user }}"
group: "{{ node['group'] }}"
- name: Create .migrated file
ansible.builtin.file:
path: "{{ node['home_path'] }}/data/containers/mastodon/.migrated_{{ version['containers']['mastodon'] }}"
state: "touch"
mode: "0644"
owner: "{{ ansible_user }}"
group: "{{ node['group'] }}"
- name: Migrate DB of mastodon
when: not is_mastodon_migrated.stat.exists and is_mastodon_init.stat.exists
block:
- name: Stop the services
ansible.builtin.systemd:
name: "{{ item }}"
state: "stopped"
enabled: true
daemon_reload: true
scope: "user"
loop:
- "mastodon-web.service"
- "mastodon-worker.service"
- "mastodon-streaming.service"
- name: Execute migrate command
containers.podman.podman_container:
name: "mastodon_migrate"
image: "ghcr.io/mastodon/mastodon:{{ version['containers']['mastodon'] }}"
command: "bundle exec rails db:migrate"
state: "started"
rm: true
detach: false
env:
LOCAL_DOMAIN: "{{ services['mastodon']['domain']['public'] }}.{{ domain['public'] }}"
DB_HOST: "{{ services['postgresql']['domain']['internal'] }}.{{ domain['internal'] }}"
DB_PORT: "{{ services['postgresql']['ports']['tcp'] }}"
DB_NAME: "mastodon_db"
DB_USER: "mastodon"
DB_PASS: "{{ hostvars['console']['postgresql']['password']['mastodon'] }}"
DB_SSLMODE: "verify-full"
PGSSLROOTCERT: "/etc/ssl/mastodon/{{ root_cert_filename }}"
REDIS_URL: "redis://host.containers.internal:{{ services['mastodon']['ports']['redis'] }}"
SECRET_KEY_BASE: "{{ hostvars['console']['mastodon']['secret_key'] }}"
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: "{{ hostvars['console']['mastodon']['encryption']['primary_key'] }}"
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: "{{ hostvars['console']['mastodon']['encryption']['deterministic_key'] }}"
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT: "{{ hostvars['console']['mastodon']['encryption']['salt'] }}"
volume:
- "{{ node['home_path'] }}/containers/mastodon/ssl:/etc/ssl/mastodon:ro"
- "{{ node['home_path'] }}/data/containers/mastodon/system:/mastodon/public/system:rw"
no_log: true
- name: Create .migrated file
ansible.builtin.file:
path: "{{ node['home_path'] }}/data/containers/mastodon/.migrated_{{ version['containers']['mastodon'] }}"
state: "touch"
mode: "0644"
owner: "{{ ansible_user }}"
group: "{{ node['group'] }}"
- name: Deploy mastodon.container file
ansible.builtin.template:
src: "{{ hostvars['console']['node']['config_path'] }}/services/containers/app/mastodon/{{ item }}.j2"
dest: "{{ node['home_path'] }}/.config/containers/systemd/{{ item }}"
owner: "{{ ansible_user }}"
group: "{{ node['group'] }}"
mode: "0644"
loop:
- "mastodon-web.container"
- "mastodon-worker.container"
- "mastodon-streaming.container"
notify: "notification_restart_mastodon"
- name: Enable mastodon.service
ansible.builtin.systemd:
name: "{{ item }}"
state: "started"
enabled: true
daemon_reload: true
scope: "user"
loop:
- "mastodon-web.service"
- "mastodon-worker.service"
- "mastodon-streaming.service"
- name: Check container archive images
ansible.builtin.stat:
path: "{{ node['home_path'] }}/archives/containers/{{ item.file }}.tar"
loop:
- name: "redis"
image: "docker.io/library/redis:{{ version['containers']['redis'] }}"
file: "docker.io_library_redis_{{ version['containers']['redis'] }}"
- name: "mastodon"
image: "ghcr.io/mastodon/mastodon:{{ version['containers']['mastodon'] }}"
file: "ghcr.io_mastodon_mastodon_{{ version['containers']['mastodon'] }}"
- name: "mastodon-streaming"
image: "ghcr.io/mastodon/mastodon-streaming:{{ version['containers']['mastodon'] }}"
file: "ghcr.io_mastodon_mastodon-streaming_{{ version['containers']['mastodon'] }}"
loop_control:
label: "{{ item.name }}"
register: container_archive_images
- name: Save container archive images
containers.podman.podman_save:
image:
- "{{ item.item.image }}"
dest: "{{ node['home_path'] }}/archives/containers/{{ item.item.file }}.tar"
format: "oci-archive"
force: false
loop: "{{ container_archive_images.results }}"
loop_control:
label: "{{ item.item.file }}"
when: not item.stat.exists
- name: Fetch container archive images
ansible.builtin.fetch:
src: "{{ node['home_path'] }}/archives/containers/{{ item.item.file }}.tar"
dest: "{{ hostvars['console']['node']['data_path'] }}/images/containers/"
flat: true
loop: "{{ container_archive_images.results }}"
loop_control:
label: "{{ item.item.file }}"
@@ -78,7 +78,7 @@
- name: Initialize nextcloud
when: not is_nextcloud_init.stat.exists
block:
- name: Execute init command (Including pulling image)
- name: Execute init command
containers.podman.podman_container:
name: "nextcloud_init"
image: "docker.io/library/nextcloud:{{ version['containers']['nextcloud'] }}"
@@ -91,7 +91,7 @@
force: true
loop:
- name: "OUTLINE_SECRET_KEY"
value: "{{ hostvars['console']['outline']['session_secret'] }}"
value: "{{ hostvars['console']['outline']['secret_key'] }}"
- name: "OUTLINE_UTILS_SECRET"
value: "{{ hostvars['console']['outline']['utils_secret'] }}"
- name: "OUTLINE_DATABASE_PASSWORD"
@@ -78,7 +78,7 @@
force: true
loop:
- name: "SURE_SECRET_KEY_BASE"
value: "{{ hostvars['console']['sure']['session_secret'] }}"
value: "{{ hostvars['console']['sure']['secret_key'] }}"
- name: "SURE_POSTGRES_PASSWORD"
value: "{{ hostvars['console']['postgresql']['password']['sure'] }}"
- name: "SURE_OIDC_CLIENT_SECRET"