Repository: ansible-collections/community.aws

Issue:
Route53 module no longer supports 0 weights
### Summary

When trying to create a Route53 DNS record with a weight of 0, I receive the error:

    "You have specified identifier which makes sense only if you specify one of: weight, region, geo_location or failover."

This appears to have been caused by this commit:

https://github.com/ansible-collections/community.aws/commit/59f06ed666a5f97adb5f75e086fad0660c49f35f#diff-39a0039c8f787ef918e13c9e34de717b42890a4baada9448cd80a76242bffee4L570-R632

this is changing the weight comparison from `weight_in is None` to `not any([weight_in...`.
A weight of zero returns false to the first comparison, but true to the latter.

### Issue Type

Bug Report

### Component Name

route53

### Ansible Version

```console (paste below)
ansible [core 2.13.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/centos/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/site-packages/ansible
  ansible collection location = /home/centos/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.8.13 (default, Jul 26 2022, 16:15:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
  jinja version = 3.1.2
  libyaml = True
```


### Collection Versions

```console (paste below)
Collection                    Version
----------------------------- -------
amazon.aws                    3.3.1
ansible.netcommon             3.0.1
ansible.posix                 1.4.0
ansible.utils                 2.6.1
ansible.windows               1.10.0
arista.eos                    5.0.1
awx.awx                       21.2.0
azure.azcollection            1.13.0
check_point.mgmt              2.3.0
chocolatey.chocolatey         1.3.0
cisco.aci                     2.2.0
cisco.asa                     3.1.0
cisco.dnac                    6.5.0
cisco.intersight              1.0.19
cisco.ios                     3.2.0
cisco.iosxr                   3.2.0
cisco.ise                     2.5.0
cisco.meraki                  2.10.0
cisco.mso                     2.0.0
cisco.nso                     1.0.3
cisco.nxos                    3.1.0
cisco.ucs                     1.8.0
cloud.common                  2.1.2
cloudscale_ch.cloud           2.2.2
community.aws                 3.4.0
community.azure               1.1.0
community.ciscosmb            1.0.5
community.crypto              2.4.0
community.digitalocean        1.21.0
community.dns                 2.2.1
community.docker              2.7.0
community.fortios             1.0.0
community.general             5.3.0
community.google              1.0.0
community.grafana             1.5.0
community.hashi_vault         3.0.0
community.hrobot              1.4.0
community.libvirt             1.1.0
community.mongodb             1.4.1
community.mysql               3.3.0
community.network             4.0.1
community.okd                 2.2.0
community.postgresql          2.1.5
community.proxysql            1.4.0
community.rabbitmq            1.2.1
community.routeros            2.1.0
community.sap                 1.0.0
community.sap_libs            1.1.0
community.skydive             1.0.0
community.sops                1.2.3
community.vmware              2.7.0
community.windows             1.10.0
community.zabbix              1.7.0
containers.podman             1.9.4
cyberark.conjur               1.1.0
cyberark.pas                  1.0.14
dellemc.enterprise_sonic      1.1.1
dellemc.openmanage            5.5.0
dellemc.os10                  1.1.1
dellemc.os6                   1.0.7
dellemc.os9                   1.0.4
f5networks.f5_modules         1.18.0
fortinet.fortimanager         2.1.5
fortinet.fortios              2.1.6
frr.frr                       2.0.0
gluster.gluster               1.0.2
google.cloud                  1.0.2
hetzner.hcloud                1.8.1
hpe.nimble                    1.1.4
ibm.qradar                    2.0.0
infinidat.infinibox           1.3.3
infoblox.nios_modules         1.3.0
inspur.sm                     2.0.0
junipernetworks.junos         3.1.0
kubernetes.core               2.3.2
mellanox.onyx                 1.0.0
netapp.aws                    21.7.0
netapp.azure                  21.10.0
netapp.cloudmanager           21.18.0
netapp.elementsw              21.7.0
netapp.ontap                  21.20.0
netapp.storagegrid            21.10.0
netapp.um_info                21.8.0
netapp_eseries.santricity     1.3.0
netbox.netbox                 3.7.1
ngine_io.cloudstack           2.2.4
ngine_io.exoscale             1.0.0
ngine_io.vultr                1.1.2
openstack.cloud               1.8.0
openvswitch.openvswitch       2.1.0
ovirt.ovirt                   2.1.0
purestorage.flasharray        1.13.0
purestorage.flashblade        1.9.0
purestorage.fusion            1.0.2
sensu.sensu_go                1.13.1
servicenow.servicenow         1.0.6
splunk.es                     2.0.0
t_systems_mms.icinga_director 1.30.0
theforeman.foreman            3.4.0
vmware.vmware_rest            2.2.0
vyos.vyos                     3.0.1
wti.remote                    1.0.4
```


### AWS SDK versions

```console (paste below)
Name: boto
Version: 2.49.0
Summary: Amazon Web Services Library
Home-page: https://github.com/boto/boto/
Author: Mitch Garnaat
Author-email: mitch@garnaat.com
License: MIT
Location: /usr/local/lib/python3.8/site-packages
Requires:
Required-by:
---
Name: boto3
Version: 1.24.37
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email:
License: Apache License 2.0
Location: /usr/local/lib/python3.8/site-packages
Requires: botocore, jmespath, s3transfer
Required-by:
---
Name: botocore
Version: 1.27.37
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email:
License: Apache License 2.0
Location: /usr/local/lib/python3.8/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: awscli, boto3, s3transfer
```


### Configuration

```console (paste below)
[DEPRECATION WARNING]: [defaults]callback_whitelist option, normalizing names to new standard, use callbacks_enabled instead.
This feature will be removed from ansible-core in version 2.15. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
CALLBACKS_ENABLED(/etc/ansible/ansible.cfg) = ['profile_tasks']
DEFAULT_GATHERING(/etc/ansible/ansible.cfg) = smart
DEFAULT_GATHER_TIMEOUT(/etc/ansible/ansible.cfg) = 60
DEFAULT_HASH_BEHAVIOUR(/etc/ansible/ansible.cfg) = merge
```


### OS / Environment

CentOS 7 and Mac OS 12.5

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->
```yaml
- 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
```


### Expected Results

I expect the DNS record to be created with a weight of zero.

### Actual Results

```console (paste below)
TASK [Set 0 weight for old env] ***********************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "You have specified identifier which makes sense only if you specify one of: weight, region, geo_location or failover."}
```


### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
* [`plugins/modules/route53.py`](https://github.com/['ansible-collections/amazon.aws', 'ansible-collections/community.aws', 'ansible-collections/community.vmware']/blob/main/plugins/modules/route53.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @jillr @jimbydamonk @markuman @s-hertel @tremble
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->

Resolving patch:
diff --git a/plugins/modules/route53.py b/plugins/modules/route53.py
--- 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(


Test patch:
diff --git a/tests/integration/targets/route53/tasks/main.yml b/tests/integration/targets/route53/tasks/main.yml
--- 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: