This commit is contained in:
parent
a7c1478d15
commit
1fdff1c48b
@ -1,6 +1,10 @@
|
|||||||
---
|
---
|
||||||
- name: restart postgresql
|
- name: Restart postgresql
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: "{{ postgresql_daemon }}"
|
name: "{{ postgresql_daemon }}"
|
||||||
state: "{{ postgresql_restarted_state }}"
|
state: "{{ postgresql_restarted_state }}"
|
||||||
sleep: 5
|
sleep: 5
|
||||||
|
|
||||||
|
- name: Reload consul configuration on Linux
|
||||||
|
ansible.builtin.command: "consul reload"
|
||||||
|
listen: "reload consul configuration"
|
||||||
|
7
tasks/consul.yml
Normal file
7
tasks/consul.yml
Normal 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
|
@ -24,3 +24,7 @@
|
|||||||
# Configure PostgreSQL.
|
# Configure PostgreSQL.
|
||||||
- import_tasks: users.yml
|
- import_tasks: users.yml
|
||||||
- import_tasks: databases.yml
|
- import_tasks: databases.yml
|
||||||
|
|
||||||
|
- name: Import Consul service task
|
||||||
|
ansible.builtin.import_tasks: consul.yml
|
||||||
|
when: postgres_consul_service
|
||||||
|
16
templates/consul.d/postgres.hcl.j2
Normal file
16
templates/consul.d/postgres.hcl.j2
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user