xoanmi / ansible-module-infoblox

Awesome infobox module for ansible
GNU General Public License v3.0
38 stars 25 forks source link

Fail after unexpected value returned from set a record operation #46

Open jmtcsngr opened 6 years ago

jmtcsngr commented 6 years ago

I'm trying to use the module as part of a playbook. I get a strange fail. From the result of the operation and reading the code I think the issue is with infoblox. The record is properly created but as part of the last checks the result fails to pass the _are_records_equivalent assertion.

"invocation": {
        "module_args": {
            "action": "set_a_record",
            "address": "192.0.2.1",
            "addresses": null,
            "alias": null,
            "api_version": "2.3.1",
            "attr_name": null,
            "attr_value": null,
            "canonical": null,
            "cidr": null,
            "cname": null,
            "comment": "Object managed by ansible-infoblox module",
            "current": null,
            "delegate_to": null,
            "dns_view": "internal",
            "end_addr": null,
            "extattrs": null,
            "filters": null,
            "fqdn": null,
            "host": null,
            "name": "instance.domain.com",
            "net_view": "default",
            "network": null,
            "object_ref": null,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "roundrobin": false,
            "server": "infoblox-gm.domain.com",
            "srv_attr": null,
            "start_addr": null,
            "ttl": null,
            "txt": null,
            "username": "admin"
        }
    },
    "result": [
        {
            "_ref": "record:a/ZG...3LjE4LjIxMQ:instance.domain.com/internal",
            "comment": "Object managed by ansible-infoblox module",
            "extattrs": {},
            "ipv4addr": "192.0.2.1",
            "name": "instance.domain.com",
            "use_ttl": false,
            "view": "internal"
        }
    ]

So, as I understand the result and any further queries to the API will return an empty object for extattrs. Which causes the original data not to match the result object. This is likely just an artifact of the current version/build of infoblox I'm working with.

I tested by blacklisting extattrs from elements checked as part of _are_records_equivalent

ignore_properties = [_ID_PROPERTY, _EXT_ATTR_PROPERTY] # ~ line 1580

and things started working without problems. I'm assuming this change may brake some current functionality. So not sure I should create a PR with this. The other option I can think is change behaviour of _are_records_equivalent so it considers extattrs: {} and extattrs: None as equivalent.