-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup_consul-client.sh
43 lines (38 loc) · 1.06 KB
/
setup_consul-client.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#! /bin/sh
# https://devopscube.com/hsetup-configure-consul-agent-client-mode/
# https://imaginea.gitbooks.io/consul-devops-handbook/content/agent_configuration.html
export NODEIP="192.168.60.13"
export NODENAME="patroni3-client"
sudo touch /etc/consul.d/client/config.json
tee -a /etc/consul.d/client/config.json <<EOF
{
"node_name": "${NODENAME}",
"bind_addr": "${NODEIP}",
"server": false,
"datacenter": "dc1",
"data_dir": "/var/consul",
"encrypt": "oXtFDsSFRWbicMOynL3FmzM0ZEMI/bWv+/ilC8OXh80=",
"log_level": "INFO",
"enable_syslog": true,
"rejoin_after_leave": true,
"retry_join": [
"192.168.60.2",
"192.168.60.3",
"192.168.60.4"
]
}
EOF
sudo touch /etc/systemd/system/consul-client.service
tee -a /etc/systemd/system/consul-client.service <<EOF
[Unit]
Description=Consul Startup process
After=network.target
[Service]
Type=simple
ExecStart=/bin/bash -c '/usr/bin/consul agent -config-dir /etc/consul.d/client'
TimeoutStartSec=0
Restart=on-failure
RestartSec=2s
[Install]
WantedBy=default.target
EOF