config print seems to be broken

197 views
Skip to first unread message

Brandon Metcalf

unread,
Sep 20, 2013, 5:14:41 PM9/20/13
to puppet...@googlegroups.com
Am I missing something or is this behavior broken:

$ puppet -V
3.2.3
$ grep environment /etc/puppet/puppet.conf
    environment = bmetcalf
$ puppet config print environment
production

Thanks.

Rahul Khengare

unread,
Sep 23, 2013, 5:47:45 AM9/23/13
to puppet...@googlegroups.com
Hi Brandon,
    puppet config print option print the environment variable of [main] section only it is not overridden by another config block.
Check the config block of environment variable present in puppet.conf file.

Read following documentation of puppet on environment,
  
Thanks and Regards,
Rahul Khengare,
NTT DATA OSS Center, Pune, India.

Brandon Metcalf

unread,
Sep 23, 2013, 11:02:18 AM9/23/13
to puppet...@googlegroups.com
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.

John Julien

unread,
Sep 23, 2013, 12:03:08 PM9/23/13
to puppet...@googlegroups.com


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-022bd17388c88fcad57e6f36fff407fb
as a result of some concerns expressed in https://projects.puppetlabs.com/issues/16189

This 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.



Dan White

unread,
Sep 23, 2013, 12:19:29 PM9/23/13
to puppet...@googlegroups.com
It still works this way:

[root ~]# puppet agent --configprint ssldir
/var/lib/puppet/ssl
[root ~]# puppet master --configprint ssldir
/var/lib/puppet-master/ssl

as opposed to:

[root ~]# puppet config print ssldir
/var/lib/puppet/ssl

“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.”
Bill Waterson (Calvin & Hobbes)


From: "John Julien" <jo...@julienfamily.com>
To: puppet...@googlegroups.com
Sent: Monday, September 23, 2013 12:03:08 PM
Subject: [Puppet Users] Re: config print seems to be broken
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To post to this group, send email to puppet...@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Josh Cooper

unread,
Oct 31, 2013, 1:06:35 AM10/31/13
to puppet...@googlegroups.com
On Mon, Sep 23, 2013 at 9:19 AM, Dan White <yg...@comcast.net> wrote:
It still works this way:

[root ~]# puppet agent --configprint ssldir
/var/lib/puppet/ssl
[root ~]# puppet master --configprint ssldir
/var/lib/puppet-master/ssl


You are better off specifying the application, e.g. master, and the --configprint option to obtain the "correct" answer.

as opposed to:

[root ~]# puppet config print ssldir
/var/lib/puppet/ssl

This invokes the `config` face-based application, which has issues...

Josh

--
Josh Cooper
Developer, Puppet Labs

Dan White

unread,
Oct 31, 2013, 8:49:19 AM10/31/13
to puppet...@googlegroups.com
Makes perfect sense.
Is there an open issue on this ?
if not, I would be glad to do the honors


“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.”
Bill Waterson (Calvin & Hobbes)


From: "Josh Cooper" <jo...@puppetlabs.com>
To: puppet...@googlegroups.com
Sent: Thursday, October 31, 2013 1:06:35 AM
Subject: Re: [Puppet Users] Re: config print seems to be broken
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages