summaryrefslogtreecommitdiffstats
path: root/lib/puppet/interface
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-03-21 14:21:53 -0700
committerNick Lewis <nick@puppetlabs.com>2011-03-21 16:14:59 -0700
commit63f33d078429a9f589474f9c0778b21d82f38682 (patch)
tree2826d47842e8d1dcd30dd08a16fa4c29c2ccb23c /lib/puppet/interface
parent84ba21e66660a67e20c1194780138317e6a39d49 (diff)
downloadpuppet-63f33d078429a9f589474f9c0778b21d82f38682.tar.gz
puppet-63f33d078429a9f589474f9c0778b21d82f38682.tar.xz
puppet-63f33d078429a9f589474f9c0778b21d82f38682.zip
(#6805) Add a "configurer" application
This application is similar in basic functionality to the "agent" application, but implemented in terms of interfaces. It currently will retrieve facts, retrieve a catalog, apply the catalog, and submit a report. Options such as noop and daemonize are still to come. Reviewed-By: Pieter van de Bruggen
Diffstat (limited to 'lib/puppet/interface')
-rw-r--r--lib/puppet/interface/catalog.rb32
-rw-r--r--lib/puppet/interface/configurer.rb13
-rw-r--r--lib/puppet/interface/report.rb9
3 files changed, 54 insertions, 0 deletions
diff --git a/lib/puppet/interface/catalog.rb b/lib/puppet/interface/catalog.rb
index b2ed08f92..f99d0881a 100644
--- a/lib/puppet/interface/catalog.rb
+++ b/lib/puppet/interface/catalog.rb
@@ -1,4 +1,36 @@
require 'puppet/interface/indirector'
Puppet::Interface::Indirector.new(:catalog) do
+ action(:apply) do |catalog|
+ report = Puppet::Transaction::Report.new("apply")
+ report.configuration_version = catalog.version
+
+ Puppet::Util::Log.newdestination(report)
+
+ begin
+ benchmark(:notice, "Finished catalog run") do
+ catalog.apply(:report => report)
+ end
+ rescue => detail
+ puts detail.backtrace if Puppet[:trace]
+ Puppet.err "Failed to apply catalog: #{detail}"
+ end
+
+ report.finalize_report
+ report
+ end
+
+ action(:download) do |certname,facts|
+ Puppet::Resource::Catalog.terminus_class = :rest
+ facts_to_upload = {:facts_format => :b64_zlib_yaml, :facts => CGI.escape(facts.render(:b64_zlib_yaml))}
+ catalog = nil
+ retrieval_duration = thinmark do
+ catalog = Puppet::Interface::Catalog.find(certname, facts_to_upload)
+ end
+ catalog = catalog.to_ral
+ catalog.finalize
+ catalog.retrieval_duration = retrieval_duration
+ catalog.write_class_file
+ catalog
+ end
end
diff --git a/lib/puppet/interface/configurer.rb b/lib/puppet/interface/configurer.rb
new file mode 100644
index 000000000..42e950fa3
--- /dev/null
+++ b/lib/puppet/interface/configurer.rb
@@ -0,0 +1,13 @@
+require 'puppet/interface'
+
+Puppet::Interface.new(:configurer) do
+ action(:synchronize) do |certname|
+ facts = Puppet::Interface::Facts.find(certname)
+
+ catalog = Puppet::Interface::Catalog.download(certname, facts)
+
+ report = Puppet::Interface::Catalog.apply(catalog)
+
+ report
+ end
+end
diff --git a/lib/puppet/interface/report.rb b/lib/puppet/interface/report.rb
index e7b916527..4923a4b67 100644
--- a/lib/puppet/interface/report.rb
+++ b/lib/puppet/interface/report.rb
@@ -1,4 +1,13 @@
require 'puppet/interface/indirector'
Puppet::Interface::Indirector.new(:report) do
+ action(:submit) do |report|
+ begin
+ Puppet::Transaction::Report.terminus_class = :rest
+ report.save
+ rescue => detail
+ puts detail.backtrace if Puppet[:trace]
+ Puppet.err "Could not send report: #{detail}"
+ end
+ end
end