def _load_params():
 global _ANSIBLE_ARGS
 if (_ANSIBLE_ARGS is not None):
  buffer = _ANSIBLE_ARGS
 else:
  if (len(sys.argv) > 1):
   if os.path.isfile(sys.argv[1]):
    fd = open(sys.argv[1], 'rb')
    buffer = fd.read()
    fd.close()
   else:
    buffer = sys.argv[1]
    if PY3:
     buffer = buffer.encode('utf-8', errors='surrogateescape')
  elif PY2:
   buffer = sys.stdin.read()
  else:
   buffer = sys.stdin.buffer.read()
  _ANSIBLE_ARGS = buffer
 try:
  params = json.loads(buffer.decode('utf-8'))
 except ValueError:
  print '\n{"msg": "Error: Module unable to decode valid JSON on stdin.  Unable to figure out what parameters were passed", "failed": true}'
  sys.exit(1)
 if PY2:
  params = json_dict_unicode_to_bytes(params)
 try:
  return params['ANSIBLE_MODULE_ARGS']
 except KeyError:
  print '\n{"msg": "Error: Module unable to locate ANSIBLE_MODULE_ARGS in json data from stdin.  Unable to figure out what parameters were passed", "failed": true}'
  sys.exit(1)

def _load_params ( ) : global _ANSIBLE_ARGS if ( _ANSIBLE_ARGS is not None ) : buffer = _ANSIBLE_ARGS else : if ( len ( sys . argv ) > 1 ) : if os . path . isfile ( sys . argv [ 1 ] ) : fd = open ( sys . argv [ 1 ] , 'rb' ) buffer = fd . read ( ) fd . close ( ) else : buffer = sys . argv [ 1 ] if PY3 : buffer = buffer . encode ( 'utf-8' , errors = 'surrogateescape' ) elif PY2 : buffer = sys . stdin . read ( ) else : buffer = sys . stdin . buffer . read ( ) _ANSIBLE_ARGS = buffer try : params = json . loads ( buffer . decode ( 'utf-8' ) ) except ValueError : print '\n{"msg": "Error: Module unable to decode valid JSON on stdin.  Unable to figure out what parameters were passed", "failed": true}' sys . exit ( 1 ) if PY2 : params = json_dict_unicode_to_bytes ( params ) try : return params [ 'ANSIBLE_MODULE_ARGS' ] except KeyError : print '\n{"msg": "Error: Module unable to locate ANSIBLE_MODULE_ARGS in json data from stdin.  Unable to figure out what parameters were passed", "failed": true}' sys . exit ( 1 )
read the modules parameters and store them globally .