@ -201,7 +201,7 @@ try:
except ImportError :
pass
from ansible . module_utils . basic import AnsibleModule
from ansible . module_utils . basic import AnsibleModule , env_fallback
class TimeoutError ( Exception ) :
@ -346,11 +346,7 @@ def core(module):
module . fail_json ( msg = ' Unable to load %s ' % k )
return v
try :
api_token = module . params [ ' api_token ' ] or os . environ [ ' DO_API_TOKEN ' ] or os . environ [ ' DO_API_KEY ' ]
except KeyError as e :
module . fail_json ( msg = ' Unable to load %s ' % e . message )
api_token = module . params [ ' api_token ' ]
changed = True
command = module . params [ ' command ' ]
state = module . params [ ' state ' ]
@ -432,7 +428,11 @@ def main():
argument_spec = dict (
command = dict ( choices = [ ' droplet ' , ' ssh ' ] , default = ' droplet ' ) ,
state = dict ( choices = [ ' active ' , ' present ' , ' absent ' , ' deleted ' ] , default = ' present ' ) ,
api_token = dict ( aliases = [ ' API_TOKEN ' ] , no_log = True ) ,
api_token = dict (
aliases = [ ' API_TOKEN ' ] ,
no_log = True ,
fallback = ( env_fallback , [ ' DO_API_TOKEN ' , ' DO_API_KEY ' ] )
) ,
name = dict ( type = ' str ' ) ,
size_id = dict ( ) ,
image_id = dict ( ) ,