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

os_recordset module: Unable to have both A and AAAA records #19572

Closed
precurse opened this issue Dec 20, 2016 · 3 comments · Fixed by #19588
Closed

os_recordset module: Unable to have both A and AAAA records #19572

precurse opened this issue Dec 20, 2016 · 3 comments · Fixed by #19588
Assignees
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. openstack support:community This issue/PR relates to code supported by the Ansible community.

Comments

@precurse
Copy link
Contributor

precurse commented Dec 20, 2016

ISSUE TYPE
  • Bug Report
COMPONENT NAME

modules-extra / cloud / openstack / os_recordset

ANSIBLE VERSION
$ ansible --version
ansible 2.2.0.0
  config file = /home/ubuntu/work/playbooks/ansible.cfg
  configured module search path = Default w/o overrides

CONFIGURATION
[defaults]
inventory=inventory/openstack.py

[ssh_connection]
pipelining=False
OS / ENVIRONMENT

Ubuntu 16.04. The task uses delegate_to: localhost

SUMMARY

It seems the os_recordset module is unable to create domain records with both A and AAAA records if they both have the same name. This isn't uncommon in IPv4 and IPv6 deployments. I should be able to create both A and AAAA records for the same name.

STEPS TO REPRODUCE
- hosts: testhost
  tasks:
    - name: Setting up testhost IPv4
      delegate_to: localhost
      os_recordset:
        cloud: dev
        state: present
        zone: "example.com."
        name: "www"
        recordset_type: A
        records: "{{ openstack.accessIPv4 }}"
        ttl: 3600
    - name: Setting up testhost IPv6
      delegate_to: localhost
      os_recordset:
        cloud: dev
        state: present
        zone: "example.com."
        name: "www"
        recordset_type: AAAA
        records: "{{ openstack.accessIPv6 }}"
        ttl: 3600
EXPECTED RESULTS

I would expect both A and AAAA records to be created without error.

ACTUAL RESULTS

Creating A/AAAA record and both an A and AAAA records already exist in OpenStack:

TASK [Setting up testhost IPv4] ************************************************
fatal: [www.example.com -> localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Unable to create recordset www (Inner Exception: Duplicate RecordSet)"}

Creating A record and only an AAAA record already exists in OpenStack:

TASK [Setting up testhost IPv4] ************************************************
fatal: [www.example.com -> localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Error updating recordset www.example.com. (Inner Exception: u'10.0.0.1' is not a 'ipv6')"}

Verbose on:

fatal: [www.example.com -> localhost]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "invocation": {
        "module_args": {
            "api_timeout": null, 
            "auth": null, 
            "auth_type": null, 
            "availability_zone": null, 
            "cacert": null, 
            "cert": null, 
            "cloud": "dev", 
            "description": null, 
            "endpoint_type": "public", 
            "key": null, 
            "name": "www", 
            "records": [
                "10.0.0.1"
            ], 
            "recordset_type": "A", 
            "region_name": null, 
            "state": "present", 
            "timeout": 180, 
            "ttl": 3600, 
            "verify": true, 
            "wait": true, 
            "zone": "example.com."
        }, 
        "module_name": "os_recordset"
    }, 
    "msg": "Error updating recordset www.example.com. (Inner Exception: u'10.0.0.1' is not a 'ipv6')"
}

Creating an AAAA record and an A record already exists in OpenStack

    "msg": "Error updating recordset www.example.com. (Inner Exception: u'<ipv6 address removed>' is not a 'ipv4')"

@precurse
Copy link
Contributor Author

From the feel of the bug, if an A record already exists and I go to add an AAAA record using Ansible it tries to update the existing A record with an IPv6 address which will obviously fail (and vice versa).

@ansibot
Copy link
Contributor

ansibot commented Dec 20, 2016

@ansibot ansibot added affects_2.2 This issue/PR affects Ansible v2.2 bug_report cloud module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. openstack labels Dec 20, 2016
@precurse
Copy link
Contributor Author

precurse commented Dec 20, 2016

So it looks like the module was never designed for multiple records with the same name.. I imagine it will fail if MX, TXT, etc. also exist for a single named record as seen here:
https://github.com/ansible/ansible/blame/devel/lib/ansible/modules/cloud/openstack/os_recordset.py#L188

It explodes if an A + AAAA record exist with the (Inner Exception: Duplicate RecordSet) error above.

After it pulls back recordset with get_recordset, it doesn't actually check the recordset['type'] value to see if it matches with what's being returned.. Which explains the other errors above like trying to update an AAAA record type with an IPv4 address or A record with IPv6 address.

@gundalow gundalow removed the needs_triage Needs a first human triage before being processed. label Jan 4, 2017
@jimi-c jimi-c removed the plugin label Jan 4, 2017
@ansibot ansibot added the support:community This issue/PR relates to code supported by the Ansible community. label Jun 29, 2017
bcoca pushed a commit that referenced this issue Aug 16, 2017
* Fix for os_recordset.py to filter based on record type. Fixes #19572

* remove redundant variable

* Needing to use recordset ID to update and delete records. Using the record name for update/delete causes issues when A and AAAA records exist for a name

* Adding exception handling for dictionary item
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.2 This issue/PR affects Ansible v2.2 bug This issue/PR relates to a bug. cloud module This issue/PR relates to a module. openstack support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants