Skip to content

Commit

Permalink
Improve own IP resolution
Browse files Browse the repository at this point in the history
--ip-address is to be deprecated, change it to --all-ip-addresses.
  • Loading branch information
jubarbot-cisco committed Sep 11, 2018
1 parent c062a35 commit cdd9c85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions salt/self-registration/files/register-node.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Parameters:
# $1 - service name
# $2 - port
# IP address is automatically determined with hostname --ip-address
export MY_IP=$(hostname --ip-address)
# IP address is automatically determined with hostname hostname -I | cut -f 1 -d ' '
export MY_IP=$(hostname -I | cut -f 1 -d ' ')
curl \
--request PUT \
--data "{\"Node\": \"$(hostname)\",\"Address\": \"$MY_IP\", \"Datacenter\":\"{{ consul_datacenter }}\", \"TaggedAddresses\":{\"lan\":\"$MY_IP\",\"wan\":\"$MY_IP\"}}" \
Expand Down
5 changes: 3 additions & 2 deletions salt/self-registration/files/register-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
# Parameters:
# $1 - service name
# $2 - port
# IP address is automatically determined with hostname --ip-address
curl --request PUT --data "{\"ID\": \"$1\",\"Name\": \"$1\",\"Address\": \"$(hostname --ip-address)\",\"Port\": $2}" http://$(hostname --ip-address):8500/v1/agent/service/register
# IP address is automatically determined with hostname -I | cut -f 1 -d ' '
export MY_IP=$(hostname -I | cut -f 1 -d ' ')
curl --request PUT --data "{\"ID\": \"$1\",\"Name\": \"$1\",\"Address\": \"${MY_IP}\",\"Port\": $2}" http://${MY_IP}:8500/v1/agent/service/register

0 comments on commit cdd9c85

Please sign in to comment.