diff options
author | Daniel Pittman <daniel@puppetlabs.com> | 2011-03-28 10:47:09 -0700 |
---|---|---|
committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-03-28 10:47:09 -0700 |
commit | 2ad8c96935ec53c2d98201ad77fd070dc40dadb6 (patch) | |
tree | f8f4d581c3b0445df836d5e55945f62547239598 /lib/puppet/string/v0.0.1 | |
parent | 88aeb04a50d8997b5e1e0ed7a5a2239508b174ee (diff) | |
parent | b859baa04737644e40002f511c5941d002a956e3 (diff) | |
download | puppet-2ad8c96935ec53c2d98201ad77fd070dc40dadb6.tar.gz puppet-2ad8c96935ec53c2d98201ad77fd070dc40dadb6.tar.xz puppet-2ad8c96935ec53c2d98201ad77fd070dc40dadb6.zip |
Merge branch 'maint/master/puppet-strings-is-the-official-api-name'
Diffstat (limited to 'lib/puppet/string/v0.0.1')
-rw-r--r-- | lib/puppet/string/v0.0.1/catalog.rb | 40 | ||||
-rw-r--r-- | lib/puppet/string/v0.0.1/catalog/select.rb | 10 | ||||
-rw-r--r-- | lib/puppet/string/v0.0.1/certificate.rb | 28 | ||||
-rw-r--r-- | lib/puppet/string/v0.0.1/certificate_request.rb | 4 | ||||
-rw-r--r-- | lib/puppet/string/v0.0.1/certificate_revocation_list.rb | 4 | ||||
-rw-r--r-- | lib/puppet/string/v0.0.1/config.rb | 11 | ||||
-rw-r--r-- | lib/puppet/string/v0.0.1/configurer.rb | 12 | ||||
-rw-r--r-- | lib/puppet/string/v0.0.1/facts.rb | 18 | ||||
-rw-r--r-- | lib/puppet/string/v0.0.1/file.rb | 5 | ||||
-rw-r--r-- | lib/puppet/string/v0.0.1/key.rb | 4 | ||||
-rw-r--r-- | lib/puppet/string/v0.0.1/node.rb | 5 | ||||
-rw-r--r-- | lib/puppet/string/v0.0.1/report.rb | 15 | ||||
-rw-r--r-- | lib/puppet/string/v0.0.1/resource.rb | 4 | ||||
-rw-r--r-- | lib/puppet/string/v0.0.1/resource_type.rb | 4 | ||||
-rw-r--r-- | lib/puppet/string/v0.0.1/status.rb | 4 |
15 files changed, 168 insertions, 0 deletions
diff --git a/lib/puppet/string/v0.0.1/catalog.rb b/lib/puppet/string/v0.0.1/catalog.rb new file mode 100644 index 000000000..0ddd83176 --- /dev/null +++ b/lib/puppet/string/v0.0.1/catalog.rb @@ -0,0 +1,40 @@ +require 'puppet/string/indirector' + +Puppet::String::Indirector.define(:catalog, '0.0.1') do + action(:apply) do + invoke 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 + end + + action(:download) do + invoke 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::String[:catalog, '0.0.1'].find(certname, facts_to_upload) + end + catalog = catalog.to_ral + catalog.finalize + catalog.retrieval_duration = retrieval_duration + catalog.write_class_file + catalog + end + end +end diff --git a/lib/puppet/string/v0.0.1/catalog/select.rb b/lib/puppet/string/v0.0.1/catalog/select.rb new file mode 100644 index 000000000..52c77d3ce --- /dev/null +++ b/lib/puppet/string/v0.0.1/catalog/select.rb @@ -0,0 +1,10 @@ +# Select and show a list of resources of a given type. +Puppet::String.define(:catalog, '0.0.1') do + action :select do + invoke do |host,type| + catalog = Puppet::Resource::Catalog.indirection.find(host) + + catalog.resources.reject { |res| res.type != type }.each { |res| puts res } + end + end +end diff --git a/lib/puppet/string/v0.0.1/certificate.rb b/lib/puppet/string/v0.0.1/certificate.rb new file mode 100644 index 000000000..7b2e5f397 --- /dev/null +++ b/lib/puppet/string/v0.0.1/certificate.rb @@ -0,0 +1,28 @@ +require 'puppet/string/indirector' +require 'puppet/ssl/host' + +Puppet::String::Indirector.define(:certificate, '0.0.1') do + + action :generate do + invoke do |name| + host = Puppet::SSL::Host.new(name) + host.generate_certificate_request + host.certificate_request.class.indirection.save(host.certificate_request) + end + end + + action :list do + invoke do + Puppet::SSL::Host.indirection.search("*", { + :for => :certificate_request, + }).map { |h| h.inspect } + end + end + + action :sign do + invoke do |name| + Puppet::SSL::Host.indirection.save(Puppet::SSL::Host.new(name)) + end + end + +end diff --git a/lib/puppet/string/v0.0.1/certificate_request.rb b/lib/puppet/string/v0.0.1/certificate_request.rb new file mode 100644 index 000000000..218b40b98 --- /dev/null +++ b/lib/puppet/string/v0.0.1/certificate_request.rb @@ -0,0 +1,4 @@ +require 'puppet/string/indirector' + +Puppet::String::Indirector.define(:certificate_request, '0.0.1') do +end diff --git a/lib/puppet/string/v0.0.1/certificate_revocation_list.rb b/lib/puppet/string/v0.0.1/certificate_revocation_list.rb new file mode 100644 index 000000000..9731b4f2d --- /dev/null +++ b/lib/puppet/string/v0.0.1/certificate_revocation_list.rb @@ -0,0 +1,4 @@ +require 'puppet/string/indirector' + +Puppet::String::Indirector.define(:certificate_revocation_list, '0.0.1') do +end diff --git a/lib/puppet/string/v0.0.1/config.rb b/lib/puppet/string/v0.0.1/config.rb new file mode 100644 index 000000000..ae1a408cf --- /dev/null +++ b/lib/puppet/string/v0.0.1/config.rb @@ -0,0 +1,11 @@ +require 'puppet/string' + +Puppet::String.define(:config, '0.0.1') do + action(:print) do + invoke do |*args| + Puppet.settings[:configprint] = args.join(",") + Puppet.settings.print_config_options + nil + end + end +end diff --git a/lib/puppet/string/v0.0.1/configurer.rb b/lib/puppet/string/v0.0.1/configurer.rb new file mode 100644 index 000000000..a6ea74b6a --- /dev/null +++ b/lib/puppet/string/v0.0.1/configurer.rb @@ -0,0 +1,12 @@ +require 'puppet/string' + +Puppet::String.define(:configurer, '0.0.1') do + action(:synchronize) do + invoke do |certname| + facts = Puppet::String[:facts, '0.0.1'].find(certname) + catalog = Puppet::String[:catalog, '0.0.1'].download(certname, facts) + report = Puppet::String[:catalog, '0.0.1'].apply(catalog) + report + end + end +end diff --git a/lib/puppet/string/v0.0.1/facts.rb b/lib/puppet/string/v0.0.1/facts.rb new file mode 100644 index 000000000..73acb0df6 --- /dev/null +++ b/lib/puppet/string/v0.0.1/facts.rb @@ -0,0 +1,18 @@ +require 'puppet/string/indirector' +require 'puppet/node/facts' + +Puppet::String::Indirector.define(:facts, '0.0.1') do + set_default_format :yaml + + # Upload our facts to the server + action(:upload) do + invoke do |*args| + Puppet::Node::Facts.indirection.terminus_class = :facter + facts = Puppet::Node::Facts.indirection.find(Puppet[:certname]) + Puppet::Node::Facts.indirection.terminus_class = :rest + Puppet::Node::Facts.indirection.save(facts) + Puppet.notice "Uploaded facts for '#{Puppet[:certname]}'" + nil + end + end +end diff --git a/lib/puppet/string/v0.0.1/file.rb b/lib/puppet/string/v0.0.1/file.rb new file mode 100644 index 000000000..cc5737f28 --- /dev/null +++ b/lib/puppet/string/v0.0.1/file.rb @@ -0,0 +1,5 @@ +require 'puppet/string/indirector' + +Puppet::String::Indirector.define(:file, '0.0.1') do + set_indirection_name :file_bucket_file +end diff --git a/lib/puppet/string/v0.0.1/key.rb b/lib/puppet/string/v0.0.1/key.rb new file mode 100644 index 000000000..95aceade5 --- /dev/null +++ b/lib/puppet/string/v0.0.1/key.rb @@ -0,0 +1,4 @@ +require 'puppet/string/indirector' + +Puppet::String::Indirector.define(:key, '0.0.1') do +end diff --git a/lib/puppet/string/v0.0.1/node.rb b/lib/puppet/string/v0.0.1/node.rb new file mode 100644 index 000000000..bc31a2cf3 --- /dev/null +++ b/lib/puppet/string/v0.0.1/node.rb @@ -0,0 +1,5 @@ +require 'puppet/string/indirector' + +Puppet::String::Indirector.define(:node, '0.0.1') do + set_default_format :yaml +end diff --git a/lib/puppet/string/v0.0.1/report.rb b/lib/puppet/string/v0.0.1/report.rb new file mode 100644 index 000000000..55a008533 --- /dev/null +++ b/lib/puppet/string/v0.0.1/report.rb @@ -0,0 +1,15 @@ +require 'puppet/string/indirector' + +Puppet::String::Indirector.define(:report, '0.0.1') do + action(:submit) do + invoke 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 +end diff --git a/lib/puppet/string/v0.0.1/resource.rb b/lib/puppet/string/v0.0.1/resource.rb new file mode 100644 index 000000000..9838be0fa --- /dev/null +++ b/lib/puppet/string/v0.0.1/resource.rb @@ -0,0 +1,4 @@ +require 'puppet/string/indirector' + +Puppet::String::Indirector.define(:resource, '0.0.1') do +end diff --git a/lib/puppet/string/v0.0.1/resource_type.rb b/lib/puppet/string/v0.0.1/resource_type.rb new file mode 100644 index 000000000..8ca31ea6c --- /dev/null +++ b/lib/puppet/string/v0.0.1/resource_type.rb @@ -0,0 +1,4 @@ +require 'puppet/string/indirector' + +Puppet::String::Indirector.define(:resource_type, '0.0.1') do +end diff --git a/lib/puppet/string/v0.0.1/status.rb b/lib/puppet/string/v0.0.1/status.rb new file mode 100644 index 000000000..41de2bb99 --- /dev/null +++ b/lib/puppet/string/v0.0.1/status.rb @@ -0,0 +1,4 @@ +require 'puppet/string/indirector' + +Puppet::String::Indirector.define(:status, '0.0.1') do +end |