Refactor condition for changed result
This commit is contained in:
parent
360bc2a587
commit
734e89e720
1 changed files with 11 additions and 10 deletions
|
@ -57,6 +57,7 @@ def main():
|
||||||
if p['zone'] is None or z == p['zone']:
|
if p['zone'] is None or z == p['zone']:
|
||||||
zone = d.get_zone(z.id)
|
zone = d.get_zone(z.id)
|
||||||
|
|
||||||
|
skipAdd = False
|
||||||
if p['subdomain'].removesuffix(d.domain) in zone.services:
|
if p['subdomain'].removesuffix(d.domain) in zone.services:
|
||||||
for s in zone.services[p['subdomain'].removesuffix(d.domain)]:
|
for s in zone.services[p['subdomain'].removesuffix(d.domain)]:
|
||||||
if s._svctype == p['type']:
|
if s._svctype == p['type']:
|
||||||
|
@ -67,19 +68,20 @@ def main():
|
||||||
differ = True
|
differ = True
|
||||||
break
|
break
|
||||||
|
|
||||||
if p['erase_others']:
|
if p['state'] == 'absent' and not differ:
|
||||||
|
s.delete()
|
||||||
|
result['changed'] = True
|
||||||
|
elif p['erase_others']:
|
||||||
if differ:
|
if differ:
|
||||||
s.delete()
|
s.delete()
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
elif not differ:
|
|
||||||
if p['state'] == 'absent':
|
|
||||||
s.delete()
|
|
||||||
result['changed'] = True
|
|
||||||
else:
|
else:
|
||||||
module.exit_json(**result)
|
skipAdd = True
|
||||||
return
|
elif not differ:
|
||||||
|
module.exit_json(**result)
|
||||||
|
return
|
||||||
|
|
||||||
if p['state'] != 'absent':
|
if not skipAdd and p['state'] != 'absent':
|
||||||
zone.add_zone_service(
|
zone.add_zone_service(
|
||||||
p['subdomain'].removesuffix(d.domain),
|
p['subdomain'].removesuffix(d.domain),
|
||||||
p['type'],
|
p['type'],
|
||||||
|
@ -88,10 +90,9 @@ def main():
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
|
|
||||||
|
|
||||||
if p['apply_changes']:
|
if p['apply_changes'] and result['changed']:
|
||||||
zone.apply_changes()
|
zone.apply_changes()
|
||||||
result['published'] = True
|
result['published'] = True
|
||||||
result['changed'] = True
|
|
||||||
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue