๐Ÿ“— Ansible playbooks and roles for building an idempotent, interconnected and scalable infrastructure
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible-playbooks/roles/postgres/tasks/maintenance.yml

23 lines
546 B

2 years ago
- name: get info about all databases
community.postgresql.postgresql_info:
filter:
- databases
register: pg_databases
- block:
- name: vacuum and analyze database
community.postgresql.postgresql_query:
db: "{{ item.database_name }}"
query: VACUUM FULL ANALYZE;
changed_when: no
- name: reindex database
community.postgresql.postgresql_query:
db: "{{ item.database_name }}"
query: 'REINDEX DATABASE "{{ item.database_name }}";'
changed_when: no
loop: "{{ pg_databases.databases }}"