Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/saltyorg/Saltbox
Browse files Browse the repository at this point in the history
  • Loading branch information
owine committed Sep 12, 2023
2 parents a8bbda3 + a49479e commit dd48f27
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ansible_facts.d/network.fact
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

# https://github.com/mtecer/terraform/blob/master/bmc/files/ansible/custom.fact

RES=$(curl -s -w "%{http_code}" --connect-timeout 2.37 -4 https://ipify.saltbox.dev)
RES=$(curl -s -w "%{http_code}" --connect-timeout 3 -4 https://ipify.saltbox.dev)
BODY=${RES::-3}
STATUS=$(printf "%s" "$RES" | tail -c 3)
if [[ "$STATUS" == 200 ]] && [ -n "${BODY-unset}" ]; then
# Server returned 200 response
PUBLIC_IP=$BODY
else
# Server didn't return 200 response, so falling back to icanhazip.com
PUBLIC_IP=$(curl --connect-timeout 2.37 -s -4 https://ipv4.icanhazip.com)
PUBLIC_IP=$(curl --connect-timeout 3 -s -4 https://ipv4.icanhazip.com)
fi

RES6=$(curl -s -w "%{http_code}" --connect-timeout 2.37 -6 https://ipify6.saltbox.dev)
RES6=$(curl -s -w "%{http_code}" --connect-timeout 3 -6 https://ipify6.saltbox.dev)
BODY6=${RES6::-3}
STATUS6=$(printf "%s" "$RES6" | tail -c 3)
if [[ "$STATUS6" == 200 ]] && [ -n "${BODY6-unset}" ]; then
# Server returned 200 response
PUBLIC_IPv6=$BODY6
else
# Server didn't return 200 response, so falling back to icanhazip.com
PUBLIC_IPv6=$(curl --connect-timeout 2.37 -s -6 https://ipv6.icanhazip.com)
PUBLIC_IPv6=$(curl --connect-timeout 3 -s -6 https://ipv6.icanhazip.com)
fi

echo "[ip]"
Expand Down

0 comments on commit dd48f27

Please sign in to comment.