mirror of
https://github.com/ansible-collections/hetzner.hcloud.git
synced 2026-02-04 08:01:49 +00:00
fix: zone rrset idempotency (#737)
##### SUMMARY - The order of dns records is not guaranteed, this ensure the module is idempotent. - The API defaults to an empty string when comments are not set, ensure the module is idempotent when no comments are given. ##### ISSUE TYPE - Bugfix Closes #740
This commit is contained in:
parent
f87c23629b
commit
79f78fae28
4 changed files with 20 additions and 9 deletions
|
|
@ -199,7 +199,7 @@ class AnsibleHCloudZoneRRSet(AnsibleHCloud):
|
|||
def _prepare_result_record(self, record: ZoneRecord):
|
||||
return {
|
||||
"value": record.value,
|
||||
"comment": record.comment,
|
||||
"comment": record.comment or "", # API defaults to "", this ensure idempotency
|
||||
}
|
||||
|
||||
def _get(self):
|
||||
|
|
@ -321,6 +321,9 @@ class AnsibleHCloudZoneRRSet(AnsibleHCloud):
|
|||
current = [self._prepare_result_record(o) for o in self.hcloud_zone_rrset.records]
|
||||
wanted = [self._prepare_result_record(ZoneRecord.from_dict(o)) for o in self.module.params.get("records")]
|
||||
|
||||
current = sorted(current, key=lambda x: x["value"])
|
||||
wanted = sorted(wanted, key=lambda x: x["value"])
|
||||
|
||||
return current != wanted
|
||||
|
||||
def present(self):
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ class AnsibleHCloudZoneRRSetInfo(AnsibleHCloud):
|
|||
def _prepare_result_record(self, record: ZoneRecord):
|
||||
return {
|
||||
"value": record.value,
|
||||
"comment": record.comment,
|
||||
"comment": record.comment or "",
|
||||
}
|
||||
|
||||
def get_zone_rrsets(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue