|
John Julien |
at Sep 23, 2013 at 4:21 pm
|
⇧ |
| |
On Monday, September 23, 2013 10:02:18 AM UTC-5, Brandon Metcalf wrote:
OK, thanks. Based on the doc, it looks like if I have a host that acts as
a master and agent and the [master] and [agent] sections contain different
values for environment, then there is no way to get "puppet config print
environment" to print the value from the [agent] section.
This actually used to works in 2.7.x by running "puppet config print
environment --mode agent"
The --mode option was removed and replaced with --run_mode in 3.x
https://github.com/jjulien/puppet/commit/f4e229ee5a0a1d6a62735eb434eb2c284b7f517d#diff-022bd17388c88fcad57e6f36fff407fbas a result of some concerns expressed in
https://projects.puppetlabs.com/issues/16189This does not appear to be working though, as an error is thrown when
--run_mode is being specified and the bootstrapping of the run to a default
of "agent" also does not appear to be functioning properly.
You may want to use an iniparser to gather this info until the bug can be
fixed. Another option is to use the following ruby code:
require 'puppet'
app = Puppet::Application::Agent.new()
app.preinit
Puppet.settings.parse
Puppet[:daemonize] = false
app.setup
# You can now access your [agent] config settings like so:
puts "Agent environment: #{Puppet[:environment]}"
This works fine on a normal functioning puppet client. One bug that will
cause an endless loop for you is if your certificate and private key don't
match. Probably quite the corner case for most, but I'm in the middle of
some rigorous testing around Puppet monitoring and have come across that
situation.