univention / ansible-modules

Ansible Modules for UCS
GNU General Public License v3.0
11 stars 6 forks source link

univention_directory_manager: error handling existing objects #5

Closed fbim-genosr closed 1 year ago

fbim-genosr commented 2 years ago

Hi all,

when adding an object that already exists, let's say a user, or an OU,

- name: Organisationsstrukturen in UCS anlegen
        tags: ou
        univention.ucs_modules.univention_directory_manager:
          module: 'container/ou'
          state: 'present'
          position: 'dc=thing,dc=some,dc=domain'
          dn: 'dc=thing,dc=some,dc=domain'
          set_properties:
            - property: 'name'
              value: 'some'
.....

I get a trace back, telling me,

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: univention.udm.exceptions.CreateError: Error creating 'container/ou' object: Das Objekt existiert bereits. (ou=some,dc=thing,dc=some,dc=domain)

IMHO, the modules should be idempotent and just return "ok", in case an object already exists. Or am I mixing things up here?

Cheers Sebastian

zumvorde commented 1 year ago

You are right If the Object exists and no change has to be made, it should return no error but an ok with the informarion that nothing had to be done.

fbim-genosr commented 1 year ago

Thank you very much for your answer. Is there a workaround to handle that? I ended up using udm with the ansible command module, having the "--ignore_exists" option set.

zumvorde commented 1 year ago

I think that is already the right workaround for this issue.

fbim-genosr commented 1 year ago

IMHO is the problem here, that --ignore_exists will "eat" all potential errors as well, right?

HunterZeroSix commented 1 year ago

I close the issue.

Integration test is added for this purpose.

test(univention_directory_manager): add more checks

Feel free to reopen or create a new issue if the error occurs again.