Skip to content

Instantly share code, notes, and snippets.

@jfrost
Created December 10, 2013 17:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfrost/7894718 to your computer and use it in GitHub Desktop.
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.
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}
@jfrost
Copy link
Author

jfrost commented Dec 10, 2013

Merged into the saltstack develop branch.

@westurner
Copy link

So every call to salt-call --local grains.items now makes a request to ipecho.net?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment