summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorMax Martin <max@puppetlabs.com>2011-04-27 13:27:40 -0700
committerMax Martin <max@puppetlabs.com>2011-04-27 13:27:40 -0700
commit68c82d4d8b75ebd8f0ab61b37ba78cf5fbc52081 (patch)
treed3f136373e6a10819975fa1ec0a931c1eb4afb37 /lib/puppet
parent32b13dad06195b37f0e10d13c6d2a9d958be00a7 (diff)
parent1b12b55b6a2d3581f9643bf09d55727ba1213580 (diff)
downloadpuppet-68c82d4d8b75ebd8f0ab61b37ba78cf5fbc52081.tar.gz
puppet-68c82d4d8b75ebd8f0ab61b37ba78cf5fbc52081.tar.xz
puppet-68c82d4d8b75ebd8f0ab61b37ba78cf5fbc52081.zip
Merge branch '2.7.next' into next
* 2.7.next: (#3420) Nagios "name" attribute does not output correctly (#4487) When setting environment on a host, ensure it is a string. add test for ticket 7101 (#7220) Add the ability to "inherit" options. (#6487) Add some testing for OS X version support in DirectoryService provider (#6487) Directoryservice provider will fail in future OS releases (#6368) Make the File type autorequire its nearest ancestor directory
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/interface/action.rb5
-rw-r--r--lib/puppet/interface/action_builder.rb10
-rw-r--r--lib/puppet/provider/naginator.rb10
-rw-r--r--lib/puppet/provider/nameservice/directoryservice.rb19
-rw-r--r--lib/puppet/rails/host.rb7
-rw-r--r--lib/puppet/type/file.rb10
6 files changed, 50 insertions, 11 deletions
diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb
index 08bc0a345..f8eef69b1 100644
--- a/lib/puppet/interface/action.rb
+++ b/lib/puppet/interface/action.rb
@@ -217,6 +217,11 @@ WRAPPER
option
end
+ def inherit_options_from(action)
+ options = action.options.map { |opt| action.get_option(opt, false) }
+ options.reject!(&:nil?).uniq.each { |option| add_option(option) }
+ end
+
def option?(name)
@options.include? name.to_sym
end
diff --git a/lib/puppet/interface/action_builder.rb b/lib/puppet/interface/action_builder.rb
index 2ffa38709..fd8b0856f 100644
--- a/lib/puppet/interface/action_builder.rb
+++ b/lib/puppet/interface/action_builder.rb
@@ -38,6 +38,16 @@ class Puppet::Interface::ActionBuilder
@action.add_option(option)
end
+ def inherit_options_from(action)
+ if action.is_a? Symbol
+ name = action
+ action = @face.get_action(name) or
+ raise ArgumentError, "This Face has no action named #{name}!"
+ end
+
+ @action.inherit_options_from(action)
+ end
+
def default(value = true)
@action.default = !!value
end
diff --git a/lib/puppet/provider/naginator.rb b/lib/puppet/provider/naginator.rb
index 5c610fb31..17cc24086 100644
--- a/lib/puppet/provider/naginator.rb
+++ b/lib/puppet/provider/naginator.rb
@@ -30,7 +30,15 @@ class Puppet::Provider::Naginator < Puppet::Provider::ParsedFile
end
def self.to_file(records)
- header + records.collect { |record| record.to_s }.join("\n").gsub("_naginator_name", NAME_STRING)
+ header + records.collect { |record|
+ # Remap the TYPE_name or _naginator_name params to the
+ # name if the record is a template (register == 0)
+ if record.to_s =~ /register\s+0/
+ record.to_s.sub("_naginator_name", "name").sub(record.type.to_s + "_name", "name")
+ else
+ record.to_s.sub("_naginator_name", NAME_STRING)
+ end
+ }.join("\n")
end
def self.skip_record?(record)
diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb
index c1139a679..35ac8d76a 100644
--- a/lib/puppet/provider/nameservice/directoryservice.rb
+++ b/lib/puppet/provider/nameservice/directoryservice.rb
@@ -221,11 +221,12 @@ class DirectoryService < Puppet::Provider::NameService
# have a lot of choice. Ultimately this should all be done using Ruby
# to access the DirectoryService APIs directly, but that's simply not
# feasible for a while yet.
- case self.get_macosx_version_major
- when "10.4"
- dscl_plist = self.parse_dscl_url_data(dscl_output)
- when "10.5", "10.6"
+ if self.get_macosx_version_major > "10.4"
dscl_plist = self.parse_dscl_plist_data(dscl_output)
+ elsif self.get_macosx_version_major == "10.4"
+ dscl_plist = self.parse_dscl_url_data(dscl_output)
+ else
+ fail("Puppet does not support OS X versions < 10.4")
end
self.generate_attribute_hash(dscl_plist, *type_properties)
@@ -243,12 +244,14 @@ class DirectoryService < Puppet::Provider::NameService
# different format for the -url output with objects with spaces in
# their values. *sigh*. Use -url for 10.4 in the hope this can be
# deprecated one day, and use -plist for 10.5 and higher.
- case self.get_macosx_version_major
- when "10.4"
- command_vector = [ command(:dscl), "-url", "." ]
- when "10.5", "10.6"
+ if self.get_macosx_version_major > "10.4"
command_vector = [ command(:dscl), "-plist", "." ]
+ elsif self.get_macosx_version_major == "10.4"
+ command_vector = [ command(:dscl), "-url", "." ]
+ else
+ fail("Puppet does not support OS X versions < 10.4")
end
+
# JJM: The actual action to perform. See "man dscl"
# Common actiosn: -create, -delete, -merge, -append, -passwd
command_vector << ds_action
diff --git a/lib/puppet/rails/host.rb b/lib/puppet/rails/host.rb
index b9dea2a3d..e5360217c 100644
--- a/lib/puppet/rails/host.rb
+++ b/lib/puppet/rails/host.rb
@@ -1,3 +1,4 @@
+require 'puppet/node/environment'
require 'puppet/rails'
require 'puppet/rails/resource'
require 'puppet/rails/fact_name'
@@ -28,6 +29,12 @@ class Puppet::Rails::Host < ActiveRecord::Base
host
end
+ # Override the setter for environment to force it to be a string, lest it
+ # be YAML encoded. See #4487.
+ def environment=(value)
+ super value.to_s
+ end
+
# returns a hash of fact_names.name => [ fact_values ] for this host.
# Note that 'fact_values' is actually a list of the value instances, not
# just actual values.
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 715836b22..1790c5e92 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -257,11 +257,17 @@ Puppet::Type.newtype(:file) do
newvalues(:first, :all)
end
- # Autorequire any parent directories.
+ # Autorequire the nearest ancestor directory found in the catalog.
autorequire(:file) do
basedir = ::File.dirname(self[:path])
if basedir != self[:path]
- basedir
+ parents = []
+ until basedir == parents.last
+ parents << basedir
+ basedir = File.dirname(basedir)
+ end
+ # The filename of the first ancestor found, or nil
+ parents.find { |dir| catalog.resource(:file, dir) }
else
nil
end