@ -234,10 +234,14 @@ class AnsibleHcloudServer(Hcloud):
" server_type " : self . client . server_types . get_by_name (
" server_type " : self . client . server_types . get_by_name (
self . module . params . get ( " server_type " )
self . module . params . get ( " server_type " )
) ,
) ,
" image " : self . client . images . get_by_name ( self . module . params . get ( " image " ) ) ,
" user_data " : self . module . params . get ( " user_data " ) ,
" user_data " : self . module . params . get ( " user_data " ) ,
" labels " : self . module . params . get ( " labels " ) ,
" labels " : self . module . params . get ( " labels " ) ,
}
}
if self . client . images . get_by_name ( self . module . params . get ( " image " ) ) is not None :
# When image name is not available look for id instead
params [ " image " ] = self . client . images . get_by_name ( self . module . params . get ( " image " ) )
else :
params [ " image " ] = self . client . images . get_by_id ( self . module . params . get ( " image " ) )
if self . module . params . get ( " ssh_keys " ) is not None :
if self . module . params . get ( " ssh_keys " ) is not None :
params [ " ssh_keys " ] = [
params [ " ssh_keys " ] = [
@ -266,7 +270,7 @@ class AnsibleHcloudServer(Hcloud):
if not self . module . check_mode :
if not self . module . check_mode :
resp = self . client . servers . create ( * * params )
resp = self . client . servers . create ( * * params )
self . result [ " root_password " ] = resp . root_password
self . result [ " root_password " ] = resp . root_password
resp . action . wait_until_finished ( )
resp . action . wait_until_finished ( max_retries = 1000 )
[ action . wait_until_finished ( ) for action in resp . next_actions ]
[ action . wait_until_finished ( ) for action in resp . next_actions ]
self . _mark_as_changed ( )
self . _mark_as_changed ( )
self . _get_server ( )
self . _get_server ( )