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?
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 underAll 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 thetestenvironment modules.