Unify environmental variables

This commit is contained in:
Antonio J. Delgado 2022-11-24 09:53:59 +02:00
parent 8ad93b5aa8
commit c79c0f47af
4 changed files with 55 additions and 59 deletions

View file

@ -73,16 +73,10 @@
src: templates/docker-compose.yml.j2 src: templates/docker-compose.yml.j2
dest: "{{ mastodon_composer_folder }}/docker-compose.yml" dest: "{{ mastodon_composer_folder }}/docker-compose.yml"
- name: Ensure mastodon application configuration is present - name: Ensure mastodon environment configuration is present
template: template:
src: templates/application.env.j2 src: templates/env.j2
dest: "{{ mastodon_composer_folder }}/application.env.production" dest: "{{ mastodon_composer_folder }}/env.production"
mode: 0600
- name: Ensure mastodon database configuration is present
template:
src: templates/database.env.j2
dest: "{{ mastodon_composer_folder }}/database.env.production"
mode: 0600 mode: 0600
- name: Generate secret key - name: Generate secret key
@ -99,7 +93,7 @@
- name: Add secret key to Mastodon config - name: Add secret key to Mastodon config
lineinfile: lineinfile:
path: "{{ mastodon_composer_folder }}/application.env.production" path: "{{ mastodon_composer_folder }}/env.production"
line: "SECRET_KEY_BASE={{ mastodon_secret_key_base }}" line: "SECRET_KEY_BASE={{ mastodon_secret_key_base }}"
regexp: "^SECRET_KEY_BASE=" regexp: "^SECRET_KEY_BASE="
backup: yes backup: yes
@ -119,7 +113,7 @@
- name: Add OTP key to Mastodon config - name: Add OTP key to Mastodon config
lineinfile: lineinfile:
path: "{{ mastodon_composer_folder }}/application.env.production" path: "{{ mastodon_composer_folder }}/env.production"
line: "OTP_SECRET={{ mastodon_otp_secret }}" line: "OTP_SECRET={{ mastodon_otp_secret }}"
regexp: "^OTP_SECRET=" regexp: "^OTP_SECRET="
backup: yes backup: yes
@ -139,7 +133,7 @@
- name: Add Paperclip key to Mastodon config - name: Add Paperclip key to Mastodon config
lineinfile: lineinfile:
path: "{{ mastodon_composer_folder }}/application.env.production" path: "{{ mastodon_composer_folder }}/env.production"
line: "PAPERCLIP_SECRET={{ mastodon_paperclip_secret }}" line: "PAPERCLIP_SECRET={{ mastodon_paperclip_secret }}"
regexp: "^PAPERCLIP_SECRET=" regexp: "^PAPERCLIP_SECRET="
backup: yes backup: yes
@ -164,7 +158,7 @@
- name: Add Paperclip private key to Mastodon config - name: Add Paperclip private key to Mastodon config
lineinfile: lineinfile:
path: "{{ mastodon_composer_folder }}/application.env.production" path: "{{ mastodon_composer_folder }}/env.production"
line: "{{ vapid_private_key }}" line: "{{ vapid_private_key }}"
regexp: "^VAPID_PRIVATE_KEY=" regexp: "^VAPID_PRIVATE_KEY="
mode: 0600 mode: 0600
@ -172,7 +166,7 @@
- name: Add Paperclip public key to Mastodon config - name: Add Paperclip public key to Mastodon config
lineinfile: lineinfile:
path: "{{ mastodon_composer_folder }}/application.env.production" path: "{{ mastodon_composer_folder }}/env.production"
line: "{{ vapid_public_key }}" line: "{{ vapid_public_key }}"
regexp: "^VAPID_PUBLIC_KEY=" regexp: "^VAPID_PUBLIC_KEY="
mode: 0600 mode: 0600

View file

@ -1,34 +0,0 @@
# postgresql configuration
POSTGRES_USER={{ mastodon_db_user }}
POSTGRES_DB={{ mastodon_db }}
POSTGRES_PASSWORD={{ mastodon_db_password }}
# pgbouncer configuration
#POOL_MODE=transaction
#ADMIN_USERS=postgres,mastodon
#DATABASE_URL="postgres://mastodon:O6lOD6nF2LbhhJs1e7QL@postgresql:5432/mastodon_production"
# elasticsearch
ES_JAVA_OPTS=-Xms512m -Xmx512m
ELASTIC_PASSWORD={{ es_pass }}
# mastodon database configuration
#DB_HOST=pgbouncer
DB_HOST={{ mastodon_db_login_unix_socket }}
DB_USER={{ mastodon_db_user }}
DB_NAME={{ mastodon_db }}
DB_PASS={{ mastodon_db_password }}
DB_PORT=5432
REDIS_HOST={{ redis_host }}
REDIS_PORT={{ redis_port }}
CACHE_REDIS_HOST=redis-volatile
CACHE_REDIS_PORT=6379
ES_ENABLED={{ es_enabled }}
ES_HOST={{ es_host }}
ES_PORT={{ es_port }}
# Authentication for ES (optional)
ES_USER={{ es_user }}
ES_PASS={{ es_pass }}

View file

@ -3,7 +3,7 @@ version: '3'
services: services:
postgresql: postgresql:
image: postgres:14-alpine image: postgres:14-alpine
env_file: database.env.production env_file: env.production
restart: always restart: always
shm_size: 256mb shm_size: 256mb
healthcheck: healthcheck:
@ -15,7 +15,7 @@ services:
# pgbouncer: # pgbouncer:
# image: edoburu/pgbouncer:1.12.0 # image: edoburu/pgbouncer:1.12.0
# env_file: database.env.production # env_file: env.production
# depends_on: # depends_on:
# - postgresql # - postgresql
# healthcheck: # healthcheck:
@ -44,7 +44,7 @@ services:
elasticsearch: elasticsearch:
image: elasticsearch:{{ es_version | default('7.17.7') }} image: elasticsearch:{{ es_version | default('7.17.7') }}
restart: always restart: always
env_file: database.env.production env_file: env.production
environment: environment:
- cluster.name=elasticsearch-mastodon - cluster.name=elasticsearch-mastodon
- discovery.type=single-node - discovery.type=single-node
@ -65,8 +65,8 @@ services:
website: website:
image: tootsuite/mastodon:latest image: tootsuite/mastodon:latest
env_file: env_file:
- application.env.production - env.production
- database.env.production - env.production
command: bash -c "bundle exec rails s -p 3000" command: bash -c "bundle exec rails s -p 3000"
restart: always restart: always
depends_on: depends_on:
@ -88,8 +88,8 @@ services:
shell: shell:
image: tootsuite/mastodon:latest image: tootsuite/mastodon:latest
env_file: env_file:
- application.env.production - env.production
- database.env.production - env.production
command: /bin/bash command: /bin/bash
restart: "no" restart: "no"
networks: networks:
@ -101,8 +101,8 @@ services:
streaming: streaming:
image: tootsuite/mastodon:latest image: tootsuite/mastodon:latest
env_file: env_file:
- application.env.production - env.production
- database.env.production - env.production
command: node ./streaming command: node ./streaming
restart: always restart: always
depends_on: depends_on:
@ -122,8 +122,8 @@ services:
sidekiq: sidekiq:
image: tootsuite/mastodon:latest image: tootsuite/mastodon:latest
env_file: env_file:
- application.env.production - env.production
- database.env.production - env.production
command: bundle exec sidekiq command: bundle exec sidekiq
restart: always restart: always
depends_on: depends_on:

View file

@ -43,3 +43,39 @@ OTP_SECRET=
VAPID_PRIVATE_KEY= VAPID_PRIVATE_KEY=
VAPID_PUBLIC_KEY= VAPID_PUBLIC_KEY=
# postgresql configuration
POSTGRES_USER={{ mastodon_db_user }}
POSTGRES_DB={{ mastodon_db }}
POSTGRES_PASSWORD={{ mastodon_db_password }}
# pgbouncer configuration
#POOL_MODE=transaction
#ADMIN_USERS=postgres,mastodon
#DATABASE_URL="postgres://mastodon:O6lOD6nF2LbhhJs1e7QL@postgresql:5432/mastodon_production"
# elasticsearch
ES_JAVA_OPTS=-Xms512m -Xmx512m
ELASTIC_PASSWORD={{ es_pass }}
# mastodon database configuration
#DB_HOST=pgbouncer
DB_HOST={{ mastodon_db_login_unix_socket }}
DB_USER={{ mastodon_db_user }}
DB_NAME={{ mastodon_db }}
DB_PASS={{ mastodon_db_password }}
DB_PORT=5432
REDIS_HOST={{ redis_host }}
REDIS_PORT={{ redis_port }}
CACHE_REDIS_HOST=redis-volatile
CACHE_REDIS_PORT=6379
ES_ENABLED={{ es_enabled }}
ES_HOST={{ es_host }}
ES_PORT={{ es_port }}
# Authentication for ES (optional)
ES_USER={{ es_user }}
ES_PASS={{ es_pass }}