REST API - Get members of host group

Dear CheckMK community,

We use the CheckMK REST API to populate our ansible playbook inventory to manage our linux based servers.
I have just implemented a way to synchronize all SSH keys on all linux servers with the CheckMK REST API.

Now I do still have a problem: This only works for calling single hosts, not groups of hosts.
Seeing as there are hostgroups in CheckMK, I wanted to get all members of a hostgroup from the API.

In the CheckMK REST API Interactive GUI in the Hostgroups Table declaration, it lists the variable members (list) with the information A list of all host names that are members of the hostgroup.

When accessing the API on the corresponding endpoints, the members attribute is always empty?

  • /objects/host_group_config/GROUPNAME returns infos on group (links, id, title, alias) and an empty members list
  • /domain-types/host_group_config/collections/all returns a list of the same information about all groups, empty members included
  • /objects/host_config/HOSTNAME returns infos on a host but no info on group membership

While searching the forum, I also found this thread talking about getting this info is not possible?

Now I’m just a little confused and I’d like clarification.
Is it possible to get the members of a group or some kind of group-membership information in the REST API or is it not?
It shouldn’t be a permission issue or something alike if I can see the host-members of a group in the Host Groups view in CheckMK, right?

Best regards,
pixelpoint

1 Like

So, I did not find a way to get group memberships via CheckMK REST API default capabilities.
What I did to solve the situation is:

  • Added custom host attributes
  • Use custom host attributes to create ansible groups based upon them

E.g.:
All hosts where the CheckMK tag tag_backup-software has the value proxmox_backup_client will be sorted in the Ansible Inventory Group proxmox_backup_client.

I would have liked it more if I could just use the already existing groups in CheckMK, but this works just as well as a workaround.