hashicorp / hashicorp/consul-template

Can't choose specific leader when use consul template for hosts settings

Open
#1,998 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
4.8k
Forks
801
Avg merge
4h 5m
Merged PRs (30d)
6

Description

Hi,
I use consul template for /etc/hosts settings , and I use citus + patroni.
I use citus groups feature in patroni. So my citus groups seem like this in patroni:
+ Citus cluster: mycluster -------------+---------+-----------+----+-----------+
| Group | Member | Host | Role | State | TL | Lag in MB |
+-------+-----------+------------------+---------+-----------+----+-----------+
| 0 | citus1 | 10.10.10.10| Leader | running | 1 | |
| 1 | citus1-02 | 10.10.10.11| Replica | streaming | 1 | 0 |
| 1 | citus2 | 10.10.10.12| Leader | running | 1 | |
| 1 | citus2-02 | 10.10.10.13| Replica | streaming | 1 | 0 |

+-------+-----------+------------------+---------+-----------+----+-----------+

I set up /etc/hosts config with consul template:
{{ range service "master.mycluster@datacenter1|passing" }}{{ .Address }} citus1-primary{{ end }}
{{ range service "replica.mycluster@datacenter1" }}{{ .Address }} citus1-replica{{ end }}

But both of 10.10.10.10 and 10.10.10.12 seem like leader and 10.10.10.11 and 10.10.10.13 seem like replica.
So /etc/hosts file seem like that:

10.10.10.10 citus1-primary 10.10.10.12 citus1-primary
10.10.10.11 citus1-replica 10.10.10.13 citus1-replica

I want to seperate this leader and replika by group number but I can't find this feature in consul template document.
Is there any solution for this?
Thanks.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.