| Hi Sebastian I can't reproduce the issue. I installed the latest version of puppet-hiera-enc and adapted it for puppet 7 pathing:
# tail -2 /etc/puppetlabs/puppet/puppet.conf |
node_terminus = exec |
external_nodes = /etc/puppetlabs/hiera-enc/enc |
# head /etc/puppetlabs/hiera-enc/hiera-enc.yaml |
--- |
:backends: |
- yaml |
:yaml: |
:datadir: /etc/puppetlabs/hiera-enc/nodes |
:hierarchy: |
- "%{clientcert}" |
- "%{fqdn}" |
- "%{hostname}" |
- "default" |
# head /etc/puppetlabs/hiera-enc/nodes/demo.example.com.yaml |
--- |
environment: customer1
|
If you delete the last_run_summary.yaml (which contains the last used environment), then the next agent run starts up in production but switches to customer1 as expected:
# rm -rf /opt/puppetlabs/puppet/public/ |
# puppet agent -t --certname demo.example.com |
Info: Using environment 'production' |
Info: Retrieving pluginfacts |
Info: Retrieving plugin |
Notice: Local environment: 'production' doesn't match server specified environment 'customer1', restarting agent run with environment 'customer1' |
Info: Retrieving pluginfacts |
Info: Retrieving plugin |
Info: Caching catalog for demo.example.com |
Info: Applying configuration version '1629491794' |
Notice: Applied catalog in 0.01 seconds
|
The run after that starts off in the environment the server told it to use last time:
# puppet agent -t --certname demo.example.com |
Info: Using environment 'customer1' |
Info: Retrieving pluginfacts |
Info: Retrieving plugin |
Info: Caching catalog for demo.example.com |
Info: Applying configuration version '1629491805'
|
I also had to install the hiera gem into system ruby since the enc script hard codes the shebang line:
# head -3 /etc/puppetlabs/hiera-enc/enc |
#!/usr/bin/env ruby |
# |
# Copyright 2014 Peter van Zetten
|
It sounds like there's something in your classification logic that relied on retrieving the fact value from the previous run... What does your /etc/puppetlabs/hiera-enc/hiera-enc.yaml contain? Are you defining hierarchies based on agent facts? Are you overriding where Puppet[:last_run_summary] is stored or modifying the file between runs? |