Puppet Enterprise 2023.0.0 Local environment doesn't match server specified environment

245 Views Asked by At

So I've been at this for a couple of days, combining the power of Google & ChatGPT (and Grayskull if I could), to no avail. I've set the agents environment, and after clearing the cache, the agent reports the environment it believes it's in. On the agent:

> sudo puppet agent --configprint environment
test

> sudo puppet node find $AGENT_FQDN --render-as yaml | grep environment:
environment: test
  agent_specified_environment: test

but when I try to test the agent, it swaps back to production

> sudo puppet agent -t --environment test
Info: Using environment 'test'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Notice: Local environment: 'test' doesn't match server specified environment 'production', restarting agent run with environment 'production'

On the Puppet Enterprise server, I have the default node_terminus, i.e. no custom ENC, but it continues to override the agent configuration

> sudo puppet config print --environment test | grep node_terminus
node_terminus = plain

> sudo puppet node find $AGENT_FQDN --render-as yaml | grep environment:
environment: production

I've considered removing and re-registering the agent, but that will just default it back into production anyway?

1

There are 1 best solutions below

0
Jules Clements On

I was missing a critical element. In the Puppet Enterprise GUI, under Node Groups I've added test ("User Acceptance Test") as an Environment Group under All Environments.

I then created a rule for agent_specific_environment = test. Now the agent stays in it's environment. To veryiy this, I put breaking change into one of the test environment modules.

> sudo puppet agent --test
sudo puppet agent --test
Info: Using environment 'test'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Apache::Vhost[example.com]: parameter 'port' expects a value of type Undef, Array[Stdlib::Port = Integer[0, 65535]], or Stdlib::Port = Integer[0, 65535], got String (file: /etc/puppetlabs/code/environments/test/modules/lamp/manifests/init.pp, line: 10)

User Acceptance Test