Repository: ansible/ansible-modules-core

Issue:
route53 module: overwrite set to yes but still fails
I have the following in my playbook:

``` yaml
- name: Set Up Route53 IPv4
  route53: >
      aws_access_key=""
      aws_secret_key=""
      command=create
      zone=domain.com
      record=site.domain.com
      type=A
      ttl=7200
      value={{ ansible_default_ipv4.address }}
      overwrite=yes
```

Yet it still fails if the record already exists:

```
Tried to create resource record set [name='site.domain.com.', type='A'] but it already exists
```

Please let me know if that's not how it was intended to use, otherwise it seems like a bug?
Thanks!

route53 module: overwrite set to yes but still fails
I have the following in my playbook:

``` yaml
- name: Set Up Route53 IPv4
  route53: >
      aws_access_key=""
      aws_secret_key=""
      command=create
      zone=domain.com
      record=site.domain.com
      type=A
      ttl=7200
      value={{ ansible_default_ipv4.address }}
      overwrite=yes
```

Yet it still fails if the record already exists:

```
Tried to create resource record set [name='site.domain.com.', type='A'] but it already exists
```

Please let me know if that's not how it was intended to use, otherwise it seems like a bug?
Thanks!



Discussion:
Can you test this again?  I can't reproduce this error.  What version of Ansible & boto are you running?

Happens to us as well. Also on A records.

Ansible 1.9.2
boto 2.36.0

Hi All,

I confirm that it fails when trying to update the existing DNS CNAME RR (module taken from devel version https://github.com/ansible/ansible-modules-core/commit/b6223ca729b0f4fb238eb30a31447c6a55fbca95).

CentOS Linux release 7.1.1503 (Core)
ansible-1.9.4-1.el7.noarch
ansible-tower-2.3.1-1.el7.centos.x86_64

```
- name: Create public DNS record {{ instance.name }}
  route53:
    region: "{{ aws_region }}"
    alias: no
    alias_hosted_zone_id: "{{ zone_id }}"
    command: create
    overwrite: yes
    private_zone: no
    record: "{{ instance.name }}.{{ route53_zone.name }}"
    ttl: 300
    type: CNAME
    value: "{{ instance_public_res.stdout_lines }}"
    zone: "{{ route53_zone.name }}"
  register: ec2_cname
  when: instance.ec2_state == 'present'
  tags: ec2
```

and it fails:

```
NOTIFIED: [ec2 | Create public DNS record {{ instance.name }}] ****************
<127.0.0.1> REMOTE_MODULE route53 type=CNAME command=create record=proj-test.aws.test.com. region=us-east-1 zone=aws.test.com. alias_hosted_zone_id=Z3KUJWRQRZK82Y
failed: [127.0.0.1] => {"failed": true}
msg: Tried to create resource record set [name='proj-test.aws.test.com.', type='CNAME'] but it already exists

FATAL: all hosts have already failed -- aborting
```

but works fine with the one from rpm package:

```
NOTIFIED: [ec2 | Create public DNS record {{ instance.name }}] ****************
<127.0.0.1> REMOTE_MODULE route53 type=CNAME command=create record=proj-test.aws.test.com. region=us-east-1 zone=aws.test.com. alias_hosted_zone_id=Z3KUJWRQRZK82Y
changed: [127.0.0.1] => {"changed": true}
```

Can you test this again?  I can't reproduce this error.  What version of Ansible & boto are you running?

Happens to us as well. Also on A records.

Ansible 1.9.2
boto 2.36.0

Hi All,

I confirm that it fails when trying to update the existing DNS CNAME RR (module taken from devel version https://github.com/ansible/ansible-modules-core/commit/b6223ca729b0f4fb238eb30a31447c6a55fbca95).

CentOS Linux release 7.1.1503 (Core)
ansible-1.9.4-1.el7.noarch
ansible-tower-2.3.1-1.el7.centos.x86_64

```
- name: Create public DNS record {{ instance.name }}
  route53:
    region: "{{ aws_region }}"
    alias: no
    alias_hosted_zone_id: "{{ zone_id }}"
    command: create
    overwrite: yes
    private_zone: no
    record: "{{ instance.name }}.{{ route53_zone.name }}"
    ttl: 300
    type: CNAME
    value: "{{ instance_public_res.stdout_lines }}"
    zone: "{{ route53_zone.name }}"
  register: ec2_cname
  when: instance.ec2_state == 'present'
  tags: ec2
```

and it fails:

```
NOTIFIED: [ec2 | Create public DNS record {{ instance.name }}] ****************
<127.0.0.1> REMOTE_MODULE route53 type=CNAME command=create record=proj-test.aws.test.com. region=us-east-1 zone=aws.test.com. alias_hosted_zone_id=Z3KUJWRQRZK82Y
failed: [127.0.0.1] => {"failed": true}
msg: Tried to create resource record set [name='proj-test.aws.test.com.', type='CNAME'] but it already exists

FATAL: all hosts have already failed -- aborting
```

but works fine with the one from rpm package:

```
NOTIFIED: [ec2 | Create public DNS record {{ instance.name }}] ****************
<127.0.0.1> REMOTE_MODULE route53 type=CNAME command=create record=proj-test.aws.test.com. region=us-east-1 zone=aws.test.com. alias_hosted_zone_id=Z3KUJWRQRZK82Y
changed: [127.0.0.1] => {"changed": true}
```


Resolving patch:
diff --git a/cloud/amazon/route53.py b/cloud/amazon/route53.py
--- a/cloud/amazon/route53.py
+++ b/cloud/amazon/route53.py
@@ -295,7 +295,7 @@ def main():
             overwrite            = dict(required=False, type='bool'),
             retry_interval       = dict(required=False, default=500),
             private_zone         = dict(required=False, type='bool', default=False),
-            identifier           = dict(required=False),
+            identifier           = dict(required=False, default=None),
             weight               = dict(required=False, type='int'),
             region               = dict(required=False),
             health_check         = dict(required=False),
@@ -391,7 +391,7 @@ def main():
         #Need to save this changes in rset, because of comparing rset.to_xml() == wanted_rset.to_xml() in next block
 	rset.name = decoded_name
 
-        if rset.type == type_in and decoded_name.lower() == record_in.lower() and rset.identifier == str(identifier_in):
+        if rset.type == type_in and decoded_name.lower() == record_in.lower() and str(rset.identifier) == str(identifier_in):
             found_record = True
             record['zone'] = zone_in
             record['type'] = rset.type


Test patch: