--- # file: roles/postgres/tasks/zabbix.yml - name: "[zabbix] scripts" copy: src: "{{ item }}" dest: "/etc/zabbix/scripts/{{ item }}" mode: 0755 loop: - pg_stat_database.sh - pg_connection_reaper.sh - pg_replication_slots_discovery.sh tags: - postgres - zabbix - name: "[zabbix] /etc/zabbix/zabbix_agentd.conf.d/postgresql.conf (static)" copy: src: zabbix_postgresql.conf dest: /etc/zabbix/zabbix_agentd.conf.d/postgresql.conf mode: 0644 notify: restart zabbix_agent tags: - postgres - zabbix - name: "[zabbix] pg < 10 specific" set_fact: postgres_zabbix_stat_replication_bytelag: "{{ postgres_zabbix_legacy_stat_replication_bytelag }}" when: pg_version is version('10', '<') tags: - postgres - zabbix - name: "[zabbix] pg >= 10 specific" set_fact: postgres_zabbix_stat_replication_bytelag: "{{ postgres_zabbix_modern_stat_replication_bytelag }}" when: pg_version is version('10', '>=') tags: - postgres - zabbix - name: "[zabbix] /etc/zabbix/zabbix_agentd.conf.d/postgresql_template.conf (template)" template: src: "zabbix_postgresql_template.conf" dest: "/etc/zabbix/zabbix_agentd.conf.d/postgresql_template.conf" mode: 0644 notify: restart zabbix_agent tags: - postgres - zabbix - name: "[zabbix] pg >= 13: crontab to reset the postgres SLRU stats once a day" cron: name: "postgres: reset SLRU stats" hour: "00" minute: "00" job: 'psql -Atc "SELECT pg_stat_reset_slru(NULL)"' user: "postgres" when: pg_version is version('13', '>=') tags: - postgres - zabbix