summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-05-03 17:02:46 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-05-03 17:02:46 -0700
commitd203853bc8b40732c2ba88a4e5396f00a1e3a4ec (patch)
treed781cc453292325dfad9df2ccb31e212a3f70147 /lib
parent71af776efc45daaaf14ca66db41261d6906bfd1b (diff)
parentdc0088f96f80292f545395eb3084dd37f7883ee9 (diff)
downloadpuppet-d203853bc8b40732c2ba88a4e5396f00a1e3a4ec.tar.gz
puppet-d203853bc8b40732c2ba88a4e5396f00a1e3a4ec.tar.xz
puppet-d203853bc8b40732c2ba88a4e5396f00a1e3a4ec.zip
Merge branch 'bug/2.7.x/7277-improve-secret-agent-face-and-supporting-actions' into 2.7.x
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/face/catalog.rb21
-rw-r--r--lib/puppet/face/report.rb5
-rw-r--r--lib/puppet/face/secret_agent.rb10
3 files changed, 22 insertions, 14 deletions
diff --git a/lib/puppet/face/catalog.rb b/lib/puppet/face/catalog.rb
index 5f1f138ee..3e964c7fe 100644
--- a/lib/puppet/face/catalog.rb
+++ b/lib/puppet/face/catalog.rb
@@ -18,7 +18,10 @@ with '--format dot'.
action(:apply) do
summary "apply a Puppet::Resource::Catalog object"
- when_invoked do |catalog, options|
+ when_invoked do |options|
+ catalog = Puppet::Face[:catalog, "0.0.1"].find(Puppet[:certname]) or raise "Could not find catalog for #{Puppet[:certname]}"
+ catalog = catalog.to_ral
+
report = Puppet::Transaction::Report.new("apply")
report.configuration_version = catalog.version
@@ -39,20 +42,22 @@ with '--format dot'.
end
action(:download) do
- summary "download the catalog given the certname and facts"
+ summary "Download the catalog for the certname to the local filesystem."
- when_invoked do |certname, facts, options|
+ when_invoked do |options|
Puppet::Resource::Catalog.indirection.terminus_class = :rest
- facts_to_upload = {:facts_format => :b64_zlib_yaml, :facts => CGI.escape(facts.render(:b64_zlib_yaml))}
+ Puppet::Resource::Catalog.indirection.cache_class = nil
catalog = nil
retrieval_duration = thinmark do
- catalog = Puppet::Face[:catalog, '0.0.1'].find(certname, facts_to_upload)
+ catalog = Puppet::Face[:catalog, '0.0.1'].find(Puppet[:certname])
end
- catalog = catalog.to_ral
- catalog.finalize
catalog.retrieval_duration = retrieval_duration
catalog.write_class_file
- catalog
+
+ Puppet::Resource::Catalog.indirection.terminus_class = :yaml
+ Puppet::Face[:catalog, "0.0.1"].save(catalog)
+ Puppet.notice "Saved catalog for #{Puppet[:certname]} to yaml"
+ nil
end
end
end
diff --git a/lib/puppet/face/report.rb b/lib/puppet/face/report.rb
index dabf83702..f5b6d08ff 100644
--- a/lib/puppet/face/report.rb
+++ b/lib/puppet/face/report.rb
@@ -9,8 +9,9 @@ Puppet::Indirector::Face.define(:report, '0.0.1') do
action(:submit) do
when_invoked do |report, options|
begin
- Puppet::Transaction::Report.terminus_class = :rest
- report.save
+ Puppet::Transaction::Report.indirection.terminus_class = :rest
+ Puppet::Face[:report, "0.0.1"].save(report)
+ Puppet.notice "Uploaded report for #{report.name}"
rescue => detail
puts detail.backtrace if Puppet[:trace]
Puppet.err "Could not send report: #{detail}"
diff --git a/lib/puppet/face/secret_agent.rb b/lib/puppet/face/secret_agent.rb
index 50018cb13..99208b545 100644
--- a/lib/puppet/face/secret_agent.rb
+++ b/lib/puppet/face/secret_agent.rb
@@ -9,12 +9,14 @@ Puppet::Face.define(:secret_agent, '0.0.1') do
action(:synchronize) do
summary "run the secret agent, which makes the catalog and system match..."
- when_invoked do |certname, options|
+ when_invoked do |options|
Puppet::Face[:plugin, '0.0.1'].download
- facts = Puppet::Face[:facts, '0.0.1'].find(certname)
- catalog = Puppet::Face[:catalog, '0.0.1'].download(certname, facts)
- report = Puppet::Face[:catalog, '0.0.1'].apply(catalog)
+ Puppet::Face[:facts, '0.0.1'].upload
+
+ Puppet::Face[:catalog, '0.0.1'].download
+
+ report = Puppet::Face[:catalog, '0.0.1'].apply
Puppet::Face[:report, '0.0.1'].submit(report)