Bug: repeatable invocation with state=present leads to (#3052)

[localhost]: FAILED! => {"changed": false, "failed": true, "msg":
"'Domain' object has no attribute 'id'"}

How to reproduce:

- name: create domain
  digital_ocean_domain: state=present name=DOMAIN_NAME ip=DROPLET_IP

- name: create domain
  digital_ocean_domain: state=present name=DOMAIN_NAME ip=DROPLET_IP

Problem: DigitalOcean API changed API
(https://developers.digitalocean.com/documentation/v2/#list-all-domain-records)
pull/18777/head
Andrei Lukovenko 8 years ago committed by Matt Clay
parent 544b044129
commit 436ff356e7

@ -128,7 +128,7 @@ class Domain(JsonfyMixIn):
self.manager.destroy_domain(self.name) self.manager.destroy_domain(self.name)
def records(self): def records(self):
json = self.manager.all_domain_records(self.id) json = self.manager.all_domain_records(self.name)
return map(DomainRecord, json) return map(DomainRecord, json)
@classmethod @classmethod
@ -194,12 +194,12 @@ def core(module):
records = domain.records() records = domain.records()
at_record = None at_record = None
for record in records: for record in records:
if record.name == "@" and record.record_type == 'A': if record.name == "@" and record.type == 'A':
at_record = record at_record = record
if not at_record.data == getkeyordie("ip"): if not at_record.data == getkeyordie("ip"):
record.update(data=getkeyordie("ip"), record_type='A') record.update(data=getkeyordie("ip"), record_type='A')
module.exit_json(changed=True, domain=Domain.find(id=record.domain_id).to_json()) module.exit_json(changed=True, domain=Domain.find(id=record.id).to_json())
module.exit_json(changed=False, domain=domain.to_json()) module.exit_json(changed=False, domain=domain.to_json())

Loading…
Cancel
Save