From 628896b49e0ebc396604c0725aab7b9d372c7016 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 28 Aug 2006 05:59:40 +0000 Subject: Adding a "configprint" option for printing out the local config state git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1496 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'lib') diff --git a/lib/puppet.rb b/lib/puppet.rb index 3688377cd..5102a5ffe 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -139,6 +139,11 @@ module Puppet "Whether to just print a manifest to stdout and exit. Only makes sense when used interactively. Takes into account arguments specified on the CLI."], + :configprint => ["", + "Print the value of a specific configuration parameter. If a + parameter is provided for this, then the value is printed and puppet + exits. Comma-separate multiple values. For a list of all values, + specify 'all'."], :color => [true, "Whether to use ANSI colors when logging to the console."], :mkusers => [false, "Whether to create the necessary user and group that puppetd will @@ -246,6 +251,29 @@ module Puppet end def self.genconfig + if Puppet[:configprint] != "" + val = Puppet[:configprint] + if val == "all" + hash = {} + Puppet.config.each do |name, obj| + val = obj.value + case val + when true, false, "": val = val.inspect + end + hash[name] = val + end + hash.sort { |a,b| a[0].to_s <=> b[0].to_s }.each do |name, val| + puts "%s = %s" % [name, val] + end + elsif val =~ /,/ + val.split(/\s*,\s*/).sort.each do |v| + puts "%s = %s" % [v, Puppet[v]] + end + else + puts Puppet[val] + end + exit(0) + end if Puppet[:genconfig] puts Puppet.config.to_config exit(0) -- cgit