Checkmk goes Ansible - handling of uppercase and lowercase names in folders

CMK version:
2.2.0p33
Ansible v5.2.1 from galaxy
OS version:
Virt 1 6.5
Error message:
"These fields have problems: parent", "fields": {"parent": ["The folder \‘/local_monitoring/de\’ could not be found."]}}'"}

We are currently testing checkmk ansible. Unfortunately we ran into an issue with creating folders. We use the following standardized folder structure:

/local_monitoring/{{countrycode}}/{{sitecode}}

countrycode is the 2 letter ANSI code in upper case like DE
sitecode is a 3 letter code specific to a site in upper case AUG

Finally that ends in the OS folder:

./local_monitoring/DE/AUG

I can setup this exactly via REST API and get the above described folders on OS level.
Doing this with Ansible fails with following error:

\"These fields have problems: parent\", \"fields\": {\"parent\": [\"The folder \\'/local_monitoring/de\\' could not be found.\"]}}'"}

The country folder is created uppercase but even if I use
path: "/local_monitoring/DE/{{sitecode}}"
it fails because it tries to access the folder in lower case.

`
OMD[rest]:~/etc/check_mk/conf.d/wato$ tree
.
├── contacts.mk
├── global.mk
├── groups.mk
├── hosts.mk
├── hosts.pkl
├── local_monitoring
│ └── DE
├── notifications.mk
├── rules.mk
└── tags.mk

`
@sekania I see that you made some modifications according to this. Can you comment please

The web based setup always lowercases folder names and tries to convert the folder title to ASCII.

This looks like the API tries to do it, too.

AFAIK folder names should always be lower case. You can set the title to uppercase letters.

1 Like

Neither in the legacy web api nor in the new REST api this is the case.
We only create folders via the api, so folders are uppercase:

`-- local_monitoring
    |-- AE
    |-- AR
    |   |-- COR
    |   |   |-- DATACENTER
    |   |   |-- EXOTIC
    |   |   |-- INDUSTRIAL
    |   |   |-- NETWORK
    |   |   |-- PRINTERS
    |   |   |-- SERVER
    |   |   `-- STORAGE
    |   |-- LNS
    |   |   |-- DATACENTER
    |   |   |-- EXOTIC
    |   |   |-- INDUSTRIAL
    |   |   |-- NETWORK
    |   |   |-- PRINTERS
    |   |   |-- SERVER
    |   |   `-- STORAGE
    |   |-- MAL
    |   |   |-- DATACENTER
    |   |   |-- EXOTIC
    |   |   |-- INDUSTRIAL
    |   |   |-- NETWORK
    |   |   |-- PRINTERS
    |   |   |-- SERVER
    |   |   `-- STORAGE
    |   `-- PLR
    |       |-- DATACENTER
    |       |-- EXOTIC
    |       |-- INDUSTRIAL
    |       |-- NETWORK
    |       |-- PRINTERS
    |       |-- SERVER
    |       `-- STORAGE
    |-- AT
    |   `-- KNB
    |       |-- DATACENTER
    |       |-- EXOTIC
    |       |-- INDUSTRIAL
    |       |-- NETWORK
    |       |-- PRINTERS
    |       |-- SERVER
    |       `-- STORAGE
    |-- BE
    |   `-- GNE
    |       |-- DATACENTER
    |       |-- EXOTIC
    |       |-- INDUSTRIAL
    |       |-- NETWORK
    |       |-- PRINTERS
    |       |-- SERVER
    |       `-- STORAGE

just a quick answer,

if one creates folders with folder names all in lowercase

/local_monitoring/

/local_monitoring/{{ countrycode.lower() }}

/local_monitoring/{{ countrycode.lower() }}/{{ sitecode.lower() }}

then everything should be fine.

Titles can contain the uppercase letters.

Could you please report the issue directly to GitHub - Checkmk/ansible-collection-checkmk.general: The official Checkmk Ansible collection - brought to you by the Checkmk company.

1 Like

IIRC, we made a conscious decision to force lowercase folder paths.
It is not good practice to mix upper- and lowercase, but even if one sticks to uppercase, there is a risk of seemingly duplicate folder names.

We might re-evaluate that decision, given demand for it.

1 Like

For a new environment that might be a solution but we started with checkmk 1.4.0 and we have already thousands of folders in uppercase. I am not sure if its fully save to rename them all to lower case.

Even so the behavior of Ansible code isnt consistent because you can create the folder in uppercase but you cannot access the folder because the path is forced to be in lowercase.
As said, in legacy API and in REST API this isnt the case. So if checkmk makes the decision that folders on OS level must be in lowercase it has to be the case in ALL interfaces, not only GUI Setup and part of Ansible.

I can understand the confusion if you are coming from Windows world but if you coming from *NIX world the logic in Windows isnt consistent. A != a :wink:

Will do right away

Thanks for all your work you spent on Ansible checkmk code.

regards

Mike

1 Like

Here is the issue for everyone reading along.

I hear what you are saying and I will take the feedback with me. I cannot make any promises, but of course we strive for the best possible user experience.

That is exactly what we wanted to avoid with the collection. :slight_smile:

:heart:

Freedom is the best experience ever :wink:

I did the same decision in the cmdbsycner to have the internal names lowercase, and when you want to see it in uppercase it’s done via the title attribute. I would also not want to see uppercase folder names for automations on Linux because, like stated: Folder de != Folder DE. Specially if the source for the data is User Input.

2 Likes

All these comments are not helpful as we have already thousands of folders in uppercase and I dont want to take the risk to rename them.

Thank you for your understanding.

Mike

I made another test which renders the discussion abut the naming of the folder on OS level useless.

Following Siuation:

In Setup GUI we have following folder structure:

/local_monitring/DE/AUG/INDUSTRIAL

On OS level the folder structure would be the same:

~/etc/check_mk/conf.d/wato/local_monitoring/DE/AUG/INDUSTRIAL

Now, we rename the folder in Setup GUI to newname.

In Setup GUI we have now following folder structure:

/local_monitring/DE/AUG/newname

But on OS level we still have:

~/etc/check_mk/conf.d/wato/local_monitoring/DE/AUG/INDUSTRIAL

Thats because the name in GUIs managed by .wato file and is independent from real name on OS level:

OMD[rest]:~/etc/check_mk/conf.d/wato/local_monitoring/DE/AUG/INDUSTRIAL$ cat .wato
{'title': 'newname', 'attributes': {'meta_data': {'created_at': 1727356282.0, 'created_by': 'automation', 'updated_at': 1727419594.0648718}}, 'num_hosts': 0, 'lock': False, 'lock_subfolders': False, '__id': 'bf8ca414dd1342ad9ff24609f0226fa7'}

So anyway there is no link between OS and what we see in Setup regards the folder and I dont see a reason why to force it to be lowercase.
If one is using the REST API or even the ansible automation I would expect that this individual has some technical experience and is aware of the situation in IT that a!=A.

regards

Mike

The issue with folder path case has been resolved and released with collection version 5.3.0.

3 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.