ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
814 stars 1.49k forks source link

udm_dns_record report a change where there is no change #317

Open tabacha opened 4 years ago

tabacha commented 4 years ago
SUMMARY

If you try to set a ipv6 host_record with an shortend IPv6 adddress the udm_dns_record it will always report a change.

ISSUE TYPE
COMPONENT NAME

plugins/modules/cloud/univention/udm_dns_record.py

ANSIBLE VERSION
2.9.6
CONFIGURATION
DEFAULT_HOST_LIST(/home/sven/.ansible.cfg) = ['/home/sven/src/anders-ansible/inventory.yml']
DEFAULT_REMOTE_USER(/home/sven/.ansible.cfg) = root
OS / ENVIRONMENT

Debian 10

STEPS TO REPRODUCE
   - name: set record
      udm_dns_record:
        name: vb01.meet
        zone: adfc-intern.de
        type: host_record
        data:
          a: 2001:0db8::42

Plese note: if you change: 2001:0db8 :: 42 to 2001:0db8:0000:0000:0000:0000:0000:0042 no change will be reported.

EXPECTED RESULTS

If you call this task twice, there should be no change reported by ansible

ACTUAL RESULTS

Change will be reported, every time.

ansibullbot commented 4 years ago

Files identified in the description:

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

ansibullbot commented 4 years ago

cc @keachi click here for bot help

russoz commented 3 years ago

hi @tabacha thanks for reporting this (quite a while ago!).

I took a quick glance at the code, and it seems that in both cases:

This is coming straight from the univention python library. When running a state=present on an existing value, there is this obj object, and everything happen within it: https://github.com/ansible-collections/community.general/blob/main/plugins/modules/cloud/univention/udm_dns_record.py#L196-L207

However, that object comes from: https://github.com/ansible-collections/community.general/blob/main/plugins/module_utils/univention_umc.py#L227 which by its turn comes from: https://github.com/ansible-collections/community.general/blob/main/plugins/module_utils/univention_umc.py#L193

So, I would suggest:

  1. Testing this again with updated versions of both this collection and the univention library
  2. In case the problem still happens, then reporting to the maintainers at Univention itself. I could not find that library in PyPI, but I've found their documentation page: https://docs.software-univention.de/developer-reference-5.0.html

We'll be happy to keep this ticket open until the issue is solved, but this does not look like something that will be solved here without adding an extra layer of complexity in the module, which is undesirable.

Cheers

tabacha commented 3 years ago

Hi I have updaded ansible via pip3 as root

pip3 list |grep ansible
ansible                  4.5.0
ansible-core             2.11.5

and installed community.general witth

ansible-galaxy collection install community.general

( community.general:3.6.0)

The bug exists, see example playbook and output, attached to the issue test-playbook-and-output.zip

tabacha commented 3 years ago

I have looked in the code I think the problem is located here:

https://github.com/ansible-collections/community.general/blob/main/plugins/modules/cloud/univention/udm_dns_record.py#L207

The univention library is not calculating any changes/diff. This is done by the communtiy.gerneral collection.

tabacha commented 3 years ago

I have looked in the code I think the problem is located here:

https://github.com/ansible-collections/community.general/blob/main/plugins/modules/cloud/univention/udm_dns_record.py#L207

The univention library is not calculating any changes/diff. This is done by the communtiy.gerneral collection.

I wrote bullshit. The code for the diff is here: https://github.com/univention/univention-corporate-server/blob/5.0-0/management/univention-directory-manager-modules/modules/univention/admin/handlers/__init__.py#L253

tabacha commented 3 years ago

See also: https://help.univention.com/t/error-in-python-lib-ansible-package-python-univenton-directory-manager/18586

felixfontein commented 3 years ago

Probably fixing that requires to normalize IP addresses when comparing. Using the ipaddress library for this (part of the standard Python library since Python 3.3, and backports available on Pypi for Python 2) is probably the best solution. From what you wrote, this needs to be fixed on Univention's side though.

ansibullbot commented 1 year ago

Files identified in the description:

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

click here for bot help