Always recreate Mastodon containers (#134)

Fixes #133.

Co-authored-by: Sam Al-Sapti <sam@sapti.me>
Reviewed-on: #134
Co-authored-by: Sam A. <samsapti@noreply@git.data.coop>
Co-committed-by: Sam A. <samsapti@noreply@git.data.coop>
This commit is contained in:
Sam A. 2022-12-04 21:45:32 +00:00 committed by valberg
parent 759ea93dd3
commit c4f3911400
5 changed files with 18 additions and 17 deletions

2
Vagrantfile vendored
View file

@ -13,7 +13,7 @@ Vagrant.configure(2) do |config|
config.vm.hostname = "datacoop" config.vm.hostname = "datacoop"
config.vm.provider :virtualbox do |v| config.vm.provider :virtualbox do |v|
v.memory = 4096 v.memory = 8192
end end
config.vm.provision :ansible do |ansible| config.vm.provision :ansible do |ansible|

View file

@ -11,7 +11,7 @@ usage () {
BASE_CMD="ansible-playbook playbook.yml --ask-vault-pass" BASE_CMD="ansible-playbook playbook.yml --ask-vault-pass"
if [ "$1" = "--vagrant" ]; then if [ "$1" = "--vagrant" ]; then
BASE_CMD="$BASE_CMD --inventory=vagrant_host" BASE_CMD="$BASE_CMD --verbose --inventory=vagrant_host"
shift shift
fi fi

View file

@ -3,13 +3,14 @@
gather_facts: true gather_facts: true
become: true become: true
vars: vars:
base_domain: data.coop
letsencrypt_email: admin@data.coop
ldap_dn: "dc=data,dc=coop" ldap_dn: "dc=data,dc=coop"
vagrant: "{{ ansible_virtualization_role == 'guest' }}" vagrant: "{{ ansible_virtualization_role == 'guest' }}"
letsencrypt_enabled: "{{ not vagrant }}" letsencrypt_enabled: "{{ not vagrant }}"
base_domain: "{{ 'datacoop.devel' if vagrant else 'data.coop' }}"
letsencrypt_email: "admin@{{ base_domain }}"
smtp_host: "postfix" smtp_host: "postfix"
smtp_port: "587" smtp_port: "587"

View file

@ -1,17 +1,15 @@
--- ---
- name: codimd network - name: codimd network
docker_network: docker_network:
name: codimd name: codimd
- name: create codimd volume folders - name: create codimd volume folders
file: file:
name: "{{ codimd.volume_folder }}/{{ volume }}" name: "{{ services.codimd.volume_folder }}/{{ volume }}"
state: directory state: directory
loop: loop:
- "db" - "db"
- "codimd/uploads" - "codimd/uploads"
loop_control: loop_control:
loop_var: volume loop_var: volume
@ -24,7 +22,7 @@
networks: networks:
- name: codimd - name: codimd
volumes: volumes:
- "{{ codimd.volume_folder }}/db:/var/lib/postgresql/data" - "{{ services.codimd.volume_folder }}/db:/var/lib/postgresql/data"
env: env:
POSTGRES_USER: "codimd" POSTGRES_USER: "codimd"
POSTGRES_PASSWORD: "{{ postgres_passwords.codimd }}" POSTGRES_PASSWORD: "{{ postgres_passwords.codimd }}"
@ -39,8 +37,7 @@
- name: ldap - name: ldap
- name: external_services - name: external_services
volumes: volumes:
- "{{ codimd.volume_folder }}/codimd/uploads:/codimd/public/uploads" - "{{ services.codimd.volume_folder }}/codimd/uploads:/codimd/public/uploads"
env: env:
CMD_DB_URL: "postgres://codimd:{{ postgres_passwords.codimd }}@codimd_db:5432/codimd" CMD_DB_URL: "postgres://codimd:{{ postgres_passwords.codimd }}@codimd_db:5432/codimd"
CMD_ALLOW_EMAIL_REGISTER: "False" CMD_ALLOW_EMAIL_REGISTER: "False"
@ -52,6 +49,6 @@
CMD_LDAP_SEARCHBASE: "dc=data,dc=coop" CMD_LDAP_SEARCHBASE: "dc=data,dc=coop"
CMD_LDAP_SEARCHFILTER: "(&(uid={{ '{{username}}' }})(objectClass=inetOrgPerson))" CMD_LDAP_SEARCHFILTER: "(&(uid={{ '{{username}}' }})(objectClass=inetOrgPerson))"
CMD_USECDN: "false" CMD_USECDN: "false"
VIRTUAL_HOST: "{{ codimd.domain }}" VIRTUAL_HOST: "{{ services.codimd.domain }}"
LETSENCRYPT_HOST: "{{ codimd.domain }}" LETSENCRYPT_HOST: "{{ services.codimd.domain }}"
LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}" LETSENCRYPT_EMAIL: "{{ letsencrypt_email }}"

View file

@ -6,6 +6,7 @@
group: "991" group: "991"
loop: loop:
- "postgres_data" - "postgres_data"
- "postgres_config"
- "redis_data" - "redis_data"
- "mastodon_data" - "mastodon_data"
loop_control: loop_control:
@ -21,17 +22,17 @@
src: files/configs/mastodon/vhost-mastodon src: files/configs/mastodon/vhost-mastodon
dest: "{{ services.nginx_proxy.volume_folder }}/vhost/{{ services.mastodon.domain }}" dest: "{{ services.nginx_proxy.volume_folder }}/vhost/{{ services.mastodon.domain }}"
- name: Copy postgresql config - name: Copy PostgreSQL config
copy: copy:
src: files/configs/mastodon/postgresql.conf 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: docker_compose:
project_name: mastodon project_name: mastodon
pull: yes pull: true
recreate: always
definition: definition:
x-sidekiq: &sidekiq x-sidekiq: &sidekiq
image: "tootsuite/mastodon:{{ services.mastodon.version }}" image: "tootsuite/mastodon:{{ services.mastodon.version }}"
restart: always restart: always
@ -62,6 +63,8 @@
test: ['CMD', 'pg_isready', '-U', 'postgres'] test: ['CMD', 'pg_isready', '-U', 'postgres']
volumes: volumes:
- "{{ services.mastodon.volume_folder }}/postgres_data:/var/lib/postgresql/data" - "{{ 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: environment:
- 'POSTGRES_HOST_AUTH_METHOD=trust' - 'POSTGRES_HOST_AUTH_METHOD=trust'