Hierarchy question regarding environments hostgroups and classes

I am encountering an environment hierarchy problem that I cannot seem to solve with what Foreman offers as a part of organizing hosts, environments and the respective puppet classes. For instance, for a given organization and location, I have multiple environments created: prod, stage, dev. I have multiple branches of Puppet modules that is respective to each environment. I make commits and pull down dev branch modules and classes for dev environment servers that are only applied to dev hosts, or perhaps another branch and environment. However, when I get to the hostgroup level organization, things starts to break down. I want to organize my hostgroups by type, such as ‘linux servers’, ‘linux servers/web servers’, ‘linux servers/mysql servers’. However, hostgroups requires you to assign an environment, otherwise you do not get to see the Puppet module classes available for that environment for further parameter customization. This seems to suggest I need to have a duplicate hostgroup for each environment even though they may have the exact same parameters. Am I doing something wrong here?

Hi,

you are not doing anything wrong here. This is in fact a current limitation that you have to find a solution to “work around” based on your needs.
Here at our site, we have a hostgroup setup like this:

  • RHEL servers
  • RHEL servers/webservers
  • RHEL servers/webservers/dev
  • RHEL servers/webservers/testing
  • RHEL servers/webservers/production

At least for our specific needs, this has proven to be the best solution for this problem. There has been some discussion around rethinking hostgroups (see here), but I do not know if there is anything currently in the making based on that.