Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.6] route53: fix CAA record ordering for idempotency #46226

Merged
merged 2 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/46049-route53-caa-ordering.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "route53 - fix CAA record ordering for idempotency."
14 changes: 12 additions & 2 deletions lib/ansible/modules/cloud/amazon/route53.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,13 @@ def main():
else:
wanted_rset.add_value(v)

need_to_sort_records = (type_in == 'CAA')

# Sort records for wanted_rset if necessary (keep original list)
unsorted_records = wanted_rset.resource_records
if need_to_sort_records:
wanted_rset.resource_records = sorted(unsorted_records)

sets = invoke_with_throttling_retries(conn.get_all_rrsets, zone.id, name=record_in,
type=type_in, identifier=identifier_in)
sets_iter = iter(sets)
Expand All @@ -593,13 +600,14 @@ def main():
identifier_in = str(identifier_in)

if rset.type == type_in and decoded_name.lower() == record_in.lower() and rset.identifier == identifier_in:
if need_to_sort_records:
# Sort records
rset.resource_records = sorted(rset.resource_records)
found_record = True
record['zone'] = zone_in
record['type'] = rset.type
record['record'] = decoded_name
record['ttl'] = rset.ttl
record['value'] = ','.join(sorted(rset.resource_records))
record['values'] = sorted(rset.resource_records)
if hosted_zone_id_in:
record['hosted_zone_id'] = hosted_zone_id_in
record['identifier'] = rset.identifier
Expand Down Expand Up @@ -652,6 +660,8 @@ def main():
command = 'UPSERT'
else:
command = command_in.upper()
# Restore original order of records
wanted_rset.resource_records = unsorted_records
changes.add_change_record(command, wanted_rset)

if not module.check_mode:
Expand Down