From 40bd4df9576d20135cfabda2fff36efadcef555d Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Fri, 13 Sep 2024 16:50:45 +0100 Subject: [PATCH] Add a weekly cron job to repack all databases --- ansible/roles/postgres/tasks/pg_repack.yml | 11 +++++++++++ ansible/roles/postgres/vars/main/main.yml | 1 + 2 files changed, 12 insertions(+) diff --git a/ansible/roles/postgres/tasks/pg_repack.yml b/ansible/roles/postgres/tasks/pg_repack.yml index 907c83f0..7f708a0c 100644 --- a/ansible/roles/postgres/tasks/pg_repack.yml +++ b/ansible/roles/postgres/tasks/pg_repack.yml @@ -19,3 +19,14 @@ tags: - role::postgres - role::postgres-pg_repack + +- name: Add cronjob for running pg_repack on all databases + cron: + name: "Run pg_repack on all databases" + special_time: "weekly" + job: "pg_repack -a" + user: "{{ postgres_user }}" + cron_file: "{{ postgres_pg_repack_cron_filename }}" + tags: + - role::postgres + - role::postgres-pg_repack diff --git a/ansible/roles/postgres/vars/main/main.yml b/ansible/roles/postgres/vars/main/main.yml index 71d18733..d8f8ba9d 100644 --- a/ansible/roles/postgres/vars/main/main.yml +++ b/ansible/roles/postgres/vars/main/main.yml @@ -1,6 +1,7 @@ postgres_version: "15" postgres_daemon: "postgresql@{{ postgres_version }}-main" postgres_user: "postgres" +postgres_pg_repack_cron_filename: ansible_postgres_pg_repack postgres_users: - name: site