Foreman enivronment when running puppet agent

Hi there, i have a small question related to puppet-foreman functionality. When i run puppet agent on client side and explicitly change environment to anything rather than prod foreman still shows me that my host is always running on production environment rather than the one that i just used. How is it possible to make foreman display the environment agent is running on that is specified in puppet.conf file. (ENC Environment setting in foreman set to NO).

Thank you, Yuri.


actually it is possible :grinning: You have to set the Foreman parameter “Update environment from facts” to “yes”. This enables the change of the hosts Puppet environment on the Foreman Server based on the Puppet Fact “environment”. The “environment” fact must be present on the host, however it seems that newer Puppet versions don’t provide this fact anymore.

If your Puppet version does not provide this fact, you can create a custom fact named “environment” as a workaround.

Example: environment.rb:

Facter.add(:environment) do
  setcode do
      Facter::Util::Resolution.exec('puppet agent --configprint environment')