diff options
| author | Luke Kanies <luke@madstop.com> | 2009-07-23 19:10:29 -0700 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-07-31 16:41:41 +1000 |
| commit | 76fc2b177a026e49d8370de2092f77108769110a (patch) | |
| tree | 1df20a9c74a2fd9431c9e8c31918462489ff45f4 /lib | |
| parent | 832b6ff1e18cf403213cbeb42646b5740669e6a5 (diff) | |
| download | puppet-76fc2b177a026e49d8370de2092f77108769110a.tar.gz puppet-76fc2b177a026e49d8370de2092f77108769110a.tar.xz puppet-76fc2b177a026e49d8370de2092f77108769110a.zip | |
Fixing #2440 - catalogs can now be compiled on demand
This uses the locally cached yaml facts and prints the
catalog in json. It's meant to be used one-time, but
you have to use puppetmasterd since we assume it's the
executable correctly configured for compilation.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/application/puppetmasterd.rb | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/lib/puppet/application/puppetmasterd.rb b/lib/puppet/application/puppetmasterd.rb index e5051293f..40bc30663 100644 --- a/lib/puppet/application/puppetmasterd.rb +++ b/lib/puppet/application/puppetmasterd.rb @@ -14,6 +14,10 @@ Puppet::Application.new(:puppetmasterd) do # internal option, only to be used by ext/rack/config.ru option("--rack") + option("--compile host", "-c host") do |arg| + options[:node] = arg + end + option("--logdest DEST", "-l DEST") do |arg| begin Puppet::Util::Log.newdestination(arg) @@ -38,7 +42,29 @@ Puppet::Application.new(:puppetmasterd) do end dispatch do - return Puppet[:parseonly] ? :parseonly : :main + if options[:node] + :compile + elsif Puppet[:parseonly] + :parseonly + else + :main + end + end + + command(:compile) do + Puppet::Util::Log.newdestination :console + raise ArgumentError, "Cannot render compiled catalogs without json support" unless Puppet.features.json? + begin + unless catalog = Puppet::Resource::Catalog.find(options[:node]) + raise "Could not compile catalog for %s" % options[:node] + end + + $stdout.puts catalog.render(:json) + rescue => detail + $stderr.puts detail + exit(30) + end + exit(0) end command(:parseonly) do |
