Skip to content

Commit

Permalink
route53: Restore support for zero weighted DNS records (ansible-colle…
Browse files Browse the repository at this point in the history
…ctions#1379)

route53: Restore support for zero weighted DNS records

SUMMARY
In ansible-collections#1117 (comment) and https://github.com/ansible-collections/community.aws/pull/1117/files#r869391659 this line was recommended to be simplified, but not any will also return true if weight_in has a value of 0, not only when it is None
Fixes ansible-collections#1378
ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
route53
ADDITIONAL INFORMATION


Previously it was possible to create weighted records with a weight of 0. Currently the playbook below returns the error:
You have specified identifier which makes sense only if you specify one of: weight, region, geo_location or failover.


- name: Bug demo
  hosts: localhost
  tasks:
    - name: Set 0 weight for old env
      route53:
        wait: yes
        ttl: '5'
        type: 'CNAME'
        identifier: old
        overwrite: yes
        record: 'record.example.com.'
        zone: 'example.com.'
        value: 'record-old.example.com.'
        weight: '0'
        state: present

Reviewed-by: Mark Chappell <None>
  • Loading branch information
wp-davisona authored and abikouo committed Sep 18, 2023
1 parent 263e2d4 commit 5a505b3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion route53.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 5a505b3

Please sign in to comment.