# vim: ft=yaml.ansible --- - name: Create volume folder for Mastodon data file: name: "{{ services.mastodon.volume_folder }}/mastodon_data" state: directory owner: "991" mode: u=rwx,g=rx,o=rx - name: Create volume folder for PostgreSQL data file: name: "{{ services.mastodon.volume_folder }}/postgres_data" state: directory owner: "70" mode: u=rwx,go= - name: Create volume folder for PostgreSQL config file: name: "{{ services.mastodon.volume_folder }}/postgres_config" state: directory owner: root mode: u=rwx,g=rx,o=rx - name: Create volume folder for Redis data file: name: "{{ services.mastodon.volume_folder }}/redis_data" state: directory owner: "999" group: "1000" mode: u=rwx,g=rx,o=rx - name: Copy mastodon environment file template: src: mastodon.env.j2 dest: "{{ services.mastodon.volume_folder }}/env_file" - name: Upload vhost config for root domain copy: src: vhost/mastodon dest: "{{ services.nginx_proxy.volume_folder }}/vhost/{{ services.mastodon.domain }}" - name: Copy PostgreSQL config copy: src: mastodon/postgresql.conf dest: "{{ services.mastodon.volume_folder }}/postgres_config/postgresql.conf" - name: Set up Mastodon docker_compose: project_name: mastodon pull: true restarted: true definition: x-sidekiq: &sidekiq image: "tootsuite/mastodon:{{ services.mastodon.version }}" restart: always env_file: "{{ services.mastodon.volume_folder }}/env_file" depends_on: db: condition: "service_healthy" redis: condition: "service_healthy" networks: - postfix - external_services - internal_network volumes: - "{{ services.mastodon.volume_folder }}/mastodon_data:/mastodon/public/system" healthcheck: test: ['CMD-SHELL', "ps aux | grep '[s]idekiq\ 6' || false"] version: '3' services: db: restart: always image: "postgres:{{ services.mastodon.postgres_version }}" shm_size: 256mb networks: - internal_network healthcheck: test: ['CMD', 'pg_isready', '-U', 'postgres'] volumes: - "{{ services.mastodon.volume_folder }}/postgres_data:/var/lib/postgresql/data" - "{{ services.mastodon.volume_folder }}/postgres_config:/config:ro" command: postgres -c config_file=/config/postgresql.conf environment: - 'POSTGRES_HOST_AUTH_METHOD=trust' redis: restart: always image: "redis:{{ services.mastodon.redis_version }}" networks: - internal_network healthcheck: test: ['CMD', 'redis-cli', 'ping'] volumes: - "{{ services.mastodon.volume_folder }}/redis_data:/data" web: image: "tootsuite/mastodon:{{ services.mastodon.version }}" restart: always env_file: "{{ services.mastodon.volume_folder }}/env_file" command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000" networks: - external_services - internal_network healthcheck: # prettier-ignore test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:3000/health || exit 1'] depends_on: db: condition: "service_healthy" redis: condition: "service_healthy" volumes: - "{{ services.mastodon.volume_folder }}/mastodon_data:/mastodon/public/system" environment: MAX_THREADS: 10 WEB_CONCURRENCY: 3 VIRTUAL_HOST: "{{ services.mastodon.domain }}" VIRTUAL_PORT: "3000" VIRTUAL_PATH: "/" LETSENCRYPT_HOST: "{{ services.mastodon.domain }}" LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}" streaming: image: "tootsuite/mastodon:{{ services.mastodon.version }}" restart: always env_file: "{{ services.mastodon.volume_folder }}/env_file" command: node ./streaming networks: - external_services - internal_network healthcheck: # prettier-ignore test: ['CMD-SHELL', 'wget -q --spider --proxy=off localhost:4000/api/v1/streaming/health || exit 1'] ports: - '127.0.0.1:4000:4000' depends_on: db: condition: "service_healthy" redis: condition: "service_healthy" environment: DB_POOL: 15 VIRTUAL_HOST: "{{ services.mastodon.domain }}" VIRTUAL_PORT: "4000" VIRTUAL_PATH: "/api/v1/streaming" # sidekiq-default-push-pull: DB_POOL = 25, -c 25 for 25 connections sidekiq-default-push-pull: <<: *sidekiq command: bundle exec sidekiq -c 25 -q default -q push -q pull environment: DB_POOL: 25 # sidekiq-default-pull-push: DB_POOL = 25, -c 25 for 25 connections sidekiq-default-pull-push: <<: *sidekiq command: bundle exec sidekiq -c 25 -q default -q pull -q push environment: DB_POOL: 25 # sidekiq-pull-default-push: DB_POOL = 25, -c 25 for 25 connections sidekiq-pull-default-push: <<: *sidekiq command: bundle exec sidekiq -c 25 -q pull -q default -q push environment: DB_POOL: 25 # sidekiq-push-default-pull: DB_POOL = 25, -c 25 for 25 connections sidekiq-push-default-pull: <<: *sidekiq command: bundle exec sidekiq -c 25 -q push -q default -q pull environment: DB_POOL: 25 # sidekiq-push-scheduler: DB_POOL = 5, -c 5 for 5 connections sidekiq-push-scheduler: <<: *sidekiq command: bundle exec sidekiq -c 5 -q push -q scheduler environment: DB_POOL: 5 # sidekiq-push-mailers: DB_POOL = 5, -c 5 for 5 connections sidekiq-push-mailers: <<: *sidekiq command: bundle exec sidekiq -c 5 -q push -q mailers environment: DB_POOL: 5 # sidekiq-push-ingress: DB_POOL = 10, -c 10 for 10 connections sidekiq-push-ingress: <<: *sidekiq command: bundle exec sidekiq -c 10 -q push -q ingress environment: DB_POOL: 10 networks: external_services: external: true postfix: external: true internal_network: internal: true - name: Configure cron job to remove old Mastodon media daily cron: name: Clean Mastodon media data older than a week cron_file: ansible_mastodon_clean_media job: docker exec mastodon_web_1 tootctl media remove --days 7 special_time: daily user: root state: present - name: Configure cron job to remove old Mastodon preview cards daily cron: name: Clean Mastodon preview card data older than two weeks cron_file: ansible_mastodon_clean_preview_cards job: docker exec mastodon_web_1 tootctl preview_cards remove --days 14 special_time: daily user: root state: present