1

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.

Philip Kirkbride
  • 279
  • 2
  • 10
  • 30
  • @gf_ I will find the information you requested and update my question. – Philip Kirkbride May 05 '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 ... `. – gxx May 05 '17 at 18:42
  • @gf_ sorry I misread. I've updated my question after trying your suggested solution. – Philip Kirkbride May 05 '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. – gxx May 05 '17 at 18:48
  • @gf_ why would I mark as solved when I still get the same error but worked differently? My original problem is that puppet master isn't seeing the environments from my environments folder and I'm still having that problem. – Philip Kirkbride May 05 '17 at 18:49
  • Show the config of your puppet master. – gxx May 05 '17 at 18:52
  • 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! – gxx May 05 '17 at 18:55

2 Answers2

2

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

gxx
  • 5,591
  • 2
  • 22
  • 42
  • Thanks for the suggestion. I still get a similar, but slightly different error. – Philip Kirkbride May 05 '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. – gxx May 05 '17 at 18:49
  • you are 100% right. Sorry about that I should have read more carefully. – Philip Kirkbride May 05 '17 at 18:53
0

another option is that in the /etc/hosts of the agent - the name of the server is not as appears in the result of the command hostname this can cause confusion when the agent communicate with the puppet server