Created
December 10, 2013 17:39
-
-
Save jfrost/7894718 to your computer and use it in GitHub Desktop.
Simple saltstack grain that returns the external IP of a server. We use this in our rackspace private cloud to easily list the external IP associated with a particular instance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def external_ip(): | |
''' | |
Return the external IP address reported by ipecho.net | |
''' | |
try: | |
r = requests.get('http://ipecho.net/plain') | |
ip = r.content | |
except: | |
ip = '' | |
return {'external_ip': ip} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So every call to
salt-call --local grains.items
now makes a request to ipecho.net?