# -*- coding: utf-8 -*-
'''
    :codeauthor: David Boucha
    :copyright: © 2013 by the SaltStack Team, see AUTHORS for more details.
    :license: Apache 2.0, see LICENSE for more details.


    salt.grains.external_ip
    ~~~~~~~~~~~~~~~~~~~~~~~

    Return the external IP address reported by boucha.saltstack.com
'''

# Import Python Libs
import logging
import requests
from pprint import pprint

# Import salt libs
from salt.utils.validate.net import ipv4_addr as _ipv4_addr

# Import errors
from requests.exceptions import Timeout, ConnectionError, HTTPError

log = logging.getLogger(__name__)

def external_ip():
    '''
    Return the external IP address
    '''
    check_url = 'http://boucha.saltstack.com:8080'

    if __opts__.get('request_external_ip', False):
        try:
            r = requests.get(check_url, timeout=0.1)
            ip_addr = r.json()
            return {'external_ip': ip_addr['ip_addr']}
        except Timeout as exc:
            log.debug('Timeout exceeded: {0}'.format(exc))
        except (ConnectionError, HTTPError) as exc:
            log.debug('Connection error: {0}'.format(exc))

    return {'external_ip': None}

@@ -289,36 +289,309 @@
 rted by 
-boucha.saltstack.com
+an IP reporting service.%0A    SaltStack provides this at http://boucha.saltstack.com:8080%0A%0A    The following config item is mandatory to opt in%0A%0A        external_ip.server: 'http://boucha.saltstack.com:8080'%0A%0A    The following minion config items are optional:%0A%0A        external_ip.timeout: 0.5
 %0A'''%0A%0A# 
@@ -643,34 +643,8 @@
 ests
-%0Afrom pprint import pprint
 %0A%0A# 
@@ -931,50 +931,103 @@
 l = 
-'http://boucha.saltstack.com:8080'%0A%0A    if
+__opts__.get('external_ip.server', False)%0A    if check_url: %0A        try:%0A            timeout =
  __o
@@ -1041,16 +1041,8 @@
 et('
-request_
 exte
@@ -1052,31 +1052,23 @@
 l_ip
-', False):%0A        try:
+.timeout', 0.5)
 %0A   
@@ -1116,11 +1116,15 @@
 out=
-0.1
+timeout
 )%0A  

Add requirement for opt in