mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-11-27 07:06:36 +00:00
Fix Mastodon role: run DB migrations before health checks, restructure setup/wait tasks, introduce service name variables, and update docker-compose templates.
Reference: https://chatgpt.com/share/6925e87d-3e0c-800f-bfff-902d1faa122e
This commit is contained in:
4
roles/web-app-mastodon/tasks/01_setup.yml
Normal file
4
roles/web-app-mastodon/tasks/01_setup.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
- name: "Execute migration for '{{ application_id }}'"
|
||||||
|
command:
|
||||||
|
chdir: "{{ docker_compose.directories.instance }}"
|
||||||
|
cmd: "docker compose run --rm {{ MASTODON_SERVICE_NAME }} bundle exec rails db:migrate"
|
||||||
@@ -11,9 +11,9 @@
|
|||||||
delay: 5
|
delay: 5
|
||||||
until: healthcheck.stdout == "healthy"
|
until: healthcheck.stdout == "healthy"
|
||||||
loop:
|
loop:
|
||||||
- mastodon
|
- "{{ MASTODON_SERVICE_NAME }}"
|
||||||
- streaming
|
- "{{ MASTODON_STREAMING_SERVICE_NAME }}"
|
||||||
- sidekiq
|
- "{{ MASTODON_SIDEKIQ_SERVICE_NAME }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item }}"
|
label: "{{ item }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
- name: "Execute migration for '{{ application_id }}'"
|
|
||||||
command:
|
|
||||||
cmd: "docker exec {{ MASTODON_CONTAINER }} bundle exec rails db:migrate"
|
|
||||||
@@ -18,15 +18,15 @@
|
|||||||
vars:
|
vars:
|
||||||
docker_compose_flush_handlers: true
|
docker_compose_flush_handlers: true
|
||||||
|
|
||||||
|
- name: "start setup procedures for mastodon"
|
||||||
|
include_tasks: 01_setup.yml
|
||||||
|
|
||||||
- name: "Wait for Mastodon"
|
- name: "Wait for Mastodon"
|
||||||
include_tasks: 01_wait.yml
|
include_tasks: 02_wait.yml
|
||||||
|
|
||||||
- name: "Cleanup Mastodon caches when MODE_CLEANUP is true"
|
- name: "Cleanup Mastodon caches when MODE_CLEANUP is true"
|
||||||
include_tasks: 02_cleanup.yml
|
include_tasks: 03_cleanup.yml
|
||||||
when: MODE_CLEANUP | bool
|
when: MODE_CLEANUP | bool
|
||||||
|
|
||||||
- name: "start setup procedures for mastodon"
|
|
||||||
include_tasks: 03_setup.yml
|
|
||||||
|
|
||||||
- name: "Include administrator routines for '{{ application_id }}'"
|
- name: "Include administrator routines for '{{ application_id }}'"
|
||||||
include_tasks: 04_administrator.yml
|
include_tasks: 04_administrator.yml
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{% include 'roles/docker-compose/templates/base.yml.j2' %}
|
{% include 'roles/docker-compose/templates/base.yml.j2' %}
|
||||||
|
|
||||||
mastodon:
|
{% set service_name = MASTODON_SERVICE_NAME %}
|
||||||
{% set service_name = 'mastodon' %}
|
|
||||||
{% set container_port = 3000 %}
|
{% set container_port = 3000 %}
|
||||||
{% set container_healthcheck = 'health' %}
|
{% set container_healthcheck = 'health' %}
|
||||||
|
{{ service_name }}:
|
||||||
container_name: {{ MASTODON_CONTAINER }}
|
container_name: {{ MASTODON_CONTAINER }}
|
||||||
image: "{{ MASTODON_IMAGE }}:{{ MASTODON_VERSION }}"
|
image: "{{ MASTODON_IMAGE }}:{{ MASTODON_VERSION }}"
|
||||||
{% include 'roles/docker-container/templates/base.yml.j2' %}
|
{% include 'roles/docker-container/templates/base.yml.j2' %}
|
||||||
@@ -16,10 +16,10 @@
|
|||||||
- data:/mastodon/public/system
|
- data:/mastodon/public/system
|
||||||
{% include 'roles/docker-container/templates/networks.yml.j2' %}
|
{% include 'roles/docker-container/templates/networks.yml.j2' %}
|
||||||
|
|
||||||
streaming:
|
{% set service_name = MASTODON_STREAMING_SERVICE_NAME %}
|
||||||
{% set service_name = 'streaming' %}
|
|
||||||
{% set container_port = 4000 %}
|
{% set container_port = 4000 %}
|
||||||
{% set container_healthcheck = 'api/v1/streaming/health' %}
|
{% set container_healthcheck = 'api/v1/streaming/health' %}
|
||||||
|
{{ service_name }}:
|
||||||
container_name: {{ MASTODON_STREAMING_CONTAINER }}
|
container_name: {{ MASTODON_STREAMING_CONTAINER }}
|
||||||
image: "{{ MASTODON_STREAMING_IMAGE }}:{{ MASTODON_STREAMING_VERSION }}"
|
image: "{{ MASTODON_STREAMING_IMAGE }}:{{ MASTODON_STREAMING_VERSION }}"
|
||||||
{% include 'roles/docker-container/templates/base.yml.j2' %}
|
{% include 'roles/docker-container/templates/base.yml.j2' %}
|
||||||
@@ -30,8 +30,8 @@
|
|||||||
{% include 'roles/docker-container/templates/depends_on/dmbs_excl.yml.j2' %}
|
{% include 'roles/docker-container/templates/depends_on/dmbs_excl.yml.j2' %}
|
||||||
{% include 'roles/docker-container/templates/networks.yml.j2' %}
|
{% include 'roles/docker-container/templates/networks.yml.j2' %}
|
||||||
|
|
||||||
sidekiq:
|
{% set service_name = MASTODON_SIDEKIQ_SERVICE_NAME %}
|
||||||
{% set service_name = 'sidekiq' %}
|
{{ service_name }}:
|
||||||
container_name: {{ MASTODON_SIDEKIQ_CONTAINER }}
|
container_name: {{ MASTODON_SIDEKIQ_CONTAINER }}
|
||||||
image: "{{ MASTODON_IMAGE }}:{{ MASTODON_VERSION }}"
|
image: "{{ MASTODON_IMAGE }}:{{ MASTODON_VERSION }}"
|
||||||
{% include 'roles/docker-container/templates/base.yml.j2' %}
|
{% include 'roles/docker-container/templates/base.yml.j2' %}
|
||||||
|
|||||||
@@ -2,13 +2,24 @@
|
|||||||
application_id: "web-app-mastodon"
|
application_id: "web-app-mastodon"
|
||||||
database_type: "postgres"
|
database_type: "postgres"
|
||||||
|
|
||||||
# Mastodon Specific
|
# Mastodon
|
||||||
|
|
||||||
|
## Main
|
||||||
MASTODON_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.mastodon.version') }}"
|
MASTODON_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.mastodon.version') }}"
|
||||||
MASTODON_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.mastodon.image') }}"
|
MASTODON_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.mastodon.image') }}"
|
||||||
MASTODON_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.mastodon.name') }}"
|
MASTODON_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.mastodon.name') }}"
|
||||||
MASTODON_VOLUME: "{{ applications | get_app_conf(application_id, 'docker.volumes.data') }}"
|
MASTODON_VOLUME: "{{ applications | get_app_conf(application_id, 'docker.volumes.data') }}"
|
||||||
|
MASTODON_SERVICE_NAME: "mastodon"
|
||||||
|
|
||||||
|
## Streaming
|
||||||
MASTODON_STREAMING_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.streaming.version') }}"
|
MASTODON_STREAMING_VERSION: "{{ applications | get_app_conf(application_id, 'docker.services.streaming.version') }}"
|
||||||
MASTODON_STREAMING_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.streaming.image') }}"
|
MASTODON_STREAMING_IMAGE: "{{ applications | get_app_conf(application_id, 'docker.services.streaming.image') }}"
|
||||||
MASTODON_STREAMING_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.streaming.name') }}"
|
MASTODON_STREAMING_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.streaming.name') }}"
|
||||||
MASTODON_SIDEKIQ_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.mastodon.name') }}_sidekiq"
|
MASTODON_STREAMING_SERVICE_NAME: "streaming"
|
||||||
|
|
||||||
|
## Sidekiq
|
||||||
|
MASTODON_SIDEKIQ_CONTAINER: "{{ applications | get_app_conf(application_id, 'docker.services.mastodon.name') }}-sidekiq"
|
||||||
|
MASTODON_SIDEKIQ_SERVICE_NAME: "sidekiq"
|
||||||
|
|
||||||
|
## General
|
||||||
MASTODON_ALLOWED_PRIVATE_ADDRESSES: "{{ networks.local['svc-db-postgres'].subnet if 'web-app-chess' in group_names else ''}}"
|
MASTODON_ALLOWED_PRIVATE_ADDRESSES: "{{ networks.local['svc-db-postgres'].subnet if 'web-app-chess' in group_names else ''}}"
|
||||||
Reference in New Issue
Block a user