@ -189,11 +189,22 @@ def main():
try :
try :
cloud = shade . openstack_cloud ( * * module . params )
cloud = shade . openstack_cloud ( * * module . params )
recordset = cloud . get_recordset ( zone , name + ' . ' + zone )
recordset_type = module . params . get ( ' recordset_type ' )
recordset_filter = { ' type ' : recordset_type }
recordsets = cloud . search_recordsets ( zone , name_or_id = name + ' . ' + zone , filters = recordset_filter )
if len ( recordsets ) == 1 :
recordset = recordsets [ 0 ]
try :
recordset_id = recordset [ ' id ' ]
except KeyError as e :
module . fail_json ( msg = str ( e ) )
else :
# recordsets is filtered by type and should never be more than 1 return
recordset = None
if state == ' present ' :
if state == ' present ' :
recordset_type = module . params . get ( ' recordset_type ' )
records = module . params . get ( ' records ' )
records = module . params . get ( ' records ' )
description = module . params . get ( ' description ' )
description = module . params . get ( ' description ' )
ttl = module . params . get ( ' ttl ' )
ttl = module . params . get ( ' ttl ' )
@ -219,10 +230,11 @@ def main():
zone , pre_update_recordset )
zone , pre_update_recordset )
if changed :
if changed :
zone = cloud . update_recordset (
zone = cloud . update_recordset (
zone , name + ' . ' + zone ,
zone , recordset_id ,
records = records ,
records = records ,
description = description ,
description = description ,
ttl = ttl )
ttl = ttl )
module . exit_json ( changed = changed , recordset = recordset )
module . exit_json ( changed = changed , recordset = recordset )
elif state == ' absent ' :
elif state == ' absent ' :
@ -235,7 +247,7 @@ def main():
if recordset is None :
if recordset is None :
changed = False
changed = False
else :
else :
cloud . delete_recordset ( zone , name + ' . ' + zone )
cloud . delete_recordset ( zone , recordset_id )
changed = True
changed = True
module . exit_json ( changed = changed )
module . exit_json ( changed = changed )