diff options
author | Britt Gresham <britt@puppetlabs.com> | 2014-09-29 15:23:35 -0700 |
---|---|---|
committer | Britt Gresham <britt@puppetlabs.com> | 2014-09-30 11:25:00 -0700 |
commit | 8b5ffc854f1f47bbbe073847de5579de4dfc5532 (patch) | |
tree | 2cc819f6db2baa8384d8185c4b1d51f9c8ed9d0c | |
parent | 6d0d748f9e2832266aa7b4a278660983cdebb89a (diff) | |
download | puppet-8b5ffc854f1f47bbbe073847de5579de4dfc5532.tar.gz |
(PUP-3244) ENC ignores missing directory environments
When using an ENC, if an environment that didn't exist was defined for a
node puppet would place the node into the production environment instead
of raising an error to alert the user that the environment that had been
requested did not exist.
This commit changes the behaviour when an environment is defined in an
ENC but does not actually exist. Instead of placing the node into the
production environment a Puppet::Environments::EnvironmentNotFound error
is raised.
-rw-r--r-- | lib/puppet/indirector/node/exec.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/puppet/indirector/node/exec.rb b/lib/puppet/indirector/node/exec.rb index d4faf74f4..9fa3c07ad 100644 --- a/lib/puppet/indirector/node/exec.rb +++ b/lib/puppet/indirector/node/exec.rb @@ -19,6 +19,14 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec # Translate the output to ruby. result = translate(request.key, output) + # If defining a new environment then we check to see if + # the environment exists, if it does not then we raise + # an error instead of falling back to the 'production' + # environment. + if result[:environment] && !Puppet.lookup(:environments).get(result[:environment]) + raise Puppet::Environments::EnvironmentNotFound, result[:environment] + end + # Set the requested environment if it wasn't overridden # If we don't do this it gets set to the local default result[:environment] ||= request.environment.name |