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

[BUG] Since version 2.1.0p5 modules not working anymore #78

Closed
elwood218 opened this issue Jul 11, 2022 · 7 comments
Closed

[BUG] Since version 2.1.0p5 modules not working anymore #78

elwood218 opened this issue Jul 11, 2022 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@elwood218
Copy link

Describe the bug

Folders cannot be created because of changes in the API since 2.1.0p5

fatal: [Host1 -> localhost]: FAILED! => changed=false
  msg: 'Error calling API. HTTP code 400. Details: b''{"title": "Bad Request", "status": 400, "detail": "These fields have problems: parent", "fields": {"parent": ["The folder \''/blub/blub/bla\'' could not be found."]}}'', '

Component Name

folder, maybe also host

Ansible Version

$ ansible --version
ansible [core 2.12.5]

Checkmk Version

2.1.0p5 (CEE) and 2.1.0p6

Collection Version

$ ansible-galaxy collection list
tribe29.checkmk               0.5.0

Environment

To Reproduce
Steps to reproduce the behavior:

- name: "Create site folder"
  tribe29.checkmk.folder:
    server_url: "https://{{ cmk_central }}/"
    site: "{{ cmk_central_site }}"
    automation_user: "{{ cmk_site_user }}"
    automation_secret: "{{ cmk_site_password }}"
    attributes:
      labels:
        test: "test123"
    path: "/BLUB/blub/BLA/FOO"
    title: "Foo"
    state: "present"
  run_once: true
  delegate_to: localhost
  become: no
  notify:
    - activate changes

Expected behavior

Actual behavior

Screenshots

Additional context

Please remove the .lower() in following line on folder.py. Please also check host.py.

ba36a79b (Lars Getwan    2022-03-11 14:29:03 +0100 125)     return str(p.parent).lower(), p.name
@elwood218 elwood218 added the bug Something isn't working label Jul 11, 2022
@kain88-de
Copy link
Contributor

Sure this only happens since p5? I did change the path handling in p4. I also just checked the tests I added and found that I generate paths in a loop. So to get "/Blub/Baa" I first create "/Blub" and then "/Blub/Baa". The error also says that the REST API only wants to create the last folder given. Or in other words. This behaves like mkdir and not mkdir -p. So my assumption is this has happened before.

@elwood218
Copy link
Author

Yea I have tested it with p4 and there it worked. And yes it creates like „mkdir“ because „mkdir -p“ was not working in the beginning.. but I don’t understand what this has to do with the problem?!

@kain88-de
Copy link
Contributor

The error message you have written says that the parent folder /blub/blub/bla does not exist. Since the rest endpoint does not create parent folders this message is expected. We can fix this in the rest api or let the ansible module deal with that.

@elwood218
Copy link
Author

Ok.. I have copied the module and fixed it locally by myself anyway. So just take it as notice and do what you think is ok..

The parent folder is already existing and its folder ID (not title!) is: ~BLUB~blub~BLA
The module does a .lower() and then the the ID of the folder is like in the output and it searches for the id ~bla~blub~bla and does not find it.

The .lower() is since march in the module so anything real strange was done by the API which did not throw this error and it was working like expected and folders got created. But since p5 ist was not working anymore and I debugged it several hours before I created this issue.

@elwood218
Copy link
Author

Btw.. and just fyi - I also fixed the host module which was not working anymore. The API Maybe was sending not the first / before and now it does.. so to fix the host module just remove the slash which is set by the module:

OLD:

current_folder = "/%s" % extensions.get("folder", "")

NEW:

current_folder = "%s" % extensions.get("folder", "")

@robin-checkmk
Copy link
Member

@elwood218 your issue should be fixed with #147. It will be included in version 0.9.0 which will be released today.
Can you verify that the fix works for you too and close this issue if so?

@robin-checkmk
Copy link
Member

Closing this due to staleness, as there is another fix in 993b4ce.

If there is anything else, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants