---
#--------------------------------------------------------------#
# Postgres Exporter                                [pg_exporter]
#--------------------------------------------------------------#
# pg_exporter_config, pg_exporter_launch
- import_tasks: pg_exporter.yml
  tags: pg_exporter
  when: pg_exporter_enabled|bool

#--------------------------------------------------------------#
# Pgbouncer Exporter                        [pgbouncer_exporter]
#--------------------------------------------------------------#
# pgbouncer_exporter_config, pgbouncer_exporter_launch
- import_tasks: pgbouncer_exporter.yml
  tags: pgbouncer_exporter
  when: pgbouncer_enabled|bool and pgbouncer_exporter_enabled|bool

#--------------------------------------------------------------#
# Pgbackrest Exporter                      [pgbackrest_exporter]
#--------------------------------------------------------------#
# pgbackrest_exporter_config, pgbackrest_exporter_launch
- import_tasks: pgbackrest_exporter.yml
  tags: pgbackrest_exporter
  when: pgbackrest_enabled|bool and pgbackrest_exporter_enabled|bool

#--------------------------------------------------------------#
# Register Prometheus                 [add_metrics][pg_register]
#--------------------------------------------------------------#
- import_tasks: register_victoria.yml
  tags: [ pg_register, register, add_metrics ]

#--------------------------------------------------------------#
# Register Vector                        [add_logs][pg_register]
#--------------------------------------------------------------#
- import_tasks: register_vector.yml
  tags: [ pg_register, register, add_logs ]
  when: vector_enabled|bool

#--------------------------------------------------------------#
# Register Grafana                         [add_ds][pg_register]
#--------------------------------------------------------------#
# the database 'postgres' is registered by default
# if postgres is explicitly defined, it will be overridden
- include_tasks: register_grafana.yml
  tags: [ pg_register, register, add_ds ]
  when: grafana_enabled|bool and pg_provision|bool
  vars: { database: "{{ item }}" }
  with_items: "{{ [{'name': 'postgres'}] + pg_databases|default([]) }}"

...