Skip to content

Commit

Permalink
Merge updates to autopilotpattern#46
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcelaya committed Dec 11, 2017
2 parents b15de52 + 5c4c2d4 commit 33ceafc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ In our experience, including a Consul cluster within a project's `docker-compose
[ERR] agent: Coordinate update error: No cluster leader
```
- `CONSUL_DATACENTER_NAME`: Explicitly set the name of the data center in which Consul is running. Consul flag: [`-datacenter`](https://www.consul.io/docs/agent/options.html#datacenter).
- If this variable is specified it will be used as-is.
- If not specified, automatic detection of the datacenter will be attempted. See [issue #23](https://github.com/autopilotpattern/consul/issues/23) for more details.
- Consul's default of "dc1" will be used if none of the above apply.
- `CONSUL_RETRY_JOIN_WAN`: sets the remote datacenter addresses to join. Must be a valid HCL list (i.e. comma-separated quoted addresses). Consul flag: [`-retry-join-wan`](https://www.consul.io/docs/agent/options.html#retry_join_wan).
- The following error will occur if `CONSUL_RETRY_JOIN_WAN` is provided but improperly formatted:
```
Expand Down
15 changes: 12 additions & 3 deletions bin/consul-manage
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ preStart() {
_log "Updating consul advertise address"
sed -i "s/CONTAINERPILOT_CONSUL_IP/${CONTAINERPILOT_CONSUL_IP}/" /etc/consul/consul.hcl

_log "Updating consul datacenter name"
sed -i "s/CONSUL_DATACENTER_NAME/${CONSUL_DATACENTER_NAME:-dc1}/" /etc/consul/consul.hcl
if [ -n "$CONSUL_DATACENTER_NAME" ]; then
_log "Updating consul datacenter name (specified: '${CONSUL_DATACENTER_NAME}' )"
sed -i "s/CONSUL_DATACENTER_NAME/${CONSUL_DATACENTER_NAME}/" /etc/consul/consul.hcl
elif [ -f "/native/usr/sbin/mdata-get" ]; then
DETECTED_DATACENTER_NAME=$(/native/usr/sbin/mdata-get sdc:datacenter_name)
_log "Updating consul datacenter name (detected: '${DETECTED_DATACENTER_NAME}')"
sed -i "s/CONSUL_DATACENTER_NAME/${DETECTED_DATACENTER_NAME}/" /etc/consul/consul.hcl
else
_log "Updating consul datacenter name (default: 'dc1')"
sed -i "s/CONSUL_DATACENTER_NAME/dc1/" /etc/consul/consul.hcl
fi

if [ ! -z "$CONSUL_RETRY_JOIN_WAN" ]; then
if [ -n "$CONSUL_RETRY_JOIN_WAN" ]; then
_log "Updating consul retry_join_wan field"
echo "retry_join_wan = [${CONSUL_RETRY_JOIN_WAN}]" >> /etc/consul/consul.hcl
fi
Expand Down

0 comments on commit 33ceafc

Please sign in to comment.