Hi,
How do I insert my public facing IP (from the machine running Ansible aka client)? Usecase: insert my own IP in sshguard’s whitelist.
Thanks!
Mathias
Hi,
How do I insert my public facing IP (from the machine running Ansible aka client)? Usecase: insert my own IP in sshguard’s whitelist.
Thanks!
Mathias
How do I insert my public facing IP (from the machine running Ansible aka
client)? Usecase: insert my own IP in sshguard's whitelist.
Use one of the myriad 'what's my IP address' services (e.g.
http://ifconfig.me), register the output in a variable and use that
further in the play.
-JP
> How do I insert my public facing IP (from the machine running Ansible aka
> client)? Usecase: insert my own IP in sshguard's whitelist.Use one of the myriad 'what's my IP address' services (e.g.
http://ifconfig.me), register the output in a variable and use that
further in the play.
My personal favorite is icanhazip.com, it just returns the IP as plain text.
For details, see https://major.io/icanhazip-com-faq/
Lorin
Hey Mathias,
Are you running “In The Cloud” (I couldn’t find a hipster font for this)? Or is this IP natted or something? A system fact doesn’t satisfy?
My personal favorite is icanhazip.com, it just returns the IP as plain text.
JSON anybody? http://jsonip.appspot.com
;-)
-JP
ansible localhost -m uri -a url=http://ifconfig.me/all.json
BTW, the register keyword is the great way to save the CLI result of command in a variable.
Not sure how much that service likes you pounding on it in automated fashion
Not sure how much that service likes you pounding on it in automated
fashion
Very true.
One (little-known) service that explicitly allows that is OpenDNS, who
provide a DNS server that returns an A record containing the IP address
of the requestor. In the context of the original poster, that would be
my "outside" IP address:
ansible localhost -m command -a 'dig +short myip.opendns.com @resolver1.opendns.com'
Needless to say, this means that the host running this needs to be able
to resolve and access that DNS service.
-JP