Determine / set Puppet environment

facterpuppet

I'm trying to determine what Puppet thinks the environment is on my agent nodes. Per the documentation I've configured the agent's environment in /etc/puppet/puppet.conf as such

[agent]
    environment = development

In order to view the environment I've found this code to add an environment fact to facter:

require 'puppet'

Facter.add("environment") do
  setcode do
    Puppet[:environment]
  end
end

However, on one of my agent nodes, if I run sudo facter -p environment, the result is production. I've tried to manually set the environment temporarily via sudo puppet agent --environment development, however the result from facter is the same.

Any idea what's going on?

Best Answer

Try puppet agent --configprint environment - that'll make sure it's using the [agent] block in the config file, which will also be used when the agent is getting a catalog from a master.