Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to determine what Puppet thinks the environment is on my agent nodes. Per the documentation I've configured the agent's environment in /etc/puppet/puppet.conf as such

[agent]
    environment = development

In order to view the environment I've found this code to add an environment fact to facter:

require 'puppet'

Facter.add("environment") do
  setcode do
    Puppet[:environment]
  end
end

However, on one of my agent nodes, if I run sudo facter -p environment, the result is production. I've tried to manually set the environment temporarily via sudo puppet agent --environment development, however the result from facter is the same.

Any idea what's going on?

share|improve this question
    
Perhaps a bug. I added environment to the main stanza and it works (after restarting puppet service). Putting the value beneath the agent stanza seems to have no effect. –  quickshiftin Oct 25 '13 at 17:10
1  
Environment is already passed to the server. You don't need to create a fact. –  Zoredache Oct 25 '13 at 17:11
    
@Zoredache Seems like the environment wasn't even being set correctly to begin with. How else would I have seen that without the fact? –  quickshiftin Oct 25 '13 at 17:23
    
Also, why would sudo puppet agent --environment development not be reflected via the fact? –  quickshiftin Oct 25 '13 at 17:34
3  
The puppet client sends some facts of its own that you don't see in facter. environment is one, The client version, and certificate name are other examples. You can put something like notify {"environment = $::environment":} on your master. –  Zoredache Oct 25 '13 at 17:53

1 Answer 1

up vote 2 down vote accepted

Try puppet agent --configprint environment - that'll make sure it's using the [agent] block in the config file, which will also be used when the agent is getting a catalog from a master.

share|improve this answer
    
Shouldn't the agent stanza inherit from the main stanza? That's what the documentation says "The [main] config block is the least specific. Settings here are always effective, unless overridden by a more specific block." However, when I run this command the result is production, whereas if I use the fact in my question development is returned. Even when I try your command with the environment set beneath the agent stanza the result is production –  quickshiftin Oct 25 '13 at 20:44
    
Yes, it can be set in either the main or agent block. It's not using the correct config file if the contents of the config file aren't in effect. Are you root? –  Shane Madden Oct 25 '13 at 20:58
    
I know you should to be able to be able to set the environment in either location, but the fact doesn't seem to work 100% when set inside the agent stanza. I've been running the facter command via sudo. And just realized when running your command via sudo it returns development. Moreover it returns development when the environment is set in the agent stanza! Goodbye custom fact, hello next serverfault question (coming soon ;)) –  quickshiftin Oct 25 '13 at 21:40
    
@quickshiftin Right - when you aren't root, then it's not using the /etc/puppet/puppet.conf file. –  Shane Madden Oct 25 '13 at 23:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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