infra-role-postgres-ha/tasks/consul.yml

49 lines
2.5 KiB
YAML

---
- name: Create Consul service definition
include_role: name=infra-role-consul-service
vars:
consul_config_name: '{{ postgres_ha_service_name }}'
consul_default_check_disabled: '{{ postgres_ha_consul_check_disabled }}'
consul_default_check_interval: '{{ postgres_ha_consul_check_interval }}'
consul_default_check_timeout: '{{ postgres_ha_consul_check_timeout }}'
consul_default_success_before_passing: '{{ postgres_ha_consul_success_before_passing }}'
consul_default_failures_before_warning: '{{ postgres_ha_consul_failures_before_warning }}'
consul_default_failures_before_critical: '{{ postgres_ha_consul_failures_before_critical }}'
consul_services:
- id: '{{ postgres_ha_service_name }}'
name: '{{ postgres_ha_consul_service }}'
tags: ['postgres', 'database']
port: '{{ postgres_ha_cont_port }}'
checks:
- id: '{{ postgres_ha_service_name }}-status'
name: 'PostgreSQL DB Healthcheck'
type: 'tcp'
tcp: 'localhost:{{ postgres_ha_cont_port }}'
- id: '{{ postgres_ha_service_name }}-{{ postgres_ha_replica_enabled | ternary("replica", "tables") }}'
name: 'PostgreSQL {{ postgres_ha_replica_enabled | ternary("Replica", "Tables") }} Healthcheck'
type: 'script'
script: '{{ postgres_ha_service_path }}/health.sh'
- name: 'postgres-metrics'
id: '{{ postgres_ha_metrics_exporter_cont_name }}'
tags: [ 'postgres-metrics', 'perf']
port: '{{ postgres_ha_metrics_exporter_cont_port }}'
address: '{{ ansible_local.wireguard.address }}'
checks:
- id: '{{ postgres_ha_metrics_exporter_cont_name }}-status'
name: 'PostgreSQL Metrics exporter'
type: 'tcp'
tcp: 'localhost:{{ postgres_ha_metrics_exporter_cont_port }}'
- name: 'postgres-perf-metrics'
id: '{{ postgres_ha_perf_metrics_exporter_cont_name }}'
tags: [ 'postgres-metrics', 'perf']
port: '{{ postgres_ha_perf_metrics_exporter_cont_port }}'
address: '{{ ansible_local.wireguard.address }}'
disabled: '{{ postgres_ha_perf_metrics_exporter_disabled | to_json }}'
checks:
- id: '{{ postgres_ha_perf_metrics_exporter_cont_name }}-status'
name: 'PostgreSQL Metrics exporter'
type: 'tcp'
tcp: 'localhost:{{ postgres_ha_perf_metrics_exporter_cont_port }}'