From f21162bdbae516d2613052d35a2f8bbd34d0bf86 Mon Sep 17 00:00:00 2001 From: Ian Ward Comfort Date: Thu, 17 Feb 2011 17:23:29 -0800 Subject: (#6368) Make the File type autorequire its nearest ancestor directory The File type will now autorequire the nearest ancestor directory found in the catalog, not just the file's parent directory. This is useful for setting up transitive relationships in cases when a package or other resource creates a large directory hierarchy, e.g. package { 'foo': ensure => present } file { '/var/lib/foo': require => Package['foo'] } This will make File resources at arbitrarily deep levels under /var/lib/foo automatically (transitively) require the foo package. Only the nearest ancestor is autorequired, to prevent explosion of the relationship graph. --- lib/puppet/type/file.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 963b9e5dd..da093921b 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -244,11 +244,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 -- cgit From 0008b630f8bd6c5dbeb96fd0f097dd15c22ffaf4 Mon Sep 17 00:00:00 2001 From: Gary Larizza Date: Sun, 27 Feb 2011 11:30:11 +0000 Subject: (#6487) Directoryservice provider will fail in future OS releases This commit removes a case statement in the get_exec_pramble and single_report methods. In its place is an if statement that will cause Puppet to fail if its being run on an OS X system with a version < 10.4. This if-statement will also allow Puppet to run in 10.7. Signed-off-by: Gary Larizza --- lib/puppet/provider/nameservice/directoryservice.rb | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/puppet/provider/nameservice/directoryservice.rb b/lib/puppet/provider/nameservice/directoryservice.rb index b01880360..aab491122 100644 --- a/lib/puppet/provider/nameservice/directoryservice.rb +++ b/lib/puppet/provider/nameservice/directoryservice.rb @@ -235,11 +235,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) @@ -257,12 +258,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 -- cgit From 9329a1f33b4d7df81ad8661de74f8a3656428570 Mon Sep 17 00:00:00 2001 From: Pieter van de Bruggen Date: Mon, 25 Apr 2011 12:12:24 -0700 Subject: (#7220) Add the ability to "inherit" options. Reviewed-By: Matt Robinson --- lib/puppet/interface/action.rb | 5 +++++ lib/puppet/interface/action_builder.rb | 10 ++++++++++ 2 files changed, 15 insertions(+) (limited to 'lib') 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 -- cgit From f656818bcd7cb88f24f6c578790771952120b1cc Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Tue, 26 Apr 2011 14:02:48 -0700 Subject: (#4487) When setting environment on a host, ensure it is a string. Before this change when environment strings were read out of the storeconfigs database, they were eventually converted up to Puppet::Node::Environment objects. When these objects are returned to the storeconfigs database, ActiveRecord dumps them as YAML, which begins the death-spiral of YAML. This change makes it so the host will always store the environment as a string, preventing the Puppet::Node::Environment object from being YAMLized, and stored as such in the database. This change was based on one by Richard Crowley. Paired-with: Jacob Helwig Reviewed-by: Jesse Wolfe Signed-off-by: Richard Crowley --- lib/puppet/rails/host.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') 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. -- cgit From 035240241d38e8872e4b67a6baaa43db4db64f96 Mon Sep 17 00:00:00 2001 From: Jim Pirzyk Date: Tue, 26 Apr 2011 15:43:24 -0700 Subject: (#3420) Nagios "name" attribute does not output correctly --- lib/puppet/provider/naginator.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib') 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) -- cgit