summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/puppet/provider/parsedfile.rb2
-rwxr-xr-xlib/puppet/type/cron.rb31
-rwxr-xr-xlib/puppet/type/exec.rb64
-rwxr-xr-xlib/puppet/type/pfile/ensure.rb2
-rw-r--r--lib/puppet/util/fileparsing.rb2
5 files changed, 60 insertions, 41 deletions
diff --git a/lib/puppet/provider/parsedfile.rb b/lib/puppet/provider/parsedfile.rb
index 3c1ee0943..8d1936ceb 100755
--- a/lib/puppet/provider/parsedfile.rb
+++ b/lib/puppet/provider/parsedfile.rb
@@ -135,7 +135,7 @@ class Puppet::Provider::ParsedFile < Puppet::Provider
define_method(attr.to_s + "=") do |val|
# Mark that this target was modified.
- modeltarget = @model[:target] || self.class.default_target
+ modeltarget = @model.should(:target) || self.class.default_target
# If they're the same, then just mark that one as modified
if @property_hash[:target] and @property_hash[:target] == modeltarget
diff --git a/lib/puppet/type/cron.rb b/lib/puppet/type/cron.rb
index dd9ed3ab5..ccf5d0449 100755
--- a/lib/puppet/type/cron.rb
+++ b/lib/puppet/type/cron.rb
@@ -105,6 +105,14 @@ Puppet::Type.newtype(:cron) do
end
end
+ def is=(val)
+ if val.is_a?(Array)
+ @is = val
+ else
+ @is = [val]
+ end
+ end
+
def is_to_s
if @is
unless @is.is_a?(Array)
@@ -122,7 +130,16 @@ Puppet::Type.newtype(:cron) do
end
def should
- @should
+ if @should and @should[0] == :absent
+ :absent
+ else
+ @should
+ end
+ end
+
+ def should=(ary)
+ super
+ @should.flatten!
end
# The method that does all of the actual parameter value
@@ -189,6 +206,14 @@ Puppet::Type.newtype(:cron) do
All cron parameters support ``absent`` as a value; this will
remove any existing values for that field."
+ def is
+ if @is
+ @is[0]
+ else
+ nil
+ end
+ end
+
def should
if @should
if @should.is_a? Array
@@ -352,10 +377,10 @@ Puppet::Type.newtype(:cron) do
name = symbolize(name)
ret = nil
if obj = @parameters[name]
- ret = obj.should_to_s
+ ret = obj.should
if ret.nil?
- ret = obj.is_to_s
+ ret = obj.is
end
if ret == :absent
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb
index 33796b129..fd85d1202 100755
--- a/lib/puppet/type/exec.rb
+++ b/lib/puppet/type/exec.rb
@@ -83,39 +83,6 @@ module Puppet
return "executed successfully"
end
- # Verify that we have the executable
- def checkexe
- cmd = self.parent[:command]
- if cmd =~ /^\//
- exe = cmd.split(/ /)[0]
- unless FileTest.exists?(exe)
- self.fail(
- "Could not find executable %s" % exe
- )
- end
- unless FileTest.executable?(exe)
- self.fail(
- "%s is not executable" % exe
- )
- end
- elsif path = self.parent[:path]
- exe = cmd.split(/ /)[0]
- withenv :PATH => self.parent[:path].join(":") do
- path = %{which #{exe}}.chomp
- if path == ""
- self.fail(
- "Could not find command '%s'" % exe
- )
- end
- end
- else
- self.fail(
- "%s is somehow not qualified with no search path" %
- self.parent[:command]
- )
- end
- end
-
# First verify that all of our checks pass.
def retrieve
# Default to somethinng
@@ -131,8 +98,6 @@ module Puppet
def sync
olddir = nil
- self.checkexe
-
# We need a dir to change to, even if it's just the cwd
dir = self.parent[:cwd] || Dir.pwd
@@ -493,6 +458,33 @@ module Puppet
return true
end
+ # Verify that we have the executable
+ def checkexe(cmd)
+ if cmd =~ /^\//
+ exe = cmd.split(/ /)[0]
+ unless FileTest.exists?(exe)
+ raise ArgumentError, "Could not find executable %s" % exe
+ end
+ unless FileTest.executable?(exe)
+ raise ArgumentError,
+ "%s is not executable" % exe
+ end
+ elsif path = self[:path]
+ exe = cmd.split(/ /)[0]
+ withenv :PATH => self[:path].join(":") do
+ path = %{which #{exe}}.chomp
+ if path == ""
+ raise ArgumentError,
+ "Could not find command '%s'" % exe
+ end
+ end
+ else
+ raise ArgumentError,
+ "%s is somehow not qualified with no search path" %
+ self[:command]
+ end
+ end
+
def output
if self.property(:returns).nil?
return nil
@@ -519,6 +511,8 @@ module Puppet
dir = nil
+ checkexe(command)
+
if dir = self[:cwd]
unless File.directory?(dir)
if check
diff --git a/lib/puppet/type/pfile/ensure.rb b/lib/puppet/type/pfile/ensure.rb
index bb4b3d27a..ea4154f80 100755
--- a/lib/puppet/type/pfile/ensure.rb
+++ b/lib/puppet/type/pfile/ensure.rb
@@ -109,7 +109,7 @@ module Puppet
end
def change_to_s
- if property = (@parent.property(:content) || @parent.property(:source))
+ if property = (@parent.property(:content) || @parent.property(:source)) and ! property.insync?
return property.change_to_s
else
super
diff --git a/lib/puppet/util/fileparsing.rb b/lib/puppet/util/fileparsing.rb
index 6b59975ab..6ffb69503 100644
--- a/lib/puppet/util/fileparsing.rb
+++ b/lib/puppet/util/fileparsing.rb
@@ -82,7 +82,7 @@ module Puppet::Util::FileParsing
fields.collect { |field|
# If the field is marked absent, use the appropriate replacement
- if details[field] == :absent or details[field].nil?
+ if details[field] == :absent or details[field] == [:absent] or details[field].nil?
if self.optional.include?(field)
self.absent
else