This is with Puppet 5.5.22 and Foreman 1.22.0-develop. I know this is an outdated Foreman and Puppet installation but until I replace them with new versions (a soon upcoming project) they are what I must deal with.
# puppet agent -tv
Notice: Local environment: 'production' doesn't match server specified node environment 'development', switching agent to 'development'.
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Notice: Local environment: 'development' doesn't match server specified environment 'test', restarting agent run with environment 'test'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for servername.example.com
Info: Applying configuration version '1694623566'
Notice: Applied catalog in 12.93 seconds
I understand that the original local environment 'production' can come either from /etc/puppet/puppet.conf or is the default if no environment specified in that file. In this case it's the latter (no environment specified locally).
The node environment 'development' was set for this host in Foreman (the ENC or external node classifier for this Puppet installation) and is the desired correct environment assignment.
The environment 'test' is the environment that Foreman is setting, broadly and generally, for all of our hosts at this time and is the environment that this particular host was on before I changed it through the Foreman UI to be 'development.' (In other words, 'test' is actually our production environment; the environment called 'production' is not in use at this time.)
I tried consulting the Foreman documentation and didn't find anything about the underpinnings of how environment assignments work; the documentation just amounted to a tour of the UI which is not helpful for troubleshooting.
Likely related, there is another oddity here in that servername.example.com appears twice in Foreman's UI.
Power | Name | Operating system | Puppet Environment | Model | Host group | Last report | Actions |
---|---|---|---|---|---|---|---|
[spinning wheel] | servername | Debian [version] | development | [bladeservername] | hostgroupname | [blank] | [Edit button] |
[power icon, gray] | servername | Debian [version] | test | Standard PC [version info] | [blank] | 6 minutes ago | [Edit button] |
If I try to edit the environment for either entry by clicking the "Edit" button, when I then click "Submit" I get "has already been taken" showing in red next to the "Name" field as though I were trying to create a new host entry.
However if I instead select the host with the checkbox to the left from the list view and then go to the top and choose "Select Action" -> "Change Environment", then it appears to work. Both the entries then show "development" in the UI. But the next Puppet run on servername will produce the output shown at the top of this post, and then after that refreshing the Foreman UI will again show one entry with "development" and one entry with "test."
What could be causing this? How can I assign hosts to environments and have it stick?