feat: add consul service
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
vincent 2023-10-31 20:11:28 +01:00
parent a7c1478d15
commit 1fdff1c48b
4 changed files with 33 additions and 2 deletions

View File

@ -1,6 +1,10 @@
---
- name: restart postgresql
service:
- name: Restart postgresql
ansible.builtin.service:
name: "{{ postgresql_daemon }}"
state: "{{ postgresql_restarted_state }}"
sleep: 5
- name: Reload consul configuration on Linux
ansible.builtin.command: "consul reload"
listen: "reload consul configuration"

7
tasks/consul.yml Normal file
View File

@ -0,0 +1,7 @@
- name: Template consul service
ansible.builtin.template:
src: consul.d/postgres.hcl.j2
dest: /etc/consul.d/postgres.hcl
owner: consul
mode: "0644"
notify: Reload consul configuration on Linux

View File

@ -24,3 +24,7 @@
# Configure PostgreSQL.
- import_tasks: users.yml
- import_tasks: databases.yml
- name: Import Consul service task
ansible.builtin.import_tasks: consul.yml
when: postgres_consul_service

View File

@ -0,0 +1,16 @@
service {
name = "{{ postgres_consul_service_name }}"
id = "{{ postgres_consul_service_name }}"
port = 5432
tags = ["{{postgres_consul_tag}}"]
check
{
id = "check-{{ postgres_consul_service_name }}",
name = "{{ postgres_consul_service_name }} status check",
service_id = "{{ postgres_consul_service_name }}",
tcp = "localhost:5432",
interval = "5s",
timeout = "5s"
}
}