Merge pull request #9144 from jfrost/external_ip_grain

new external_ip grain for salt - requires that requests be installed
This commit is contained in:
Thomas S Hatch 2013-12-10 11:30:33 -08:00
commit 0923aed4d3

View File

@ -0,0 +1,20 @@
try:
import requests
HAS_REQUESTS = True
except:
HAS_REQUESTS = False
def external_ip():
'''
Return the external IP address reported by ipecho.net
'''
if not HAS_REQUESTS:
return []
try:
r = requests.get('http://ipecho.net/plain')
ip = r.content
except:
ip = []
return {'external_ip': ip}