I have this simple ansible playbook to install the CheckMK agent on linux hosts, create the host in CheckMK and register automatically. It works all fine, but existing hosts are moved to the root folder.
I usually just move the hosts in CheckMK directly as the environment is very heterogenic.
Is there a way around this except defining the folder path in the ansible inventory?
Ansible is a desired state configuration tool, so it ensures a certain state.
When using the agent role, it passes on a folder to the host module when the host is added to Checkmk. As it needs a folder to put the host in, this is not optional.
What you can do is this: Run the agent role only with the variable checkmk_agent_add_host: true once and set the variable to false for all subsequent runs. That way the role will not touch the host object in Checkmk anymore.
Or manage the folder with Checkmk entirely. Your choice.
Interestingly this also seems to cause some problems when specifying host attributes (alias in my case):
4:22:31 PM
TASK [checkmk.general.agent : Linux: Create host on server.] *******************
4:22:34 PM
fatal: [hostname.example.com -> localhost]: FAILED! => {"changed": false, "failed_when_result": true, "msg": "ERROR: The folder parameter is different from the folder in which the host is located, while other parameters are also specified!\n If you want to move the host to a specific folder, please omit the other parameters: 'attributes', 'update_attributes' and 'remove_attributes'."}
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.