summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet.rb2
-rw-r--r--lib/puppet/application/agent.rb7
-rw-r--r--lib/puppet/application/apply.rb8
-rw-r--r--lib/puppet/application/inspect.rb80
-rw-r--r--lib/puppet/application/kick.rb6
-rw-r--r--lib/puppet/application/master.rb4
-rw-r--r--lib/puppet/application/queue.rb8
-rw-r--r--lib/puppet/application/resource.rb6
-rw-r--r--lib/puppet/configurer.rb6
-rw-r--r--lib/puppet/configurer/fact_handler.rb2
-rw-r--r--lib/puppet/configurer/plugin_handler.rb2
-rw-r--r--lib/puppet/defaults.rb10
-rw-r--r--lib/puppet/file_bucket/dipper.rb4
-rw-r--r--lib/puppet/indirector.rb32
-rw-r--r--lib/puppet/indirector/catalog/active_record.rb4
-rw-r--r--lib/puppet/indirector/catalog/compiler.rb4
-rw-r--r--lib/puppet/indirector/indirection.rb2
-rwxr-xr-xlib/puppet/network/handler/filebucket.rb4
-rwxr-xr-xlib/puppet/network/handler/fileserver.rb2
-rw-r--r--lib/puppet/network/handler/master.rb4
-rw-r--r--lib/puppet/network/http/handler.rb8
-rw-r--r--lib/puppet/network/http/webrick.rb2
-rw-r--r--lib/puppet/network/rest_authconfig.rb1
-rw-r--r--lib/puppet/node.rb2
-rwxr-xr-xlib/puppet/node/facts.rb4
-rw-r--r--lib/puppet/provider/augeas/augeas.rb7
-rw-r--r--lib/puppet/provider/host/parsed.rb8
-rwxr-xr-xlib/puppet/provider/maillist/mailman.rb11
-rw-r--r--lib/puppet/provider/zfs/solaris.rb2
-rw-r--r--lib/puppet/provider/zone/solaris.rb3
-rw-r--r--lib/puppet/ssl/certificate_authority.rb26
-rw-r--r--lib/puppet/ssl/certificate_request.rb24
-rw-r--r--lib/puppet/ssl/certificate_revocation_list.rb2
-rw-r--r--lib/puppet/ssl/host.rb40
-rw-r--r--lib/puppet/ssl/inventory.rb2
-rw-r--r--lib/puppet/sslcertificates/monkey_patch.rb6
-rw-r--r--lib/puppet/transaction.rb2
-rw-r--r--lib/puppet/transaction/change.rb74
-rw-r--r--lib/puppet/transaction/event.rb2
-rw-r--r--lib/puppet/transaction/report.rb5
-rw-r--r--lib/puppet/transaction/resource_harness.rb30
-rw-r--r--lib/puppet/type/file.rb5
-rwxr-xr-xlib/puppet/type/file/ensure.rb2
-rwxr-xr-xlib/puppet/type/file/mode.rb54
-rwxr-xr-xlib/puppet/type/file/source.rb4
-rwxr-xr-xlib/puppet/type/host.rb33
-rwxr-xr-xlib/puppet/type/sshkey.rb7
-rwxr-xr-xlib/puppet/type/user.rb10
-rwxr-xr-xlib/puppet/type/zfs.rb20
-rw-r--r--lib/puppet/type/zone.rb27
-rwxr-xr-xlib/puppet/util/command_line/filebucket2
-rwxr-xr-xlib/puppet/util/command_line/pi2
-rwxr-xr-xlib/puppet/util/command_line/puppet2
-rwxr-xr-xlib/puppet/util/command_line/puppetca2
-rwxr-xr-xlib/puppet/util/command_line/puppetd2
-rwxr-xr-xlib/puppet/util/command_line/puppetdoc4
-rwxr-xr-xlib/puppet/util/command_line/puppetmasterd2
-rwxr-xr-xlib/puppet/util/command_line/puppetqd2
-rwxr-xr-xlib/puppet/util/command_line/puppetrun2
-rwxr-xr-xlib/puppet/util/command_line/ralsh2
-rw-r--r--lib/puppet/util/log.rb11
61 files changed, 348 insertions, 305 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb
index 78fb5138b..a58d3c801 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -24,7 +24,7 @@ require 'puppet/util/run_mode'
# it's also a place to find top-level commands like 'debug'
module Puppet
- PUPPETVERSION = '2.6.3'
+ PUPPETVERSION = '2.6.4'
def Puppet.version
PUPPETVERSION
diff --git a/lib/puppet/application/agent.rb b/lib/puppet/application/agent.rb
index c5ad72068..96f33296f 100644
--- a/lib/puppet/application/agent.rb
+++ b/lib/puppet/application/agent.rb
@@ -228,9 +228,9 @@ class Puppet::Application::Agent < Puppet::Application
# access to the local files and we don't need a ca.
Puppet::SSL::Host.ca_location = options[:fingerprint] ? :none : :remote
- Puppet::Transaction::Report.terminus_class = :rest
+ Puppet::Transaction::Report.indirection.terminus_class = :rest
# we want the last report to be persisted locally
- Puppet::Transaction::Report.cache_class = :yaml
+ Puppet::Transaction::Report.indirection.cache_class = :yaml
# Override the default; puppetd needs this, usually.
# You can still override this on the command-line with, e.g., :compiler.
@@ -239,8 +239,7 @@ class Puppet::Application::Agent < Puppet::Application
# Override the default.
Puppet[:facts_terminus] = :facter
- Puppet::Resource::Catalog.cache_class = :yaml
-
+ Puppet::Resource::Catalog.indirection.cache_class = :yaml
# We need tomake the client either way, we just don't start it
# if --no-client is set.
diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb
index 8ec3fab6b..e5b4bb5b7 100644
--- a/lib/puppet/application/apply.rb
+++ b/lib/puppet/application/apply.rb
@@ -85,12 +85,12 @@ class Puppet::Application::Apply < Puppet::Application
end
# Collect our facts.
- unless facts = Puppet::Node::Facts.find(Puppet[:certname])
+ unless facts = Puppet::Node::Facts.indirection.find(Puppet[:certname])
raise "Could not find facts for #{Puppet[:certname]}"
end
# Find our Node
- unless node = Puppet::Node.find(Puppet[:certname])
+ unless node = Puppet::Node.indirection.find(Puppet[:certname])
raise "Could not find node #{Puppet[:certname]}"
end
@@ -112,7 +112,7 @@ class Puppet::Application::Apply < Puppet::Application
begin
# Compile our catalog
starttime = Time.now
- catalog = Puppet::Resource::Catalog.find(node.name, :use_node => node)
+ catalog = Puppet::Resource::Catalog.indirection.find(node.name, :use_node => node)
# Translate it to a RAL catalog
catalog = catalog.to_ral
@@ -149,7 +149,7 @@ class Puppet::Application::Apply < Puppet::Application
end
# we want the last report to be persisted locally
- Puppet::Transaction::Report.cache_class = :yaml
+ Puppet::Transaction::Report.indirection.cache_class = :yaml
if options[:debug]
Puppet::Util::Log.level = :debug
diff --git a/lib/puppet/application/inspect.rb b/lib/puppet/application/inspect.rb
new file mode 100644
index 000000000..c76f9e4da
--- /dev/null
+++ b/lib/puppet/application/inspect.rb
@@ -0,0 +1,80 @@
+require 'puppet/application'
+
+class Puppet::Application::Inspect < Puppet::Application
+
+ should_parse_config
+ run_mode :agent
+
+ option("--debug","-d")
+ option("--verbose","-v")
+
+ option("--logdest LOGDEST", "-l") do |arg|
+ begin
+ Puppet::Util::Log.newdestination(arg)
+ options[:logset] = true
+ rescue => detail
+ $stderr.puts detail.to_s
+ end
+ end
+
+ def setup
+ exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs?
+
+ raise "Inspect requires reporting to be enabled. Set report=true in puppet.conf to enable reporting." unless Puppet[:report]
+
+ @report = Puppet::Transaction::Report.new("inspect")
+
+ Puppet::Util::Log.newdestination(@report)
+ Puppet::Util::Log.newdestination(:console) unless options[:logset]
+
+ trap(:INT) do
+ $stderr.puts "Exiting"
+ exit(1)
+ end
+
+ if options[:debug]
+ Puppet::Util::Log.level = :debug
+ elsif options[:verbose]
+ Puppet::Util::Log.level = :info
+ end
+
+ Puppet::Transaction::Report.indirection.terminus_class = :rest
+ Puppet::Resource::Catalog.indirection.terminus_class = :yaml
+ end
+
+ def run_command
+ retrieval_starttime = Time.now
+
+ unless catalog = Puppet::Resource::Catalog.indirection.find(Puppet[:certname])
+ raise "Could not find catalog for #{Puppet[:certname]}"
+ end
+
+ retrieval_time = Time.now - retrieval_starttime
+ @report.add_times("config_retrieval", retrieval_time)
+
+ starttime = Time.now
+
+ catalog.to_ral.resources.each do |ral_resource|
+ audited_attributes = ral_resource[:audit]
+ next unless audited_attributes
+
+ audited_resource = ral_resource.to_resource
+
+ status = Puppet::Resource::Status.new(ral_resource)
+ audited_attributes.each do |name|
+ event = ral_resource.event(:previous_value => audited_resource[name], :property => name, :status => "audit", :message => "inspected value is #{audited_resource[name].inspect}")
+ status.add_event(event)
+ end
+ @report.add_resource_status(status)
+ end
+
+ @report.add_metric(:time, {"config_retrieval" => retrieval_time, "inspect" => Time.now - starttime})
+
+ begin
+ Puppet::Transaction::Report.indirection.save(@report)
+ rescue => detail
+ puts detail.backtrace if Puppet[:trace]
+ Puppet.err "Could not send report: #{detail}"
+ end
+ end
+end
diff --git a/lib/puppet/application/kick.rb b/lib/puppet/application/kick.rb
index 37aeb1ef2..12dad653a 100644
--- a/lib/puppet/application/kick.rb
+++ b/lib/puppet/application/kick.rb
@@ -120,7 +120,7 @@ class Puppet::Application::Kick < Puppet::Application
:background => ! options[:foreground],
:ignoreschedules => options[:ignoreschedules]
}
- run = Puppet::Run.new( run_options ).save( url )
+ run = Puppet::Run.indirection.save(Puppet::Run.new( run_options ), url)
puts "Getting status"
result = run.status
puts "status is #{result}"
@@ -175,12 +175,12 @@ class Puppet::Application::Kick < Puppet::Application
if Puppet[:node_terminus] == "ldap" and (options[:all] or @classes)
if options[:all]
- @hosts = Puppet::Node.search("whatever", :fqdn => options[:fqdn]).collect { |node| node.name }
+ @hosts = Puppet::Node.indirection.search("whatever", :fqdn => options[:fqdn]).collect { |node| node.name }
puts "all: #{@hosts.join(", ")}"
else
@hosts = []
@classes.each do |klass|
- list = Puppet::Node.search("whatever", :fqdn => options[:fqdn], :class => klass).collect { |node| node.name }
+ list = Puppet::Node.indirection.search("whatever", :fqdn => options[:fqdn], :class => klass).collect { |node| node.name }
puts "#{klass}: #{list.join(", ")}"
@hosts += list
diff --git a/lib/puppet/application/master.rb b/lib/puppet/application/master.rb
index fde474907..879b66c67 100644
--- a/lib/puppet/application/master.rb
+++ b/lib/puppet/application/master.rb
@@ -51,7 +51,7 @@ class Puppet::Application::Master < Puppet::Application
Puppet::Util::Log.newdestination :console
raise ArgumentError, "Cannot render compiled catalogs without pson support" unless Puppet.features.pson?
begin
- unless catalog = Puppet::Resource::Catalog.find(options[:node])
+ unless catalog = Puppet::Resource::Catalog.indirection.find(options[:node])
raise "Could not compile catalog for #{options[:node]}"
end
@@ -139,7 +139,7 @@ class Puppet::Application::Master < Puppet::Application
Puppet.settings.use :main, :master, :ssl
# Cache our nodes in yaml. Currently not configurable.
- Puppet::Node.cache_class = :yaml
+ Puppet::Node.indirection.cache_class = :yaml
# Configure all of the SSL stuff.
if Puppet::SSL::CertificateAuthority.ca?
diff --git a/lib/puppet/application/queue.rb b/lib/puppet/application/queue.rb
index 239f6b2ad..b9e8ca4ca 100644
--- a/lib/puppet/application/queue.rb
+++ b/lib/puppet/application/queue.rb
@@ -41,12 +41,12 @@ class Puppet::Application::Queue < Puppet::Application
require 'puppet/indirector/catalog/queue' # provides Puppet::Indirector::Queue.subscribe
Puppet.notice "Starting puppetqd #{Puppet.version}"
Puppet::Resource::Catalog::Queue.subscribe do |catalog|
- # Once you have a Puppet::Resource::Catalog instance, calling save on it should suffice
+ # Once you have a Puppet::Resource::Catalog instance, passing it to save should suffice
# to put it through to the database via its active_record indirector (which is determined
# by the terminus_class = :active_record setting above)
Puppet::Util.benchmark(:notice, "Processing queued catalog for #{catalog.name}") do
begin
- catalog.save
+ Puppet::Resource::Catalog.indirection.save(catalog)
rescue => detail
puts detail.backtrace if Puppet[:trace]
Puppet.err "Could not save queued catalog for #{catalog.name}: #{detail}"
@@ -79,7 +79,7 @@ class Puppet::Application::Queue < Puppet::Application
exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs?
require 'puppet/resource/catalog'
- Puppet::Resource::Catalog.terminus_class = :active_record
+ Puppet::Resource::Catalog.indirection.terminus_class = :active_record
daemon.daemonize if Puppet[:daemonize]
@@ -87,6 +87,6 @@ class Puppet::Application::Queue < Puppet::Application
# class set up, because if storeconfigs is enabled,
# we'll get a loop of continually caching the catalog
# for storage again.
- Puppet::Resource::Catalog.cache_class = nil
+ Puppet::Resource::Catalog.indirection.cache_class = nil
end
end
diff --git a/lib/puppet/application/resource.rb b/lib/puppet/application/resource.rb
index f55caa58a..c7c1c28be 100644
--- a/lib/puppet/application/resource.rb
+++ b/lib/puppet/application/resource.rb
@@ -76,12 +76,12 @@ class Puppet::Application::Resource < Puppet::Application
text = if name
if params.empty?
- [ Puppet::Resource.find( key ) ]
+ [ Puppet::Resource.indirection.find( key ) ]
else
- [ Puppet::Resource.new( type, name, :parameters => params ).save( key ) ]
+ [ Puppet::Resource.indirection.save(Puppet::Resource.new( type, name, :parameters => params ), key) ]
end
else
- Puppet::Resource.search( key, {} )
+ Puppet::Resource.indirection.search( key, {} )
end.map(&format).join("\n")
if options[:edit]
diff --git a/lib/puppet/configurer.rb b/lib/puppet/configurer.rb
index 1c0639029..50aaa0d1f 100644
--- a/lib/puppet/configurer.rb
+++ b/lib/puppet/configurer.rb
@@ -176,7 +176,7 @@ class Puppet::Configurer
puts report.summary if Puppet[:summarize]
save_last_run_summary(report)
if Puppet[:report]
- report.save
+ Puppet::Transaction::Report.indirection.save(report)
end
rescue => detail
puts detail.backtrace if Puppet[:trace]
@@ -224,7 +224,7 @@ class Puppet::Configurer
def retrieve_catalog_from_cache(fact_options)
result = nil
@duration = thinmark do
- result = Puppet::Resource::Catalog.find(Puppet[:certname], fact_options.merge(:ignore_terminus => true))
+ result = Puppet::Resource::Catalog.indirection.find(Puppet[:certname], fact_options.merge(:ignore_terminus => true))
end
Puppet.notice "Using cached catalog"
result
@@ -237,7 +237,7 @@ class Puppet::Configurer
def retrieve_new_catalog(fact_options)
result = nil
@duration = thinmark do
- result = Puppet::Resource::Catalog.find(Puppet[:certname], fact_options.merge(:ignore_cache => true))
+ result = Puppet::Resource::Catalog.indirection.find(Puppet[:certname], fact_options.merge(:ignore_cache => true))
end
result
rescue SystemExit,NoMemoryError
diff --git a/lib/puppet/configurer/fact_handler.rb b/lib/puppet/configurer/fact_handler.rb
index 075a59458..abe032010 100644
--- a/lib/puppet/configurer/fact_handler.rb
+++ b/lib/puppet/configurer/fact_handler.rb
@@ -16,7 +16,7 @@ module Puppet::Configurer::FactHandler
# compile them and then "cache" them on the server.
begin
reload_facter
- Puppet::Node::Facts.find(Puppet[:certname])
+ Puppet::Node::Facts.indirection.find(Puppet[:certname])
rescue SystemExit,NoMemoryError
raise
rescue Exception => detail
diff --git a/lib/puppet/configurer/plugin_handler.rb b/lib/puppet/configurer/plugin_handler.rb
index 539441e75..cfc6b5a0b 100644
--- a/lib/puppet/configurer/plugin_handler.rb
+++ b/lib/puppet/configurer/plugin_handler.rb
@@ -19,8 +19,6 @@ module Puppet::Configurer::PluginHandler
begin
Puppet.info "Loading downloaded plugin #{file}"
load file
- rescue SystemExit,NoMemoryError
- raise
rescue Exception => detail
Puppet.err "Could not load downloaded file #{file}: #{detail}"
end
diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb
index 8bf1cd84d..1e7229d01 100644
--- a/lib/puppet/defaults.rb
+++ b/lib/puppet/defaults.rb
@@ -121,7 +121,7 @@ module Puppet
:hook => proc do |value|
require 'puppet/node/facts'
if value.to_s == "rest"
- Puppet::Node::Facts.cache_class = :yaml
+ Puppet::Node::Facts.indirection.cache_class = :yaml
end
end
},
@@ -152,7 +152,7 @@ module Puppet
Puppet.settings[:storeconfigs] = true
# But then we modify the configuration
- Puppet::Resource::Catalog.cache_class = :queue
+ Puppet::Resource::Catalog.indirection.cache_class = :queue
else
raise "Cannot disable asynchronous storeconfigs in a running process"
end
@@ -794,9 +794,9 @@ module Puppet
if value
require 'puppet/rails'
raise "StoreConfigs not supported without ActiveRecord 2.1 or higher" unless Puppet.features.rails?
- Puppet::Resource::Catalog.cache_class = :active_record unless Puppet.settings[:async_storeconfigs]
- Puppet::Node::Facts.cache_class = :active_record
- Puppet::Node.cache_class = :active_record
+ Puppet::Resource::Catalog.indirection.cache_class = :active_record unless Puppet.settings[:async_storeconfigs]
+ Puppet::Node::Facts.indirection.cache_class = :active_record
+ Puppet::Node.indirection.cache_class = :active_record
end
end
}
diff --git a/lib/puppet/file_bucket/dipper.rb b/lib/puppet/file_bucket/dipper.rb
index dbfcdcd43..367d6bfbd 100644
--- a/lib/puppet/file_bucket/dipper.rb
+++ b/lib/puppet/file_bucket/dipper.rb
@@ -36,7 +36,7 @@ class Puppet::FileBucket::Dipper
file_bucket_file = Puppet::FileBucket::File.new(contents, :bucket_path => @local_path, :path => absolutize_path(file) )
dest_path = "#{@rest_path}#{file_bucket_file.name}"
- file_bucket_file.save(dest_path)
+ Puppet::FileBucket::File.indirection.save(file_bucket_file, dest_path)
return file_bucket_file.checksum_data
rescue => detail
puts detail.backtrace if Puppet[:trace]
@@ -47,7 +47,7 @@ class Puppet::FileBucket::Dipper
# Retrieve a file by sum.
def getfile(sum)
source_path = "#{@rest_path}md5/#{sum}"
- file_bucket_file = Puppet::FileBucket::File.find(source_path, :bucket_path => @local_path)
+ file_bucket_file = Puppet::FileBucket::File.indirection.find(source_path, :bucket_path => @local_path)
raise Puppet::Error, "File not found" unless file_bucket_file
file_bucket_file.to_s
diff --git a/lib/puppet/indirector.rb b/lib/puppet/indirector.rb
index 5b737578b..9effc5cdd 100644
--- a/lib/puppet/indirector.rb
+++ b/lib/puppet/indirector.rb
@@ -21,7 +21,6 @@ module Puppet::Indirector
raise(ArgumentError, "Already handling indirection for #{@indirection.name}; cannot also handle #{indirection}") if @indirection
# populate this class with the various new methods
extend ClassMethods
- include InstanceMethods
include Puppet::Indirector::Envelope
extend Puppet::Network::FormatHandler
@@ -32,36 +31,5 @@ module Puppet::Indirector
module ClassMethods
attr_reader :indirection
-
- def cache_class=(klass)
- indirection.cache_class = klass
- end
-
- def terminus_class=(klass)
- indirection.terminus_class = klass
- end
-
- # Expire any cached instance.
- def expire(*args)
- indirection.expire(*args)
- end
-
- def find(*args)
- indirection.find(*args)
- end
-
- def destroy(*args)
- indirection.destroy(*args)
- end
-
- def search(*args)
- indirection.search(*args)
- end
- end
-
- module InstanceMethods
- def save(key = nil)
- self.class.indirection.save key, self
- end
end
end
diff --git a/lib/puppet/indirector/catalog/active_record.rb b/lib/puppet/indirector/catalog/active_record.rb
index fabb08eb9..365cdfefe 100644
--- a/lib/puppet/indirector/catalog/active_record.rb
+++ b/lib/puppet/indirector/catalog/active_record.rb
@@ -30,9 +30,9 @@ class Puppet::Resource::Catalog::ActiveRecord < Puppet::Indirector::ActiveRecord
host.merge_resources(catalog.vertices)
host.last_compile = Time.now
- if node = Puppet::Node.find(catalog.name)
+ if node = Puppet::Node.indirection.find(catalog.name)
host.ip = node.parameters["ipaddress"]
- host.environment = node.environment
+ host.environment = node.environment.to_s
end
host.save
diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb
index 78be4caf7..f4c40812d 100644
--- a/lib/puppet/indirector/catalog/compiler.rb
+++ b/lib/puppet/indirector/catalog/compiler.rb
@@ -23,7 +23,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
facts = Puppet::Node::Facts.convert_from(format, text_facts)
end
facts.add_timestamp
- facts.save
+ Puppet::Node::Facts.indirection.save(facts)
end
# Compile a node's catalog.
@@ -88,7 +88,7 @@ class Puppet::Resource::Catalog::Compiler < Puppet::Indirector::Code
# Turn our host name into a node object.
def find_node(name)
begin
- return nil unless node = Puppet::Node.find(name)
+ return nil unless node = Puppet::Node.indirection.find(name)
rescue => detail
puts detail.backtrace if Puppet[:trace]
raise Puppet::Error, "Failed when searching for node #{name}: #{detail}"
diff --git a/lib/puppet/indirector/indirection.rb b/lib/puppet/indirector/indirection.rb
index 9095e48f8..eb0aa8aee 100644
--- a/lib/puppet/indirector/indirection.rb
+++ b/lib/puppet/indirector/indirection.rb
@@ -247,7 +247,7 @@ class Puppet::Indirector::Indirection
# Save the instance in the appropriate terminus. This method is
# normally an instance method on the indirected class.
- def save(key, instance = nil)
+ def save(instance, key = nil)
request = request(:save, key, instance)
terminus = prepare(request)
diff --git a/lib/puppet/network/handler/filebucket.rb b/lib/puppet/network/handler/filebucket.rb
index 6aaa2df1c..55028ee64 100755
--- a/lib/puppet/network/handler/filebucket.rb
+++ b/lib/puppet/network/handler/filebucket.rb
@@ -28,12 +28,12 @@ class Puppet::Network::Handler # :nodoc:
def addfile(contents, path, client = nil, clientip = nil)
contents = Base64.decode64(contents) if client
bucket = Puppet::FileBucket::File.new(contents)
- bucket.save
+ Puppet::FileBucket::File.indirection.save(bucket)
end
# Return the contents associated with a given md5 sum.
def getfile(md5, client = nil, clientip = nil)
- bucket = Puppet::FileBucket::File.find("md5:#{md5}")
+ bucket = Puppet::FileBucket::File.indirection.find("md5:#{md5}")
contents = bucket.contents
if client
diff --git a/lib/puppet/network/handler/fileserver.rb b/lib/puppet/network/handler/fileserver.rb
index 9abc7ee1a..5b4b17a32 100755
--- a/lib/puppet/network/handler/fileserver.rb
+++ b/lib/puppet/network/handler/fileserver.rb
@@ -236,7 +236,7 @@ class Puppet::Network::Handler
unless hostname = (client || Facter.value("hostname"))
raise ArgumentError, "Could not find hostname"
end
- env = (node = Puppet::Node.find(hostname)) ? node.environment : nil
+ env = (node = Puppet::Node.indirection.find(hostname)) ? node.environment : nil
# And use the environment to look up the module.
(mod = Puppet::Node::Environment.new(env).module(module_name) and mod.files?) ? @mounts[MODULES].copy(mod.name, mod.file_directory) : nil
diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb
index c21aafafc..62aab539e 100644
--- a/lib/puppet/network/handler/master.rb
+++ b/lib/puppet/network/handler/master.rb
@@ -47,9 +47,9 @@ class Puppet::Network::Handler
client ||= facts["hostname"]
# Pass the facts to the fact handler
- Puppet::Node::Facts.new(client, facts).save unless local?
+ Puppet::Node::Facts.indirection.save(Puppet::Node::Facts.new(client, facts)) unless local?
- catalog = Puppet::Resource::Catalog.find(client)
+ catalog = Puppet::Resource::Catalog.indirection.find(client)
case format
when "yaml"
diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb
index 82238aa0a..916f02c8d 100644
--- a/lib/puppet/network/http/handler.rb
+++ b/lib/puppet/network/http/handler.rb
@@ -103,7 +103,7 @@ module Puppet::Network::HTTP::Handler
# Execute our find.
def do_find(indirection_name, key, params, request, response)
- unless result = model(indirection_name).find(key, params)
+ unless result = model(indirection_name).indirection.find(key, params)
Puppet.info("Could not find #{indirection_name} for '#{key}'")
return do_exception(response, "Could not find #{indirection_name} #{key}", 404)
end
@@ -120,7 +120,7 @@ module Puppet::Network::HTTP::Handler
# Execute our search.
def do_search(indirection_name, key, params, request, response)
model = self.model(indirection_name)
- result = model.search(key, params)
+ result = model.indirection.search(key, params)
if result.nil?
return do_exception(response, "Could not find instances in #{indirection_name} with '#{key}'", 404)
@@ -134,7 +134,7 @@ module Puppet::Network::HTTP::Handler
# Execute our destroy.
def do_destroy(indirection_name, key, params, request, response)
- result = model(indirection_name).destroy(key, params)
+ result = model(indirection_name).indirection.destroy(key, params)
return_yaml_response(response, result)
end
@@ -146,7 +146,7 @@ module Puppet::Network::HTTP::Handler
format = request_format(request)
obj = model(indirection_name).convert_from(format, data)
- result = obj.save(key)
+ result = model(indirection_name).indirection.save(obj, key)
return_yaml_response(response, result)
end
diff --git a/lib/puppet/network/http/webrick.rb b/lib/puppet/network/http/webrick.rb
index 8ed0b28ca..54bcf30c2 100644
--- a/lib/puppet/network/http/webrick.rb
+++ b/lib/puppet/network/http/webrick.rb
@@ -105,7 +105,7 @@ class Puppet::Network::HTTP::WEBrick
results[:SSLStartImmediately] = true
results[:SSLEnable] = true
- raise Puppet::Error, "Could not find CA certificate" unless Puppet::SSL::Certificate.find(Puppet::SSL::CA_NAME)
+ raise Puppet::Error, "Could not find CA certificate" unless Puppet::SSL::Certificate.indirection.find(Puppet::SSL::CA_NAME)
results[:SSLCACertificateFile] = Puppet[:localcacert]
results[:SSLVerifyClient] = OpenSSL::SSL::VERIFY_PEER
diff --git a/lib/puppet/network/rest_authconfig.rb b/lib/puppet/network/rest_authconfig.rb
index b6a163316..850f9211c 100644
--- a/lib/puppet/network/rest_authconfig.rb
+++ b/lib/puppet/network/rest_authconfig.rb
@@ -17,7 +17,6 @@ module Puppet
{ :acl => "/certificate/", :method => :find, :authenticated => false },
{ :acl => "/certificate_request", :method => [:find, :save], :authenticated => false },
{ :acl => "/status", :method => [:find], :authenticated => true },
- { :acl => "/resource", :method => [:find, :save, :search], :authenticated => true },
]
def self.main
diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb
index e8d58e6be..5b0a98615 100644
--- a/lib/puppet/node.rb
+++ b/lib/puppet/node.rb
@@ -57,7 +57,7 @@ class Puppet::Node
# Merge the node facts with parameters from the node source.
def fact_merge
- if facts = Puppet::Node::Facts.find(name)
+ if facts = Puppet::Node::Facts.indirection.find(name)
merge(facts.values)
end
rescue => detail
diff --git a/lib/puppet/node/facts.rb b/lib/puppet/node/facts.rb
index d84d54113..451813f7d 100755
--- a/lib/puppet/node/facts.rb
+++ b/lib/puppet/node/facts.rb
@@ -15,8 +15,8 @@ class Puppet::Node::Facts
# We want to expire any cached nodes if the facts are saved.
module NodeExpirer
- def save(key, instance)
- Puppet::Node.expire(instance.name)
+ def save(instance, key = nil)
+ Puppet::Node.indirection.expire(instance.name)
super
end
end
diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb
index 7dbd06240..461968245 100644
--- a/lib/puppet/provider/augeas/augeas.rb
+++ b/lib/puppet/provider/augeas/augeas.rb
@@ -213,7 +213,12 @@ Puppet::Type.type(:augeas).provide(:augeas) do
fail("Invalid command: #{cmd_array.join(" ")}") if clause_array.length != 2
comparator = clause_array.shift
arg = clause_array.shift
- return_value = (result.size.send(comparator, arg))
+ case comparator
+ when "!="
+ return_value = !(result.size.send(:==, arg))
+ else
+ return_value = (result.size.send(comparator, arg))
+ end
when "include"
arg = clause_array.shift
return_value = result.include?(arg)
diff --git a/lib/puppet/provider/host/parsed.rb b/lib/puppet/provider/host/parsed.rb
index a303c4bcf..2ba01a41c 100644
--- a/lib/puppet/provider/host/parsed.rb
+++ b/lib/puppet/provider/host/parsed.rb
@@ -22,9 +22,7 @@ Puppet::Type.type(:host).provide(:parsed,:parent => Puppet::Provider::ParsedFile
# An absent comment should match "comment => ''"
hash[:comment] = '' if hash[:comment].nil? or hash[:comment] == :absent
unless hash[:host_aliases].nil? or hash[:host_aliases] == :absent
- hash[:host_aliases] = hash[:host_aliases].split(/\s+/)
- else
- hash[:host_aliases] = []
+ hash[:host_aliases].gsub!(/\s+/,' ') # Change delimiter
end
},
:to_line => proc { |hash|
@@ -32,8 +30,8 @@ Puppet::Type.type(:host).provide(:parsed,:parent => Puppet::Provider::ParsedFile
raise ArgumentError, "#{n} is a required attribute for hosts" unless hash[n] and hash[n] != :absent
end
str = "#{hash[:ip]}\t#{hash[:name]}"
- if hash.include? :host_aliases and !hash[:host_aliases].empty?
- str += "\t#{hash[:host_aliases].join("\t")}"
+ if hash.include? :host_aliases and !hash[:host_aliases].nil? and hash[:host_aliases] != :absent
+ str += "\t#{hash[:host_aliases]}"
end
if hash.include? :comment and !hash[:comment].empty?
str += "\t# #{hash[:comment]}"
diff --git a/lib/puppet/provider/maillist/mailman.rb b/lib/puppet/provider/maillist/mailman.rb
index 633642af7..e070a25dd 100755
--- a/lib/puppet/provider/maillist/mailman.rb
+++ b/lib/puppet/provider/maillist/mailman.rb
@@ -2,11 +2,11 @@ require 'puppet/provider/parsedfile'
Puppet::Type.type(:maillist).provide(:mailman) do
if [ "CentOS", "RedHat", "Fedora" ].any? { |os| Facter.value(:operatingsystem) == os }
- commands :list_lists => "/usr/lib/mailman/bin/list_lists --bare", :rmlist => "/usr/lib/mailman/bin/rmlist", :newlist => "/usr/lib/mailman/bin/newlist"
+ commands :list_lists => "/usr/lib/mailman/bin/list_lists", :rmlist => "/usr/lib/mailman/bin/rmlist", :newlist => "/usr/lib/mailman/bin/newlist"
commands :mailman => "/usr/lib/mailman/mail/mailman"
else
# This probably won't work for non-Debian installs, but this path is sure not to be in the PATH.
- commands :list_lists => "list_lists --bare", :rmlist => "rmlist", :newlist => "newlist"
+ commands :list_lists => "list_lists", :rmlist => "rmlist", :newlist => "newlist"
commands :mailman => "/var/lib/mailman/mail/mailman"
end
@@ -14,10 +14,9 @@ Puppet::Type.type(:maillist).provide(:mailman) do
# Return a list of existing mailman instances.
def self.instances
- list_lists.split("\n").collect do |line|
- name = line.strip
- new(:ensure => :present, :name => name)
- end
+ list_lists('--bare').
+ split("\n").
+ collect { |line| new(:ensure => :present, :name => line.strip) }
end
# Prefetch our list list, yo.
diff --git a/lib/puppet/provider/zfs/solaris.rb b/lib/puppet/provider/zfs/solaris.rb
index 85d054f86..9aec9d801 100644
--- a/lib/puppet/provider/zfs/solaris.rb
+++ b/lib/puppet/provider/zfs/solaris.rb
@@ -31,7 +31,7 @@ Puppet::Type.type(:zfs).provide(:solaris) do
end
end
- [:mountpoint, :compression, :copies, :quota, :reservation, :sharenfs, :snapdir].each do |field|
+ [:mountpoint, :recordsize, :aclmode, :aclinherit, :primarycache, :secondarycache, :compression, :copies, :quota, :reservation, :sharenfs, :snapdir].each do |field|
define_method(field) do
zfs(:get, "-H", "-o", "value", field, @resource[:name]).strip
end
diff --git a/lib/puppet/provider/zone/solaris.rb b/lib/puppet/provider/zone/solaris.rb
index c11444993..a1df041cb 100644
--- a/lib/puppet/provider/zone/solaris.rb
+++ b/lib/puppet/provider/zone/solaris.rb
@@ -221,6 +221,9 @@ Puppet::Type.type(:zone).provide(:solaris) do
if dir = config["inherit-pkg-dir"]
result[:inherit] = dir.collect { |dirs| dirs[:dir] }
end
+ if datasets = config["dataset"]
+ result[:dataset] = datasets.collect { |dataset| dataset[:name] }
+ end
result[:iptype] = config[:"ip-type"]
if net = config["net"]
result[:ip] = net.collect do |params|
diff --git a/lib/puppet/ssl/certificate_authority.rb b/lib/puppet/ssl/certificate_authority.rb
index 0c226ca6a..d65067c70 100644
--- a/lib/puppet/ssl/certificate_authority.rb
+++ b/lib/puppet/ssl/certificate_authority.rb
@@ -63,7 +63,7 @@ class Puppet::SSL::CertificateAuthority
store = nil
store = autosign_store(auto) if auto != true
- Puppet::SSL::CertificateRequest.search("*").each do |csr|
+ Puppet::SSL::CertificateRequest.indirection.search("*").each do |csr|
sign(csr.name) if auto == true or store.allowed?(csr.name, "127.1.1.1")
end
end
@@ -93,10 +93,10 @@ class Puppet::SSL::CertificateAuthority
# Retrieve (or create, if necessary) the certificate revocation list.
def crl
unless defined?(@crl)
- unless @crl = Puppet::SSL::CertificateRevocationList.find(Puppet::SSL::CA_NAME)
+ unless @crl = Puppet::SSL::CertificateRevocationList.indirection.find(Puppet::SSL::CA_NAME)
@crl = Puppet::SSL::CertificateRevocationList.new(Puppet::SSL::CA_NAME)
@crl.generate(host.certificate.content, host.key.content)
- @crl.save
+ Puppet::SSL::CertificateRevocationList.indirection.save(@crl)
end
end
@crl
@@ -109,7 +109,7 @@ class Puppet::SSL::CertificateAuthority
# Generate a new certificate.
def generate(name)
- raise ArgumentError, "A Certificate already exists for #{name}" if Puppet::SSL::Certificate.find(name)
+ raise ArgumentError, "A Certificate already exists for #{name}" if Puppet::SSL::Certificate.indirection.find(name)
host = Puppet::SSL::Host.new(name)
host.generate_certificate_request
@@ -169,7 +169,7 @@ class Puppet::SSL::CertificateAuthority
# List all signed certificates.
def list
- Puppet::SSL::Certificate.search("*").collect { |c| c.name }
+ Puppet::SSL::Certificate.indirection.search("*").collect { |c| c.name }
end
# Read the next serial from the serial file, and increment the
@@ -199,14 +199,14 @@ class Puppet::SSL::CertificateAuthority
# Print a given host's certificate as text.
def print(name)
- (cert = Puppet::SSL::Certificate.find(name)) ? cert.to_text : nil
+ (cert = Puppet::SSL::Certificate.indirection.find(name)) ? cert.to_text : nil
end
# Revoke a given certificate.
def revoke(name)
raise ArgumentError, "Cannot revoke certificates when the CRL is disabled" unless crl
- if cert = Puppet::SSL::Certificate.find(name)
+ if cert = Puppet::SSL::Certificate.indirection.find(name)
serial = cert.content.serial
elsif ! serial = inventory.serial(name)
raise ArgumentError, "Could not find a serial number for #{name}"
@@ -229,7 +229,7 @@ class Puppet::SSL::CertificateAuthority
csr = self_signing_csr
issuer = csr.content
else
- unless csr = Puppet::SSL::CertificateRequest.find(hostname)
+ unless csr = Puppet::SSL::CertificateRequest.indirection.find(hostname)
raise ArgumentError, "Could not find certificate request for #{hostname}"
end
issuer = host.certificate.content
@@ -248,17 +248,17 @@ class Puppet::SSL::CertificateAuthority
# Save the now-signed cert. This should get routed correctly depending
# on the certificate type.
- cert.save
+ Puppet::SSL::Certificate.indirection.save(cert)
# And remove the CSR if this wasn't self signed.
- Puppet::SSL::CertificateRequest.destroy(csr.name) unless self_signing_csr
+ Puppet::SSL::CertificateRequest.indirection.destroy(csr.name) unless self_signing_csr
cert
end
# Verify a given host's certificate.
def verify(name)
- unless cert = Puppet::SSL::Certificate.find(name)
+ unless cert = Puppet::SSL::Certificate.indirection.find(name)
raise ArgumentError, "Could not find a certificate for #{name}"
end
store = OpenSSL::X509::Store.new
@@ -271,7 +271,7 @@ class Puppet::SSL::CertificateAuthority
end
def fingerprint(name, md = :MD5)
- unless cert = Puppet::SSL::Certificate.find(name) || Puppet::SSL::CertificateRequest.find(name)
+ unless cert = Puppet::SSL::Certificate.indirection.find(name) || Puppet::SSL::CertificateRequest.indirection.find(name)
raise ArgumentError, "Could not find a certificate or csr for #{name}"
end
cert.fingerprint(md)
@@ -279,6 +279,6 @@ class Puppet::SSL::CertificateAuthority
# List the waiting certificate requests.
def waiting?
- Puppet::SSL::CertificateRequest.search("*").collect { |r| r.name }
+ Puppet::SSL::CertificateRequest.indirection.search("*").collect { |r| r.name }
end
end
diff --git a/lib/puppet/ssl/certificate_request.rb b/lib/puppet/ssl/certificate_request.rb
index 2f6cae3f5..8c83339a1 100644
--- a/lib/puppet/ssl/certificate_request.rb
+++ b/lib/puppet/ssl/certificate_request.rb
@@ -5,7 +5,20 @@ class Puppet::SSL::CertificateRequest < Puppet::SSL::Base
wraps OpenSSL::X509::Request
extend Puppet::Indirector
- indirects :certificate_request, :terminus_class => :file
+
+ # If auto-signing is on, sign any certificate requests as they are saved.
+ module AutoSigner
+ def save(instance, key = nil)
+ super
+
+ # Try to autosign the CSR.
+ if ca = Puppet::SSL::CertificateAuthority.instance
+ ca.autosign
+ end
+ end
+ end
+
+ indirects :certificate_request, :terminus_class => :file, :extend => AutoSigner
# Convert a string into an instance.
def self.from_s(string)
@@ -46,13 +59,4 @@ class Puppet::SSL::CertificateRequest < Puppet::SSL::Base
Puppet.info "Certificate Request fingerprint (md5): #{fingerprint}"
@content
end
-
- def save(args = {})
- super()
-
- # Try to autosign the CSR.
- if ca = Puppet::SSL::CertificateAuthority.instance
- ca.autosign
- end
- end
end
diff --git a/lib/puppet/ssl/certificate_revocation_list.rb b/lib/puppet/ssl/certificate_revocation_list.rb
index 44e0a9e22..293f4b8c0 100644
--- a/lib/puppet/ssl/certificate_revocation_list.rb
+++ b/lib/puppet/ssl/certificate_revocation_list.rb
@@ -79,6 +79,6 @@ class Puppet::SSL::CertificateRevocationList < Puppet::SSL::Base
@content.sign(cakey, OpenSSL::Digest::SHA1.new)
- save
+ Puppet::SSL::CertificateRevocationList.indirection.save(self)
end
end
diff --git a/lib/puppet/ssl/host.rb b/lib/puppet/ssl/host.rb
index 8a6f0aa6d..7f71ced99 100644
--- a/lib/puppet/ssl/host.rb
+++ b/lib/puppet/ssl/host.rb
@@ -43,31 +43,31 @@ class Puppet::SSL::Host
# Configure how our various classes interact with their various terminuses.
def self.configure_indirection(terminus, cache = nil)
- Certificate.terminus_class = terminus
- CertificateRequest.terminus_class = terminus
- CertificateRevocationList.terminus_class = terminus
+ Certificate.indirection.terminus_class = terminus
+ CertificateRequest.indirection.terminus_class = terminus
+ CertificateRevocationList.indirection.terminus_class = terminus
if cache
# This is weird; we don't actually cache our keys, we
# use what would otherwise be the cache as our normal
# terminus.
- Key.terminus_class = cache
+ Key.indirection.terminus_class = cache
else
- Key.terminus_class = terminus
+ Key.indirection.terminus_class = terminus
end
if cache
- Certificate.cache_class = cache
- CertificateRequest.cache_class = cache
- CertificateRevocationList.cache_class = cache
+ Certificate.indirection.cache_class = cache
+ CertificateRequest.indirection.cache_class = cache
+ CertificateRevocationList.indirection.cache_class = cache
else
# Make sure we have no cache configured. puppet master
# switches the configurations around a bit, so it's important
# that we specify the configs for absolutely everything, every
# time.
- Certificate.cache_class = nil
- CertificateRequest.cache_class = nil
- CertificateRevocationList.cache_class = nil
+ Certificate.indirection.cache_class = nil
+ CertificateRequest.indirection.cache_class = nil
+ CertificateRevocationList.indirection.cache_class = nil
end
end
@@ -94,7 +94,7 @@ class Puppet::SSL::Host
# Remove all traces of a given host
def self.destroy(name)
- [Key, Certificate, CertificateRequest].collect { |part| part.destroy(name) }.any? { |x| x }
+ [Key, Certificate, CertificateRequest].collect { |part| part.indirection.destroy(name) }.any? { |x| x }
end
# Search for more than one host, optionally only specifying
@@ -106,7 +106,7 @@ class Puppet::SSL::Host
# Collect the results from each class, flatten them, collect all of the names, make the name list unique,
# then create a Host instance for each one.
- classlist.collect { |klass| klass.search }.flatten.collect { |r| r.name }.uniq.collect do |name|
+ classlist.collect { |klass| klass.indirection.search }.flatten.collect { |r| r.name }.uniq.collect do |name|
new(name)
end
end
@@ -117,7 +117,7 @@ class Puppet::SSL::Host
end
def key
- @key ||= Key.find(name)
+ @key ||= Key.indirection.find(name)
end
# This is the private key; we can create it from scratch
@@ -126,7 +126,7 @@ class Puppet::SSL::Host
@key = Key.new(name)
@key.generate
begin
- @key.save
+ Key.indirection.save(@key)
rescue
@key = nil
raise
@@ -135,7 +135,7 @@ class Puppet::SSL::Host
end
def certificate_request
- @certificate_request ||= CertificateRequest.find(name)
+ @certificate_request ||= CertificateRequest.indirection.find(name)
end
# Our certificate request requires the key but that's all.
@@ -144,7 +144,7 @@ class Puppet::SSL::Host
@certificate_request = CertificateRequest.new(name)
@certificate_request.generate(key.content)
begin
- @certificate_request.save
+ CertificateRequest.indirection.save(@certificate_request)
rescue
@certificate_request = nil
raise
@@ -159,8 +159,8 @@ class Puppet::SSL::Host
# get the CA cert first, since it's required for the normal cert
# to be of any use.
- return nil unless Certificate.find("ca") unless ca?
- return nil unless @certificate = Certificate.find(name)
+ return nil unless Certificate.indirection.find("ca") unless ca?
+ return nil unless @certificate = Certificate.indirection.find(name)
unless certificate_matches_key?
raise Puppet::Error, "Retrieved certificate does not match private key; please remove certificate from server and regenerate it with the current key"
@@ -212,7 +212,7 @@ class Puppet::SSL::Host
@ssl_store.add_file(Puppet[:localcacert])
# If there's a CRL, add it to our store.
- if crl = Puppet::SSL::CertificateRevocationList.find(CA_NAME)
+ if crl = Puppet::SSL::CertificateRevocationList.indirection.find(CA_NAME)
@ssl_store.flags = OpenSSL::X509::V_FLAG_CRL_CHECK_ALL|OpenSSL::X509::V_FLAG_CRL_CHECK if Puppet.settings[:certificate_revocation]
@ssl_store.add_crl(crl.content)
end
diff --git a/lib/puppet/ssl/inventory.rb b/lib/puppet/ssl/inventory.rb
index b2b402a53..e094da100 100644
--- a/lib/puppet/ssl/inventory.rb
+++ b/lib/puppet/ssl/inventory.rb
@@ -36,7 +36,7 @@ class Puppet::SSL::Inventory
f.print "# Inventory of signed certificates\n# SERIAL NOT_BEFORE NOT_AFTER SUBJECT\n"
end
- Puppet::SSL::Certificate.search("*").each { |cert| add(cert) }
+ Puppet::SSL::Certificate.indirection.search("*").each { |cert| add(cert) }
end
# Find the serial number for a given certificate.
diff --git a/lib/puppet/sslcertificates/monkey_patch.rb b/lib/puppet/sslcertificates/monkey_patch.rb
deleted file mode 100644
index 663b944c1..000000000
--- a/lib/puppet/sslcertificates/monkey_patch.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# This is the file that we use to add indirection to all the SSL Certificate classes.
-
-require 'puppet/indirector'
-
-OpenSSL::PKey::RSA.extend Puppet::Indirector
-OpenSSL::PKey::RSA.indirects :ssl_rsa, :terminus_class => :file
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index dcd9aad0a..4c0ea9ac5 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -298,7 +298,7 @@ class Puppet::Transaction
if Puppet[:report]
begin
- report.save
+ Puppet::Transaction::Report.indirection.save(report)
rescue => detail
Puppet.err "Reporting failed: #{detail}"
end
diff --git a/lib/puppet/transaction/change.rb b/lib/puppet/transaction/change.rb
index ecc3b5a5f..d57ac1917 100644
--- a/lib/puppet/transaction/change.rb
+++ b/lib/puppet/transaction/change.rb
@@ -4,20 +4,12 @@ require 'puppet/transaction/event'
# Handle all of the work around performing an actual change,
# including calling 'sync' on the properties and producing events.
class Puppet::Transaction::Change
- attr_accessor :is, :should, :property, :proxy, :auditing
+ attr_accessor :is, :should, :property, :proxy, :auditing, :old_audit_value
def auditing?
auditing
end
- # Create our event object.
- def event
- result = property.event
- result.previous_value = is
- result.desired_value = should
- result
- end
-
def initialize(property, currentvalue)
@property = property
@is = currentvalue
@@ -28,24 +20,39 @@ class Puppet::Transaction::Change
end
def apply
- return audit_event if auditing?
- return noop_event if noop?
-
- property.sync
-
- result = event
- result.message = property.change_to_s(is, should)
- result.status = "success"
- result.send_log
- result
+ event = property.event
+ event.previous_value = is
+ event.desired_value = should
+ event.historical_value = old_audit_value
+
+ if auditing? and old_audit_value != is
+ event.message = "audit change: previously recorded value #{property.is_to_s(old_audit_value)} has been changed to #{property.is_to_s(is)}"
+ event.status = "audit"
+ event.audited = true
+ brief_audit_message = " (previously recorded value was #{property.is_to_s(old_audit_value)})"
+ else
+ brief_audit_message = ""
+ end
+
+ if property.insync?(is)
+ # nothing happens
+ elsif noop?
+ event.message = "is #{property.is_to_s(is)}, should be #{property.should_to_s(should)} (noop)#{brief_audit_message}"
+ event.status = "noop"
+ else
+ property.sync
+ event.message = [ property.change_to_s(is, should), brief_audit_message ].join
+ event.status = "success"
+ end
+ event
rescue => detail
puts detail.backtrace if Puppet[:trace]
- result = event
- result.status = "failure"
+ event.status = "failure"
- result.message = "change from #{property.is_to_s(is)} to #{property.should_to_s(should)} failed: #{detail}"
- result.send_log
- result
+ event.message = "change from #{property.is_to_s(is)} to #{property.should_to_s(should)} failed: #{detail}"
+ event
+ ensure
+ event.send_log
end
# Is our property noop? This is used for generating special events.
@@ -65,23 +72,4 @@ class Puppet::Transaction::Change
def to_s
"change #{@property.change_to_s(@is, @should)}"
end
-
- private
-
- def audit_event
- # This needs to store the appropriate value, and then produce a new event
- result = event
- result.message = "audit change: previously recorded value #{property.should_to_s(should)} has been changed to #{property.is_to_s(is)}"
- result.status = "audit"
- result.send_log
- result
- end
-
- def noop_event
- result = event
- result.message = "is #{property.is_to_s(is)}, should be #{property.should_to_s(should)} (noop)"
- result.status = "noop"
- result.send_log
- result
- end
end
diff --git a/lib/puppet/transaction/event.rb b/lib/puppet/transaction/event.rb
index e5e5793da..da5b14727 100644
--- a/lib/puppet/transaction/event.rb
+++ b/lib/puppet/transaction/event.rb
@@ -7,7 +7,7 @@ class Puppet::Transaction::Event
include Puppet::Util::Tagging
include Puppet::Util::Logging
- ATTRIBUTES = [:name, :resource, :property, :previous_value, :desired_value, :status, :message, :node, :version, :file, :line, :source_description]
+ ATTRIBUTES = [:name, :resource, :property, :previous_value, :desired_value, :historical_value, :status, :message, :node, :version, :file, :line, :source_description, :audited]
attr_accessor *ATTRIBUTES
attr_writer :tags
attr_accessor :time
diff --git a/lib/puppet/transaction/report.rb b/lib/puppet/transaction/report.rb
index 1d3091428..492d15da2 100644
--- a/lib/puppet/transaction/report.rb
+++ b/lib/puppet/transaction/report.rb
@@ -10,7 +10,7 @@ class Puppet::Transaction::Report
indirects :report, :terminus_class => :processor
- attr_reader :resource_statuses, :logs, :metrics, :host, :time
+ attr_reader :resource_statuses, :logs, :metrics, :host, :time, :kind
# This is necessary since Marshall doesn't know how to
# dump hash with default proc (see below @records)
@@ -49,13 +49,14 @@ class Puppet::Transaction::Report
calculate_event_metrics
end
- def initialize
+ def initialize(kind = "apply")
@metrics = {}
@logs = []
@resource_statuses = {}
@external_times ||= {}
@host = Puppet[:certname]
@time = Time.now
+ @kind = kind
end
def name
diff --git a/lib/puppet/transaction/resource_harness.rb b/lib/puppet/transaction/resource_harness.rb
index 29ec9a539..c978e5545 100644
--- a/lib/puppet/transaction/resource_harness.rb
+++ b/lib/puppet/transaction/resource_harness.rb
@@ -25,12 +25,12 @@ class Puppet::Transaction::ResourceHarness
status.changed = true
end
- # Used mostly for scheduling at this point.
+ # Used mostly for scheduling and auditing at this point.
def cached(resource, name)
Puppet::Util::Storage.cache(resource)[name]
end
- # Used mostly for scheduling at this point.
+ # Used mostly for scheduling and auditing at this point.
def cache(resource, name, value)
Puppet::Util::Storage.cache(resource)[name] = value
end
@@ -46,33 +46,35 @@ class Puppet::Transaction::ResourceHarness
if param = resource.parameter(:ensure)
return [] if absent_and_not_being_created?(current, param)
- return [Puppet::Transaction::Change.new(param, current[:ensure])] unless ensure_is_insync?(current, param)
+ unless ensure_is_insync?(current, param)
+ audited.keys.reject{|name| name == :ensure}.each do |name|
+ resource.parameter(name).notice "audit change: previously recorded value #{audited[name]} has been changed to #{current[param]}"
+ cache(resource, name, current[param])
+ end
+ return [Puppet::Transaction::Change.new(param, current[:ensure])]
+ end
return [] if ensure_should_be_absent?(current, param)
end
- resource.properties.reject { |p| p.name == :ensure }.reject do |param|
- param.should.nil?
- end.reject do |param|
- param_is_insync?(current, param)
+ resource.properties.reject { |param| param.name == :ensure }.select do |param|
+ (audited.include?(param.name) && audited[param.name] != current[param.name]) || (param.should != nil && !param_is_insync?(current, param))
end.collect do |param|
change = Puppet::Transaction::Change.new(param, current[param.name])
change.auditing = true if audited.include?(param.name)
+ change.old_audit_value = audited[param.name]
change
end
end
def copy_audited_parameters(resource, current)
- return [] unless audit = resource[:audit]
+ return {} unless audit = resource[:audit]
audit = Array(audit).collect { |p| p.to_sym }
- audited = []
+ audited = {}
audit.find_all do |param|
- next if resource[param]
-
if value = cached(resource, param)
- resource[param] = value
- audited << param
+ audited[param] = value
else
- resource.debug "Storing newly-audited value #{current[param]} for #{param}"
+ resource.property(param).notice "audit change: newly-recorded recorded value #{current[param]}"
cache(resource, param, current[param])
end
end
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index f35a26408..b3461277c 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -587,7 +587,7 @@ Puppet::Type.newtype(:file) do
def perform_recursion(path)
- Puppet::FileServing::Metadata.search(
+ Puppet::FileServing::Metadata.indirection.search(
path,
:links => self[:links],
@@ -718,8 +718,9 @@ Puppet::Type.newtype(:file) do
mode = self.should(:mode) # might be nil
umask = mode ? 000 : 022
+ mode_int = mode ? mode.to_i(8) : nil
- content_checksum = Puppet::Util.withumask(umask) { File.open(path, 'w', mode) { |f| write_content(f) } }
+ content_checksum = Puppet::Util.withumask(umask) { File.open(path, 'w', mode_int ) { |f| write_content(f) } }
# And put our new file in place
if use_temporary_file # This is only not true when our file is empty.
diff --git a/lib/puppet/type/file/ensure.rb b/lib/puppet/type/file/ensure.rb
index 967e06aee..4a68551ee 100755
--- a/lib/puppet/type/file/ensure.rb
+++ b/lib/puppet/type/file/ensure.rb
@@ -66,7 +66,7 @@ module Puppet
end
if mode
Puppet::Util.withumask(000) do
- Dir.mkdir(@resource[:path],mode)
+ Dir.mkdir(@resource[:path], mode.to_i(8))
end
else
Dir.mkdir(@resource[:path])
diff --git a/lib/puppet/type/file/mode.rb b/lib/puppet/type/file/mode.rb
index 1ce56c843..2acd8b359 100755
--- a/lib/puppet/type/file/mode.rb
+++ b/lib/puppet/type/file/mode.rb
@@ -25,60 +25,26 @@ module Puppet
@event = :file_changed
- # Our modes are octal, so make sure they print correctly. Other
- # valid values are symbols, basically
- def is_to_s(currentvalue)
- case currentvalue
- when Integer
- return "%o" % currentvalue
- when Symbol
- return currentvalue
- else
- raise Puppet::DevError, "Invalid current value for mode: #{currentvalue.inspect}"
- end
- end
-
- def should_to_s(newvalue = @should)
- case newvalue
- when Integer
- return "%o" % newvalue
- when Symbol
- return newvalue
- else
- raise Puppet::DevError, "Invalid 'should' value for mode: #{newvalue.inspect}"
- end
- end
-
munge do |should|
- # this is pretty hackish, but i need to make sure the number is in
- # octal, yet the number can only be specified as a string right now
- value = should
- if value.is_a?(String)
- unless value =~ /^\d+$/
- raise Puppet::Error, "File modes can only be numbers, not #{value.inspect}"
- end
- # Make sure our number looks like octal.
- unless value =~ /^0/
- value = "0#{value}"
- end
- old = value
- begin
- value = Integer(value)
- rescue ArgumentError => detail
- raise Puppet::DevError, "Could not convert #{old.inspect} to integer"
+ if should.is_a?(String)
+ unless should =~ /^[0-7]+$/
+ raise Puppet::Error, "File modes can only be octal numbers, not #{should.inspect}"
end
+ should.to_i(8).to_s(8)
+ else
+ should.to_s(8)
end
-
- return value
end
# If we're a directory, we need to be executable for all cases
# that are readable. This should probably be selectable, but eh.
def dirmask(value)
if FileTest.directory?(@resource[:path])
+ value = value.to_i(8)
value |= 0100 if value & 0400 != 0
value |= 010 if value & 040 != 0
value |= 01 if value & 04 != 0
+ value = value.to_s(8)
end
value
@@ -101,7 +67,7 @@ module Puppet
unless defined?(@fixed)
@should &&= @should.collect { |s| self.dirmask(s) }
end
- return stat.mode & 007777
+ return (stat.mode & 007777).to_s(8)
else
return :absent
end
@@ -111,7 +77,7 @@ module Puppet
mode = self.should
begin
- File.chmod(mode, @resource[:path])
+ File.chmod(mode.to_i(8), @resource[:path])
rescue => detail
error = Puppet::Error.new("failed to chmod #{@resource[:path]}: #{detail.message}")
error.set_backtrace detail.backtrace
diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb
index 7d03de2b0..19dabbdc3 100755
--- a/lib/puppet/type/file/source.rb
+++ b/lib/puppet/type/file/source.rb
@@ -98,7 +98,7 @@ module Puppet
cached_attr(:content) do
raise Puppet::DevError, "No source for content was stored with the metadata" unless metadata.source
- unless tmp = Puppet::FileServing::Content.find(metadata.source)
+ unless tmp = Puppet::FileServing::Content.indirection.find(metadata.source)
fail "Could not find any content at %s" % metadata.source
end
tmp.content
@@ -148,7 +148,7 @@ module Puppet
result = nil
value.each do |source|
begin
- if data = Puppet::FileServing::Metadata.find(source)
+ if data = Puppet::FileServing::Metadata.indirection.find(source)
result = data
result.source = source
break
diff --git a/lib/puppet/type/host.rb b/lib/puppet/type/host.rb
index 1af74d886..867ef2ab3 100755
--- a/lib/puppet/type/host.rb
+++ b/lib/puppet/type/host.rb
@@ -1,3 +1,5 @@
+require 'puppet/property/ordered_list'
+
module Puppet
newtype(:host) do
ensurable
@@ -13,41 +15,24 @@ module Puppet
end
- newproperty(:host_aliases) do
+ # for now we use OrderedList to indicate that the order does matter.
+ newproperty(:host_aliases, :parent => Puppet::Property::OrderedList) do
desc "Any aliases the host might have. Multiple values must be
specified as an array."
- def insync?(is)
- is == @should
+ def delimiter
+ " "
end
- def is_to_s(currentvalue = @is)
- currentvalue = [currentvalue] unless currentvalue.is_a? Array
- currentvalue.join(" ")
- end
-
- # We actually want to return the whole array here, not just the first
- # value.
- def should
- if defined?(@should)
- if @should == [:absent]
- return :absent
- else
- return @should
- end
- else
- return nil
- end
- end
-
- def should_to_s(newvalue = @should)
- newvalue.join(" ")
+ def inclusive?
+ true
end
validate do |value|
raise Puppet::Error, "Host aliases cannot include whitespace" if value =~ /\s/
raise Puppet::Error, "Host alias cannot be an empty string. Use an empty array to delete all host_aliases " if value =~ /^\s*$/
end
+
end
newproperty(:comment) do
diff --git a/lib/puppet/type/sshkey.rb b/lib/puppet/type/sshkey.rb
index b7a1b8a8d..59a1a12f8 100755
--- a/lib/puppet/type/sshkey.rb
+++ b/lib/puppet/type/sshkey.rb
@@ -41,7 +41,7 @@ module Puppet
raise Puppet::Error, "Aliases cannot include whitespace"
end
if value =~ /,/
- raise Puppet::Error, "Aliases cannot include whitespace"
+ raise Puppet::Error, "Aliases must be provided as an array, not a comma-separated list"
end
end
end
@@ -50,6 +50,11 @@ module Puppet
desc "The host name that the key is associated with."
isnamevar
+
+ validate do |value|
+ raise Puppet::Error, "Resourcename cannot include whitespaces" if value =~ /\s/
+ raise Puppet::Error, "No comma in resourcename allowed. If you want to specify aliases use the host_aliases property" if value.include?(',')
+ end
end
newproperty(:target) do
diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb
index c8110bb69..761d5d71b 100755
--- a/lib/puppet/type/user.rb
+++ b/lib/puppet/type/user.rb
@@ -72,6 +72,11 @@ module Puppet
end
end
+ newproperty(:home) do
+ desc "The home directory of the user. The directory must be created
+ separately and is not currently checked for existence."
+ end
+
newproperty(:uid) do
desc "The user ID. Must be specified numerically. For new users
being created, if no user ID is specified then one will be
@@ -138,11 +143,6 @@ module Puppet
desc "A description of the user. Generally is a user's full name."
end
- newproperty(:home) do
- desc "The home directory of the user. The directory must be created
- separately and is not currently checked for existence."
- end
-
newproperty(:shell) do
desc "The user's login shell. The shell must exist and be
executable."
diff --git a/lib/puppet/type/zfs.rb b/lib/puppet/type/zfs.rb
index 1757931f8..be18ab5aa 100755
--- a/lib/puppet/type/zfs.rb
+++ b/lib/puppet/type/zfs.rb
@@ -12,6 +12,26 @@ module Puppet
desc "The mountpoint property."
end
+ newproperty(:recordsize) do
+ desc "The recordsize property."
+ end
+
+ newproperty(:aclmode) do
+ desc "The aclmode property."
+ end
+
+ newproperty(:aclinherit) do
+ desc "The aclinherit property."
+ end
+
+ newproperty(:primarycache) do
+ desc "The primarycache property."
+ end
+
+ newproperty(:secondarycache) do
+ desc "The secondarycache property."
+ end
+
newproperty(:compression) do
desc "The compression property."
end
diff --git a/lib/puppet/type/zone.rb b/lib/puppet/type/zone.rb
index 408d6f5dd..fc524a541 100644
--- a/lib/puppet/type/zone.rb
+++ b/lib/puppet/type/zone.rb
@@ -282,6 +282,33 @@ Puppet::Type.newtype(:zone) do
end
end
+ newproperty(:dataset, :parent => ZoneMultiConfigProperty) do
+ desc "The list of datasets delegated to the non global zone from the
+ global zone. All datasets must be zfs filesystem names which is
+ different than the mountpoint."
+
+ validate do |value|
+ unless value !~ /^\//
+ raise ArgumentError, "Datasets must be the name of a zfs filesystem"
+ end
+ end
+
+ # Add a zfs filesystem to our list of datasets.
+ def add(dataset)
+ "add dataset\nset name=#{dataset}\nend"
+ end
+
+ # Remove a zfs filesystem from our list of datasets.
+ def rm(dataset)
+ "remove dataset name=#{dataset}"
+ end
+
+ def should
+ @should
+ end
+ end
+
+
newproperty(:inherit, :parent => ZoneMultiConfigProperty) do
desc "The list of directories that the zone inherits from the global
zone. All directories must be fully qualified."
diff --git a/lib/puppet/util/command_line/filebucket b/lib/puppet/util/command_line/filebucket
index 8302d7b12..34b01508e 100755
--- a/lib/puppet/util/command_line/filebucket
+++ b/lib/puppet/util/command_line/filebucket
@@ -91,7 +91,7 @@
#
# = Copyright
#
-# Copyright (c) 2005 Reductive Labs, LLC
+# Copyright (c) 2005 Puppet Labs, LLC
# Licensed under the GNU Public License
#Puppet::Application[:filebucket].run
diff --git a/lib/puppet/util/command_line/pi b/lib/puppet/util/command_line/pi
index ae3c46e9a..3d80eea8f 100755
--- a/lib/puppet/util/command_line/pi
+++ b/lib/puppet/util/command_line/pi
@@ -42,7 +42,7 @@
#
# = Copyright
#
-# Copyright (c) 2005 Reductive Labs, LLC
+# Copyright (c) 2005 Puppet Labs, LLC
# Licensed under the GNU Public License
#Puppet::Application[:describe].run
diff --git a/lib/puppet/util/command_line/puppet b/lib/puppet/util/command_line/puppet
index 7b6c0ae7f..e75b92af8 100755
--- a/lib/puppet/util/command_line/puppet
+++ b/lib/puppet/util/command_line/puppet
@@ -63,7 +63,7 @@
#
# = Copyright
#
-# Copyright (c) 2005 Reductive Labs, LLC
+# Copyright (c) 2005 Puppet Labs, LLC
# Licensed under the GNU Public License
#Puppet::Application[:apply].run
diff --git a/lib/puppet/util/command_line/puppetca b/lib/puppet/util/command_line/puppetca
index 4f1a88da5..9aa7e907c 100755
--- a/lib/puppet/util/command_line/puppetca
+++ b/lib/puppet/util/command_line/puppetca
@@ -104,7 +104,7 @@
#
# = Copyright
#
-# Copyright (c) 2005 Reductive Labs, LLC
+# Copyright (c) 2005 Puppet Labs, LLC
# Licensed under the GNU Public License
#Puppet::Application[:cert].run
diff --git a/lib/puppet/util/command_line/puppetd b/lib/puppet/util/command_line/puppetd
index 571b15486..cb8589c5f 100755
--- a/lib/puppet/util/command_line/puppetd
+++ b/lib/puppet/util/command_line/puppetd
@@ -180,7 +180,7 @@
#
# = Copyright
#
-# Copyright (c) 2005, 2006 Reductive Labs, LLC
+# Copyright (c) 2005, 2006 Puppet Labs, LLC
# Licensed under the GNU Public License
#Puppet::Application[:agent].run
diff --git a/lib/puppet/util/command_line/puppetdoc b/lib/puppet/util/command_line/puppetdoc
index 0fa1830d6..8f24ea5ef 100755
--- a/lib/puppet/util/command_line/puppetdoc
+++ b/lib/puppet/util/command_line/puppetdoc
@@ -3,7 +3,7 @@
#
# = Synopsis
#
-# Generate a reference for all Puppet types. Largely meant for internal Reductive
+# Generate a reference for all Puppet types. Largely meant for internal Puppet
# Labs use.
#
# = Usage
@@ -61,7 +61,7 @@
#
# = Copyright
#
-# Copyright (c) 2005-2007 Reductive Labs, LLC
+# Copyright (c) 2005-2007 Puppet Labs, LLC
# Licensed under the GNU Public License
#Puppet::Application[:doc].run
diff --git a/lib/puppet/util/command_line/puppetmasterd b/lib/puppet/util/command_line/puppetmasterd
index 74efb3818..baf8a7581 100755
--- a/lib/puppet/util/command_line/puppetmasterd
+++ b/lib/puppet/util/command_line/puppetmasterd
@@ -59,7 +59,7 @@
#
# = Copyright
#
-# Copyright (c) 2005 Reductive Labs, LLC
+# Copyright (c) 2005 Puppet Labs, LLC
# Licensed under the GNU Public License
#Puppet::Application[:master].run
diff --git a/lib/puppet/util/command_line/puppetqd b/lib/puppet/util/command_line/puppetqd
index 48fc952bd..81963d537 100755
--- a/lib/puppet/util/command_line/puppetqd
+++ b/lib/puppet/util/command_line/puppetqd
@@ -47,7 +47,7 @@
#
# = Copyright
#
-# Copyright (c) 2009 Reductive Labs, LLC
+# Copyright (c) 2009 Puppet Labs, LLC
# Licensed under the GNU Public License
#Puppet::Application[:queue].run
diff --git a/lib/puppet/util/command_line/puppetrun b/lib/puppet/util/command_line/puppetrun
index 27cd775b9..7eba3b2c4 100755
--- a/lib/puppet/util/command_line/puppetrun
+++ b/lib/puppet/util/command_line/puppetrun
@@ -120,7 +120,7 @@
#
# = Copyright
#
-# Copyright (c) 2005 Reductive Labs, LLC
+# Copyright (c) 2005 Puppet Labs, LLC
# Licensed under the GNU Public License
#Puppet::Application[:kick].run
diff --git a/lib/puppet/util/command_line/ralsh b/lib/puppet/util/command_line/ralsh
index 83338fcbc..5c1f719e2 100755
--- a/lib/puppet/util/command_line/ralsh
+++ b/lib/puppet/util/command_line/ralsh
@@ -83,7 +83,7 @@
#
# = Copyright
#
-# Copyright (c) 2005-2007 Reductive Labs, LLC
+# Copyright (c) 2005-2007 Puppet Labs, LLC
# Licensed under the GNU Public License
#Puppet::Application[:resource].run
diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb
index a5aacc265..9a9e291a6 100644
--- a/lib/puppet/util/log.rb
+++ b/lib/puppet/util/log.rb
@@ -17,11 +17,12 @@ class Puppet::Util::Log
# Create a new destination type.
def self.newdesttype(name, options = {}, &block)
- dest = genclass(
- name, :parent => Puppet::Util::Log::Destination, :prefix => "Dest",
- :block => block,
- :hash => @desttypes,
-
+ dest = genclass(
+ name,
+ :parent => Puppet::Util::Log::Destination,
+ :prefix => "Dest",
+ :block => block,
+ :hash => @desttypes,
:attributes => options
)
dest.match(dest.name)