diff --git a/changelogs/fragments/1379-zero_weight_dns_fix.yml b/changelogs/fragments/1379-zero_weight_dns_fix.yml new file mode 100644 index 00000000000..bae7072cbbf --- /dev/null +++ b/changelogs/fragments/1379-zero_weight_dns_fix.yml @@ -0,0 +1,2 @@ +bugfixes: + - route53 - fixes bug preventing creating a DNS record with a weight of zero (https://github.com/ansible-collections/community.aws/issues/1378) \ No newline at end of file diff --git a/plugins/modules/route53.py b/plugins/modules/route53.py index bebdacdbf9a..db97197ec6b 100644 --- a/plugins/modules/route53.py +++ b/plugins/modules/route53.py @@ -628,7 +628,7 @@ def main(): if command_in == 'create' or command_in == 'delete': if alias_in and len(value_in) != 1: module.fail_json(msg="parameter 'value' must contain a single dns name for alias records") - if not any([weight_in, region_in, failover_in, geo_location]) and identifier_in is not None: + if (weight_in is None and region_in is None and failover_in is None and geo_location is None) and identifier_in is not None: module.fail_json(msg="You have specified identifier which makes sense only if you specify one of: weight, region, geo_location or failover.") retry_decorator = AWSRetry.jittered_backoff( diff --git a/tests/integration/targets/route53/tasks/main.yml b/tests/integration/targets/route53/tasks/main.yml index 063e279f1cf..62a82f44a31 100644 --- a/tests/integration/targets/route53/tasks/main.yml +++ b/tests/integration/targets/route53/tasks/main.yml @@ -635,6 +635,42 @@ - weighted_record is not failed - weighted_record is not changed + - name: 'Create a zero weighted record' + route53: + state: present + zone: '{{ zone_one }}' + record: 'zero_weighted.{{ zone_one }}' + type: CNAME + value: 'zid_test.{{ zone_one }}' + overwrite: True + identifier: "host1@www" + weight: 0 + region: '{{ omit }}' + register: weighted_record + - name: 'This should be changed' + assert: + that: + - weighted_record is not failed + - weighted_record is changed + + - name: 'Re-Create a zero weighted record' + route53: + state: present + zone: '{{ zone_one }}' + record: 'zero_weighted.{{ zone_one }}' + type: CNAME + value: 'zid_test.{{ zone_one }}' + overwrite: True + identifier: "host1@www" + weight: 0 + region: '{{ omit }}' + register: weighted_record + - name: 'This should not be changed' + assert: + that: + - weighted_record is not failed + - weighted_record is not changed + #Test Geo Location - Continent Code - name: Create a record with geo_location - continent_code (check_mode) route53: