diff --git a/lib/puppet/application/secret_agent.rb b/lib/puppet/application/secret_agent.rb deleted file mode 100644 index 6bee28431..000000000 --- a/lib/puppet/application/secret_agent.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'puppet/application/face_base' -require 'puppet/face' - -# NOTE: this is using an "old" naming convention (underscores instead of camel-case), for backwards -# compatibility with 2.7.x. When the old naming convention is officially and publicly deprecated, -# this should be changed to camel-case. -class Puppet::Application::Secret_agent < Puppet::Application::FaceBase - run_mode :agent -end diff --git a/lib/puppet/face/catalog.rb b/lib/puppet/face/catalog.rb index ae2dadc29..e596a55e5 100644 --- a/lib/puppet/face/catalog.rb +++ b/lib/puppet/face/catalog.rb @@ -1,130 +1,130 @@ require 'puppet/indirector/face' Puppet::Indirector::Face.define(:catalog, '0.0.1') do copyright "Puppet Labs", 2011 license "Apache 2 license; see COPYING" summary "Compile, save, view, and convert catalogs." description <<-'EOT' This subcommand deals with catalogs, which are compiled per-node artifacts generated from a set of Puppet manifests. By default, it interacts with the compiling subsystem and compiles a catalog using the default manifest and `certname`, but you can change the source of the catalog with the `--terminus` option. You can also choose to print any catalog in 'dot' format (for easy graph viewing with OmniGraffle or Graphviz) with '--render-as dot'. EOT short_description <<-'EOT' This subcommand deals with catalogs, which are compiled per-node artifacts generated from a set of Puppet manifests. By default, it interacts with the compiling subsystem and compiles a catalog using the default manifest and `certname`; use the `--terminus` option to change the source of the catalog. EOT get_action(:destroy).summary "Invalid for this subcommand." get_action(:search).summary "Invalid for this subcommand." find = get_action(:find) find.summary "Retrieve the catalog for a node." find.arguments "" find.returns <<-'EOT' A serialized catalog. When used from the Ruby API, returns a Puppet::Resource::Catalog object. EOT action(:apply) do summary "Find and apply a catalog." description <<-'EOT' Finds and applies a catalog. This action takes no arguments, but the source of the catalog can be managed with the `--terminus` option. EOT returns <<-'EOT' Nothing. When used from the Ruby API, returns a Puppet::Transaction::Report object. EOT examples <<-'EOT' Apply the locally cached catalog: $ puppet catalog apply --terminus yaml Retrieve a catalog from the master and apply it, in one step: $ puppet catalog apply --terminus rest - From `secret_agent.rb` (API example): + API example: # ... Puppet::Face[:catalog, '0.0.1'].download # (Termini are singletons; catalog.download has a side effect of # setting the catalog terminus to yaml) report = Puppet::Face[:catalog, '0.0.1'].apply # ... EOT 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 report.environment = Puppet[:environment] Puppet::Util::Log.newdestination(report) begin benchmark(:notice, "Finished catalog run") do catalog.apply(:report => report) end rescue => detail Puppet.log_exception(detail, "Failed to apply catalog: #{detail}") end report.finalize_report report end end action(:download) do summary "Download this node's catalog from the puppet master server." description <<-'EOT' Retrieves a catalog from the puppet master and saves it to the local yaml cache. This action always contacts the puppet master and will ignore alternate termini. The saved catalog can be used in any subsequent catalog action by specifying '--terminus yaml' for that action. EOT returns "Nothing." notes <<-'EOT' When used from the Ruby API, this action has a side effect of leaving Puppet::Resource::Catalog.indirection.terminus_class set to yaml. The terminus must be explicitly re-set for subsequent catalog actions. EOT examples <<-'EOT' Retrieve and store a catalog: $ puppet catalog download - From `secret_agent.rb` (API example): + API example: Puppet::Face[:plugin, '0.0.1'].download Puppet::Face[:facts, '0.0.1'].upload Puppet::Face[:catalog, '0.0.1'].download # ... EOT when_invoked do |options| Puppet::Resource::Catalog.indirection.terminus_class = :rest Puppet::Resource::Catalog.indirection.cache_class = nil catalog = nil retrieval_duration = thinmark do catalog = Puppet::Face[:catalog, '0.0.1'].find(Puppet[:certname]) end catalog.retrieval_duration = retrieval_duration catalog.write_class_file 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 55288cc42..c5ff1a4a9 100644 --- a/lib/puppet/face/report.rb +++ b/lib/puppet/face/report.rb @@ -1,54 +1,54 @@ require 'puppet/indirector/face' Puppet::Indirector::Face.define(:report, '0.0.1') do copyright "Puppet Labs", 2011 license "Apache 2 license; see COPYING" summary "Create, display, and submit reports." get_action(:find).summary "Invalid for this face." get_action(:search).summary "Invalid for this face." get_action(:destroy).summary "Invalid for this face." save = get_action(:save) save.summary "API only: submit a report." save.arguments "" save.returns "Nothing." save.examples <<-'EOT' From the implementation of `puppet report submit` (API example): begin Puppet::Transaction::Report.indirection.terminus_class = :rest Puppet::Face[:report, "0.0.1"].save(report) Puppet.notice "Uploaded report for #{report.name}" rescue => detail Puppet.log_exception(detail, "Could not send report: #{detail}") end EOT action(:submit) do summary "API only: submit a report with error handling." description <<-'EOT' API only: Submits a report to the puppet master. This action is essentially a shortcut and wrapper for the `save` action with the `rest` terminus, and provides additional details in the event of a failure. EOT arguments "" examples <<-'EOT' - From secret_agent.rb (API example): + API example: # ... report = Puppet::Face[:catalog, '0.0.1'].apply Puppet::Face[:report, '0.0.1'].submit(report) return report EOT when_invoked do |report, options| begin Puppet::Transaction::Report.indirection.terminus_class = :rest Puppet::Face[:report, "0.0.1"].save(report) Puppet.notice "Uploaded report for #{report.name}" rescue => detail Puppet.log_exception(detail, "Could not send report: #{detail}") end end end end diff --git a/lib/puppet/face/secret_agent.rb b/lib/puppet/face/secret_agent.rb deleted file mode 100644 index 7771d576a..000000000 --- a/lib/puppet/face/secret_agent.rb +++ /dev/null @@ -1,54 +0,0 @@ -require 'puppet/face' - -Puppet::Face.define(:secret_agent, '0.0.1') do - copyright "Puppet Labs", 2011 - license "Apache 2 license; see COPYING" - - summary "Mimics puppet agent." - description <<-'EOT' - This subcommand currently functions as a proof of concept, demonstrating how - the Faces API exposes Puppet's internal systems to application logic; - compare the actual code for puppet agent. It will eventually replace puppet - agent entirely, and can provide a template for users who wish to implement - agent-like functionality with non-standard application logic. - EOT - - action(:synchronize) do - default - summary "Run secret_agent once." - description <<-'EOT' - Mimics a single run of puppet agent. This action does not currently - daemonize, but can download plugins, submit facts, retrieve and apply a - catalog, and submit a report to the puppet master. - EOT - returns <<-'EOT' - Verbose logging from the completed run. When used from the Ruby API: - returns a Puppet::Transaction::Report object. - EOT - examples <<-'EOT' - Trigger a Puppet run with the configured puppet master: - - $ puppet secret_agent - EOT - notes <<-'EOT' - This action requires that the puppet master's `auth.conf` file allow save - access to the `facts` REST terminus. Puppet agent does not use this - facility, and it is turned off by default. See - for more details. - EOT - - when_invoked do |options| - Puppet::Face[:plugin, '0.0.1'].download - - 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) - - return report - end - end -end diff --git a/man/man8/extlookup2hiera.8 b/man/man8/extlookup2hiera.8 index 035545b02..bc808e782 100644 --- a/man/man8/extlookup2hiera.8 +++ b/man/man8/extlookup2hiera.8 @@ -1,10 +1,10 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "EXTLOOKUP2HIERA" "8" "September 2014" "Puppet Labs, LLC" "Puppet manual" +.TH "EXTLOOKUP2HIERA" "8" "October 2014" "Puppet Labs, LLC" "Puppet manual" . .SH "NAME" \fBextlookup2hiera\fR . .P Converter for extlookup CSV files into Hiera JSON and YAML files \-i, \-\-in FILE Input CSV file \-o, \-\-out FILE Output Hiera file \-j, \-\-json Create JSON format file diff --git a/spec/unit/application/secret_agent_spec.rb b/spec/unit/application/secret_agent_spec.rb deleted file mode 100755 index be6e1cf15..000000000 --- a/spec/unit/application/secret_agent_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -#! /usr/bin/env ruby -require 'spec_helper' -require 'puppet/application/secret_agent' -require 'puppet/indirector/catalog/rest' -require 'puppet/indirector/report/rest' -require 'tempfile' - -describe "Puppet::Application::Secret_agent" do - include PuppetSpec::Files - - it "should retrieve and apply a catalog and submit a report" do - pending "REVISIT: 2.7 changes broke this, and we want the merge published" - - dirname = tmpdir("puppetdir") - Puppet[:vardir] = dirname - Puppet[:confdir] = dirname - Puppet[:certname] = "foo" - @catalog = Puppet::Resource::Catalog.new - @file = Puppet::Resource.new(:file, File.join(dirname, "tmp_dir_resource"), :parameters => {:ensure => :present}) - @catalog.add_resource(@file) - - @report = Puppet::Transaction::Report.new("apply") - Puppet::Transaction::Report.stubs(:new).returns(@report) - - Puppet::Resource::Catalog::Rest.any_instance.stubs(:find).returns(@catalog) - @report.expects(:save) - - Puppet::Util::Log.stubs(:newdestination) - - Puppet::Application::Secret_agent.new.run - - @report.status.should == "changed" - end -end diff --git a/spec/unit/face/secret_agent_spec.rb b/spec/unit/face/secret_agent_spec.rb deleted file mode 100755 index fa692281d..000000000 --- a/spec/unit/face/secret_agent_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -#! /usr/bin/env ruby -require 'spec_helper' -require 'puppet/face' -require 'puppet/indirector/catalog/rest' -require 'tempfile' - -describe Puppet::Face[:secret_agent, '0.0.1'] do - include PuppetSpec::Files - - describe "#synchronize" do - it "should retrieve and apply a catalog and return a report" do - pending "This test doesn't work, but the code actually does - tested by LAK" - dirname = tmpdir("puppetdir") - Puppet[:vardir] = dirname - Puppet[:confdir] = dirname - @catalog = Puppet::Resource::Catalog.new - @file = Puppet::Resource.new(:file, File.join(dirname, "tmp_dir_resource"), :parameters => {:ensure => :present}) - @catalog.add_resource(@file) - Puppet::Resource::Catalog::Rest.any_instance.stubs(:find).returns(@catalog) - - report = subject.synchronize - - report.kind.should == "apply" - report.status.should == "changed" - end - end -end