From c4f391140094f312752b98d7f6611091951a3182 Mon Sep 17 00:00:00 2001 From: Sam A Date: Sun, 4 Dec 2022 21:45:32 +0000 Subject: [PATCH] Always recreate Mastodon containers (#134) Fixes #133. Co-authored-by: Sam Al-Sapti Reviewed-on: https://git.data.coop/data.coop/ansible/pulls/134 Co-authored-by: Sam A. Co-committed-by: Sam A. --- Vagrantfile | 2 +- deploy.sh | 2 +- playbook.yml | 5 +++-- roles/docker/tasks/services/codimd.yml | 13 +++++-------- roles/docker/tasks/services/mastodon.yml | 13 ++++++++----- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 7d00af1..1e46276 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -13,7 +13,7 @@ Vagrant.configure(2) do |config| config.vm.hostname = "datacoop" config.vm.provider :virtualbox do |v| - v.memory = 4096 + v.memory = 8192 end config.vm.provision :ansible do |ansible| diff --git a/deploy.sh b/deploy.sh index 9f41a33..d66caa2 100755 --- a/deploy.sh +++ b/deploy.sh @@ -11,7 +11,7 @@ usage () { BASE_CMD="ansible-playbook playbook.yml --ask-vault-pass" if [ "$1" = "--vagrant" ]; then - BASE_CMD="$BASE_CMD --inventory=vagrant_host" + BASE_CMD="$BASE_CMD --verbose --inventory=vagrant_host" shift fi diff --git a/playbook.yml b/playbook.yml index 1ce47fb..f2c5a1d 100644 --- a/playbook.yml +++ b/playbook.yml @@ -3,13 +3,14 @@ gather_facts: true become: true vars: - base_domain: data.coop - letsencrypt_email: admin@data.coop ldap_dn: "dc=data,dc=coop" vagrant: "{{ ansible_virtualization_role == 'guest' }}" letsencrypt_enabled: "{{ not vagrant }}" + base_domain: "{{ 'datacoop.devel' if vagrant else 'data.coop' }}" + letsencrypt_email: "admin@{{ base_domain }}" + smtp_host: "postfix" smtp_port: "587" diff --git a/roles/docker/tasks/services/codimd.yml b/roles/docker/tasks/services/codimd.yml index 1e0e950..6e13c21 100644 --- a/roles/docker/tasks/services/codimd.yml +++ b/roles/docker/tasks/services/codimd.yml @@ -1,17 +1,15 @@ --- - - name: codimd network docker_network: name: codimd - name: create codimd volume folders file: - name: "{{ codimd.volume_folder }}/{{ volume }}" + name: "{{ services.codimd.volume_folder }}/{{ volume }}" state: directory loop: - "db" - "codimd/uploads" - loop_control: loop_var: volume @@ -24,7 +22,7 @@ networks: - name: codimd volumes: - - "{{ codimd.volume_folder }}/db:/var/lib/postgresql/data" + - "{{ services.codimd.volume_folder }}/db:/var/lib/postgresql/data" env: POSTGRES_USER: "codimd" POSTGRES_PASSWORD: "{{ postgres_passwords.codimd }}" @@ -39,8 +37,7 @@ - name: ldap - name: external_services volumes: - - "{{ codimd.volume_folder }}/codimd/uploads:/codimd/public/uploads" - + - "{{ services.codimd.volume_folder }}/codimd/uploads:/codimd/public/uploads" env: CMD_DB_URL: "postgres://codimd:{{ postgres_passwords.codimd }}@codimd_db:5432/codimd" CMD_ALLOW_EMAIL_REGISTER: "False" @@ -52,6 +49,6 @@ CMD_LDAP_SEARCHBASE: "dc=data,dc=coop" CMD_LDAP_SEARCHFILTER: "(&(uid={{ '{{username}}' }})(objectClass=inetOrgPerson))" CMD_USECDN: "false" - VIRTUAL_HOST: "{{ codimd.domain }}" - LETSENCRYPT_HOST: "{{ codimd.domain }}" + VIRTUAL_HOST: "{{ services.codimd.domain }}" + LETSENCRYPT_HOST: "{{ services.codimd.domain }}" LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}" diff --git a/roles/docker/tasks/services/mastodon.yml b/roles/docker/tasks/services/mastodon.yml index 613b97a..472ea95 100644 --- a/roles/docker/tasks/services/mastodon.yml +++ b/roles/docker/tasks/services/mastodon.yml @@ -6,6 +6,7 @@ group: "991" loop: - "postgres_data" + - "postgres_config" - "redis_data" - "mastodon_data" loop_control: @@ -21,17 +22,17 @@ src: files/configs/mastodon/vhost-mastodon dest: "{{ services.nginx_proxy.volume_folder }}/vhost/{{ services.mastodon.domain }}" -- name: Copy postgresql config +- name: Copy PostgreSQL config copy: src: files/configs/mastodon/postgresql.conf - dest: "{{ services.mastodon.volume_folder }}/postgres_data/postgresql.conf" + dest: "{{ services.mastodon.volume_folder }}/postgres_config/postgresql.conf" -- name: set up mastodon +- name: Set up Mastodon docker_compose: project_name: mastodon - pull: yes + pull: true + recreate: always definition: - x-sidekiq: &sidekiq image: "tootsuite/mastodon:{{ services.mastodon.version }}" restart: always @@ -62,6 +63,8 @@ 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'