Default hostgroup plugin configuration file syntax

Hey there just wondering if someone can show me the correct syntax for the yaml file default_hostgroup.yaml.

What i am wanting is very simple. no matter what machine joins foreman, i want it put in a foreman group “windowshosts/staff/newlaptops”. Currently if i do imaging with for instande MDT, puppet will be installed whcih registers it in foreman but the hostgroup will be blank. I want to set the default in those situations.

I think foreman doesnt let you set the “default” hostgroup , so i have to use this plugin.

I am maintaining an old foreman install. I was able to install the plugin i think, but this config file syntax doesnt make sense to me. Where am i supposed to put the string for the hostgroup? where it says “default”? after the colon in hostgroup?

---

:default_hostgroup:
:facts_map:
“Default”:
“hostname”: “.*”

if someone has a yaml file that is simple with a hostgroup in there maybe you can post the relevant section and it would help me understand where to put the string. thanks. THere are only two examples on the github page and neither seem to have the hostgroup that i can see. Unless “Default” is the hostgroup.

Default is the host group name (more precisely title), what’s nested under it are the rules that are checked. If all of them (int this example just one) is matching, the host is assigned to the Default hostgroup. Make sure you keep the indentation correct, in YAML the white spaces are significant. So it should be formatted like this:

---
:default_hostgroup:
  :facts_map:
    "Default":
      "hostname": ".*"

For the reference, the logic can be found here in the code. The rule can be based on any fact (e.g. hostname) the value is the reguar expression.

I thought that was the case and tested yesterday before i left. But it seems that its not so straightforward as the machine has no hostgroup this morning.

This does not work for instance. Hostgroup is just blank. The spacing may look bad here because of blockquote but the spacing is correct. I only took the default example and copied it in.

:default_hostgroup:
  :facts_map:
    "windowshosts/staff/newlaptops":
      "hostname": ".*"

Is there an error log i can check for this to see why it is failing?

Your configuration seems ok. However there is currently an open issue which affects Foreman 2.2 or higher which fits your problem description:

There is also a pull request available which should fix this problem (Add support for foreman 2.2.0 and the HostFactImporter by bruabetic · Pull Request #46 · theforeman/foreman_default_hostgroup · GitHub)

Oops, that fell of the radar completely, I’ll raise this on the maintainers call. I seem to have merge permissions but not release permissions, but I know someone who has :slight_smile:

No looks like we are on Version 1.19.0 so probably this isnt the same problem sadly. The foreman system is quite old and doesn’t really get updates. New bossman wants to migrate off to microsoft tools. I just have to get it to play nicely for now. Sad because it works, but new boss new rules right.

Could there be something wrong because i have to use slashes in the hostgroup? i know sometimes on linux they need to be escaped.

New release for Foreman 2.2+ was released today, it’s version 6.0.0. Once packaging PRs are in, it should appear in the repositories. I’ll also open a thread to find a new active maintainer for this plugin.

@foremanrox I’m sad to see you go. Foreman 1.19 is very old version. I can’t try to reproduce the issue locally since I don’t have such version. If it’s not a huge setup with many plugins, perhaps try first upgrading to 2.4. You should go version by version to avoid problems.