0

I have file structures for 2 environments on my puppet master server. Running ls /etc/puppetlabs/code/environments/ on my master server returns two folders beta and production.

Yet when I go on my agent and run puppet apply -t --environment beta I get the error:

/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/environments.rb:38:in `get!':
Could not find a directory environment named 'beta' anywhere in the path: /etc/puppetlabs/code/environments.
Does the directory exist? (Puppet::Environments::EnvironmentNotFound)

On the master server I can successfully apply the beta manifest with puppet apply /etc/puppetlabs/code/environments/beta/manifests/site.pp.

I'm trying to figure out why Puppet isn't detecting the folder. How can I go about debugging this?

I also tried puppet agent -t --environment beta, as suggested by @gd_, which returns:

Notice: Local environment: 'beta' doesn't match server specified node environment 'production', switching agent to 'production'.

/etc/puppetlabs/puppet/puppet.conf (on agent) is as follows:

# This file can be used to override the default puppet settings.
# See the following links for more details on what settings are available:
# - https://docs.puppetlabs.com/puppet/latest/reference/config_important_settings.html
# - https://docs.puppetlabs.com/puppet/latest/reference/config_about_settings.html
# - https://docs.puppetlabs.com/puppet/latest/reference/config_file_main.html
# - https://docs.puppetlabs.com/puppet/latest/reference/configuration.html

Using open source version.

  • @gf_ I will find the information you requested and update my question. – Philip Kirkbride May 5 '17 at 18:41
  • 1
    Well, you wrote that you're using puppet apply -t --environment beta, which is not a valid call. Try with puppet agent ... . – gf_ May 5 '17 at 18:42
  • @gf_ sorry I misread. I've updated my question after trying your suggested solution. – Philip Kirkbride May 5 '17 at 18:44
  • It's not considered good practice to edit questions with new errors which are coming up. I would suggest to mark this question as solved, and create a new one. Anyway: Which version is this? Also: Is this open source or puppet enterprise? Searching for the error gives quite some hints what could be wrong. – gf_ May 5 '17 at 18:48
  • 1
    Just as a final hint: If both, the master and the agent, via their respective config or via the CLI, request a specific environment, the master wins. Good luck! – gf_ May 5 '17 at 18:55
2

Use puppet agent ..., instead of puppet apply .... The params you're using apply to the former, not the later.

  • Thanks for the suggestion. I still get a similar, but slightly different error. – Philip Kirkbride May 5 '17 at 18:48
  • 2
    The error is not really similar. It means that the server is overriding the environment and or providing the environment on the CLI is disabled. Searching for the error gives quite some hints. – gf_ May 5 '17 at 18:49
  • you are 100% right. Sorry about that I should have read more carefully. – Philip Kirkbride May 5 '17 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.