Compare commits
4 Commits
369c2ec692
...
db_constra
| Author | SHA1 | Date | |
|---|---|---|---|
| 679fc59e7b | |||
| 396998d655 | |||
| e79a14dcc3 | |||
| 370e5051cb |
@@ -6,3 +6,9 @@
|
|||||||
ansible.builtin.systemd_service:
|
ansible.builtin.systemd_service:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
scope: user
|
scope: user
|
||||||
|
|
||||||
|
- name: Run mastodon database migrations
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: podman exec mastodon rails db:migrate
|
||||||
|
register: mastodon_db_migrate
|
||||||
|
changed_when: mastodon_db_migrate.stdout | length > 0
|
||||||
|
|||||||
49
roles/mastodon/tasks/db_constraints.yml
Normal file
49
roles/mastodon/tasks/db_constraints.yml
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
- name: Wait for database to accept connections
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv:
|
||||||
|
- podman
|
||||||
|
- exec
|
||||||
|
- database
|
||||||
|
- pg_isready
|
||||||
|
- -U
|
||||||
|
- "{{ mastodon_database.username }}"
|
||||||
|
- -d
|
||||||
|
- mastodon
|
||||||
|
register: mastodon_db_ready
|
||||||
|
until: mastodon_db_ready.rc == 0
|
||||||
|
retries: 30
|
||||||
|
delay: 2
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Ensure invite_block_spam_bot constraint on user_invite_requests
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv:
|
||||||
|
- podman
|
||||||
|
- exec
|
||||||
|
- database
|
||||||
|
- psql
|
||||||
|
- -U
|
||||||
|
- "{{ mastodon_database.username }}"
|
||||||
|
- -d
|
||||||
|
- mastodon
|
||||||
|
- -v
|
||||||
|
- ON_ERROR_STOP=1
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
DO $$
|
||||||
|
BEGIN
|
||||||
|
IF NOT EXISTS (
|
||||||
|
SELECT 1 FROM pg_constraint
|
||||||
|
WHERE conname = 'invite_block_spam_bot'
|
||||||
|
AND conrelid = 'public.user_invite_requests'::regclass
|
||||||
|
) THEN
|
||||||
|
ALTER TABLE public.user_invite_requests
|
||||||
|
ADD CONSTRAINT invite_block_spam_bot
|
||||||
|
CHECK (text NOT ILIKE 'Automated protocol deliverability probe');
|
||||||
|
RAISE NOTICE 'invite_block_spam_bot constraint added';
|
||||||
|
END IF;
|
||||||
|
END
|
||||||
|
$$;
|
||||||
|
register: mastodon_db_constraint
|
||||||
|
changed_when: "'invite_block_spam_bot constraint added' in mastodon_db_constraint.stderr"
|
||||||
@@ -123,3 +123,6 @@
|
|||||||
- elasticsearch.service
|
- elasticsearch.service
|
||||||
- mastodon.service
|
- mastodon.service
|
||||||
- sidekiq.service
|
- sidekiq.service
|
||||||
|
|
||||||
|
- name: Ensure database constraints
|
||||||
|
ansible.builtin.include_tasks: db_constraints.yml
|
||||||
|
|||||||
@@ -10,4 +10,6 @@
|
|||||||
state: present
|
state: present
|
||||||
src: "{{ mastodon_quadlet_tmp.path }}/sidekiq.container"
|
src: "{{ mastodon_quadlet_tmp.path }}/sidekiq.container"
|
||||||
reload_systemd: false
|
reload_systemd: false
|
||||||
notify: Reload systemd user units
|
notify:
|
||||||
|
- Reload systemd user units
|
||||||
|
- Run mastodon database migrations
|
||||||
|
|||||||
@@ -10,4 +10,6 @@
|
|||||||
state: present
|
state: present
|
||||||
src: "{{ mastodon_quadlet_tmp.path }}/mastodon.container"
|
src: "{{ mastodon_quadlet_tmp.path }}/mastodon.container"
|
||||||
reload_systemd: false
|
reload_systemd: false
|
||||||
notify: Reload systemd user units
|
notify:
|
||||||
|
- Reload systemd user units
|
||||||
|
- Run mastodon database migrations
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Requires=database.service redis.service elasticsearch.service
|
|||||||
|
|
||||||
[Container]
|
[Container]
|
||||||
ContainerName=mastodon
|
ContainerName=mastodon
|
||||||
Image=ghcr.io/mastodon/mastodon:v4.6.8
|
Image=ghcr.io/mastodon/mastodon:v4.6.11
|
||||||
Exec=bundle exec puma -C config/puma.rb
|
Exec=bundle exec puma -C config/puma.rb
|
||||||
Network=mastodon_internal.network
|
Network=mastodon_internal.network
|
||||||
Network=podman
|
Network=podman
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Requires=database.service redis.service elasticsearch.service
|
|||||||
|
|
||||||
[Container]
|
[Container]
|
||||||
ContainerName=sidekiq
|
ContainerName=sidekiq
|
||||||
Image=ghcr.io/mastodon/mastodon:v4.6.8
|
Image=ghcr.io/mastodon/mastodon:v4.6.11
|
||||||
Exec=bundle exec sidekiq
|
Exec=bundle exec sidekiq
|
||||||
Network=mastodon_internal.network
|
Network=mastodon_internal.network
|
||||||
Environment=LOCAL_DOMAIN=wtf.lt
|
Environment=LOCAL_DOMAIN=wtf.lt
|
||||||
|
|||||||
Reference in New Issue
Block a user