summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/puppetca3
-rw-r--r--lib/puppet/config.rb2
-rw-r--r--lib/puppet/parser/interpreter.rb18
-rw-r--r--lib/puppet/transaction.rb23
-rw-r--r--lib/puppet/transportable.rb6
-rw-r--r--lib/puppet/type.rb20
-rwxr-xr-xlib/puppet/type/package/apt.rb12
-rwxr-xr-xlib/puppet/type/package/dpkg.rb6
-rwxr-xr-xlib/puppet/type/symlink.rb1
-rwxr-xr-xtest/executables/puppetbin.rb5
-rwxr-xr-xtest/executables/puppetca.rb2
-rwxr-xr-xtest/executables/puppetd.rb2
-rwxr-xr-xtest/executables/puppetmodule.rb2
-rwxr-xr-xtest/language/ast.rb3
-rw-r--r--test/other/transactions.rb22
-rw-r--r--test/types/package.rb3
-rwxr-xr-xtest/types/symlink.rb3
17 files changed, 101 insertions, 32 deletions
diff --git a/bin/puppetca b/bin/puppetca
index 2cbb37872..3b572c6e1 100755
--- a/bin/puppetca
+++ b/bin/puppetca
@@ -148,6 +148,9 @@ Puppet.genmanifest
begin
ca = Puppet::SSLCertificates::CA.new()
rescue => detail
+ if Puppet[:debug]
+ puts detail.backtrace
+ end
puts detail.to_s
exit(23)
end
diff --git a/lib/puppet/config.rb b/lib/puppet/config.rb
index 0569424e3..7af3a72d9 100644
--- a/lib/puppet/config.rb
+++ b/lib/puppet/config.rb
@@ -627,7 +627,7 @@ Generated on #{Time.now}.
if value =~ /\$(\w+)/
parent = $1
if pval = @parent[parent]
- newval = value.sub(/\$#{parent}/, pval)
+ newval = value.to_s.sub(/\$#{parent.to_s}/, pval.to_s)
return File.join(newval.split("/"))
else
raise Puppet::DevError, "Could not find value for %s" % parent
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index 9c74934b0..eeb0e4cca 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -15,6 +15,14 @@ module Puppet
Puppet.setdefaults("ldap",
:ldapnodes => [false,
"Whether to search for node configurations in LDAP."],
+ :ldapssl => [false,
+ "Whether SSL should be used when searching for nodes.
+ Defaults to false because SSL usually requires certificates
+ to be set up on the client side."],
+ :ldaptls => [false,
+ "Whether TLS should be used when searching for nodes.
+ Defaults to false because TLS usually requires certificates
+ to be set up on the client side."],
:ldapserver => ["ldap",
"The LDAP server. Only used if ``ldapnodes`` is enabled."],
:ldapport => [389,
@@ -114,7 +122,15 @@ module Puppet
return
end
begin
- @ldap = LDAP::Conn.new(Puppet[:ldapserver], Puppet[:ldapport])
+ if Puppet[:ldapssl]
+ @ldap = LDAP::SSLConn.new(Puppet[:ldapserver], Puppet[:ldapport])
+ elsif Puppet[:ldaptls]
+ @ldap = LDAP::SSLConn.new(
+ Puppet[:ldapserver], Puppet[:ldapport], true
+ )
+ else
+ @ldap = LDAP::Conn.new(Puppet[:ldapserver], Puppet[:ldapport])
+ end
@ldap.set_option(LDAP::LDAP_OPT_PROTOCOL_VERSION, 3)
@ldap.set_option(LDAP::LDAP_OPT_REFERRALS, LDAP::LDAP_OPT_ON)
@ldap.simple_bind(Puppet[:ldapuser], Puppet[:ldappassword])
diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb
index f5410d642..682727fe5 100644
--- a/lib/puppet/transaction.rb
+++ b/lib/puppet/transaction.rb
@@ -26,6 +26,21 @@ class Transaction
# Apply all changes for a child, returning a list of the events
# generated.
def apply(child)
+ # First make sure there are no failed dependencies
+ child.eachdependency do |dep|
+ skip = false
+ if @failures[dep] > 0
+ child.notice "Dependency %s[%s] has %s failures" %
+ [dep.class.name, dep.name, @failures[dep]]
+ skip = true
+ end
+
+ if skip
+ child.warning "Skipping because of failed dependencies"
+ return []
+ end
+ end
+
changes = child.evaluate
unless changes.is_a? Array
changes = [changes]
@@ -44,9 +59,7 @@ class Transaction
change.state.err "change from %s to %s failed: %s" %
[change.state.is_to_s, change.state.should_to_s, detail]
#Puppet.err("%s failed: %s" % [change.to_s,detail])
- if Puppet[:debug]
- puts detail.backtrace
- end
+ @failures[child] += 1
next
# FIXME this should support using onerror to determine
# behaviour; or more likely, the client calling us
@@ -166,6 +179,10 @@ class Transaction
end
@changes = []
+
+ @failures = Hash.new do |h, key|
+ h[key] = 0
+ end
end
# Roll all completed changes back.
diff --git a/lib/puppet/transportable.rb b/lib/puppet/transportable.rb
index e7459ee36..9a7cf2353 100644
--- a/lib/puppet/transportable.rb
+++ b/lib/puppet/transportable.rb
@@ -54,8 +54,6 @@ module Puppet
def to_yaml_properties
instance_variables
- #%w{ @type @name @file @line @tags }.find_all { |v|
- #}
end
def to_type(parent = nil)
@@ -68,13 +66,9 @@ module Puppet
end
else
unless retobj = typeklass.create(self)
- #Puppet.notice "Could not create %s[%s]" %
- # [self.type, self.name]
return nil
end
end
- #retobj.file = @file
- #retobj.line = @line
else
raise Puppet::Error.new("Could not find object type %s" % self.type)
end
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 78bfb955b..d51d243a2 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -176,6 +176,8 @@ class Type < Puppet::Element
# And add it to our bucket.
@types[name] = t
+
+ t
end
# Create the 'ensure' class. This is a separate method so other types
@@ -988,17 +990,23 @@ class Type < Puppet::Element
def parent=(parent)
if self.parentof?(parent)
- raise Puppet::DevError, "Objects can not be their own parents"
+ devfail "%s[%s] is already the parent of %s[%s]" %
+ [self.class.name, self.name, parent.class.name, parent.name]
end
@parent = parent
end
# Add a hook for testing for recursion.
def parentof?(child)
- if (self == child) or
- (defined? @parent and @parent.parentof?(child)) or
- @children.include?(child)
- return true
+ if (self == child)
+ debug "parent is equal to child"
+ return true
+ elsif defined? @parent and @parent.parentof?(child)
+ debug "My parent is parent of child"
+ return true
+ elsif @children.include?(child)
+ debug "child is already in children array"
+ return true
else
return false
end
@@ -1011,7 +1019,7 @@ class Type < Puppet::Element
childs.each { |child|
# Make sure we don't have any loops here.
if parentof?(child)
- raise Puppet::DevError, "Objects can not be their own parents"
+ devfail "Already the parent of %s[%s]" % [child.class.name, child.name]
end
unless child.is_a?(Puppet::Element)
self.debug "Got object of type %s" % child.class
diff --git a/lib/puppet/type/package/apt.rb b/lib/puppet/type/package/apt.rb
index f35abf8ec..b470272a8 100755
--- a/lib/puppet/type/package/apt.rb
+++ b/lib/puppet/type/package/apt.rb
@@ -17,7 +17,7 @@ module Puppet
# Add the package version
str += "=%s" % should
end
- cmd = "apt-get -q -y install %s" % str
+ cmd = "/usr/bin/apt-get -q -y install %s" % str
self.info "Executing %s" % cmd.inspect
output = %x{#{cmd} 2>&1}
@@ -29,7 +29,7 @@ module Puppet
# What's the latest package version available?
def latest
- cmd = "apt-cache showpkg %s" % self[:name]
+ cmd = "/usr/bin/apt-cache showpkg %s" % self[:name]
self.info "Executing %s" % cmd.inspect
output = %x{#{cmd} 2>&1}
@@ -65,6 +65,14 @@ module Puppet
self.install
end
+ def uninstall
+ cmd = "/usr/bin/apt-get -y -q remove %s" % self[:name]
+ output = %x{#{cmd} 2>&1}
+ if $? != 0
+ raise Puppet::PackageError.new(output)
+ end
+ end
+
def versionable?
true
end
diff --git a/lib/puppet/type/package/dpkg.rb b/lib/puppet/type/package/dpkg.rb
index c3bbc2317..c66897b8c 100755
--- a/lib/puppet/type/package/dpkg.rb
+++ b/lib/puppet/type/package/dpkg.rb
@@ -12,7 +12,7 @@ module Puppet
hash = {}
# list out our specific package
- open("| dpkg -l %s 2>/dev/null" % self[:name]) { |process|
+ open("| /usr/bin/dpkg -l %s 2>/dev/null" % self[:name]) { |process|
# our regex for matching dpkg output
regex = %r{^(.)(.)(.)\s(\S+)\s+(\S+)\s+(.+)$}
@@ -64,7 +64,7 @@ module Puppet
ENV["COLUMNS"] = "500"
# list out all of the packages
- open("| dpkg -l") { |process|
+ open("| /usr/bin/dpkg -l") { |process|
# our regex for matching dpkg output
regex = %r{^(\S+)\s+(\S+)\s+(\S+)\s+(.+)$}
fields = [:status, :name, :version, :description]
@@ -101,7 +101,7 @@ module Puppet
end
def uninstall
- cmd = "dpkg -r %s" % self[:name]
+ cmd = "/usr/bin/dpkg -r %s" % self[:name]
output = %x{#{cmd} 2>&1}
if $? != 0
raise Puppet::PackageError.new(output)
diff --git a/lib/puppet/type/symlink.rb b/lib/puppet/type/symlink.rb
index e6634a2df..9acc808a5 100755
--- a/lib/puppet/type/symlink.rb
+++ b/lib/puppet/type/symlink.rb
@@ -170,7 +170,6 @@ module Puppet
}
dir = Puppet.type(:file).implicitcreate(args)
- dir.parent = @parent
@parent.push dir
@setparent = true
end
diff --git a/test/executables/puppetbin.rb b/test/executables/puppetbin.rb
index 79fbd2358..bde9eaa8b 100755
--- a/test/executables/puppetbin.rb
+++ b/test/executables/puppetbin.rb
@@ -28,7 +28,6 @@ class TestPuppetBin < Test::Unit::TestCase
if Puppet[:debug]
cmd += " --debug"
end
- #cmd += " --fqdn %s" % fqdn
cmd += " --confdir %s" % Puppet[:confdir]
cmd += " --vardir %s" % Puppet[:vardir]
unless Puppet[:debug]
@@ -36,7 +35,7 @@ class TestPuppetBin < Test::Unit::TestCase
end
assert_nothing_raised {
- system(cmd + " " + file)
+ output = %x{#{cmd + " " + file} 2>&1}
}
assert($? == 0, "Puppet exited with code %s" % $?.to_i)
@@ -62,7 +61,7 @@ class TestPuppetBin < Test::Unit::TestCase
cmd += " -e \"#{code}\""
assert_nothing_raised {
- system(cmd)
+ out = %x{#{cmd} 2>&1}
}
assert($? == 0, "Puppet exited with code %s" % $?.to_i)
diff --git a/test/executables/puppetca.rb b/test/executables/puppetca.rb
index 1248e0345..b722c963f 100755
--- a/test/executables/puppetca.rb
+++ b/test/executables/puppetca.rb
@@ -29,7 +29,7 @@ class TestPuppetCA < Test::Unit::TestCase
if Puppet[:debug]
debug = "-d "
end
- return %x{puppetca --user=#{Puppet[:user]} #{debug} --group=#{Puppet[:group]} --confdir=#{Puppet[:confdir]} #{args} 2>&1}
+ return %x{puppetca --user=#{Puppet[:user]} #{debug} --group=#{Puppet[:group]} --confdir=#{Puppet[:confdir]} --vardir=#{Puppet[:vardir]} #{args} 2>&1}
end
diff --git a/test/executables/puppetd.rb b/test/executables/puppetd.rb
index bae91dc7d..700ea5bd3 100755
--- a/test/executables/puppetd.rb
+++ b/test/executables/puppetd.rb
@@ -34,7 +34,7 @@ class TestPuppetDExe < Test::Unit::TestCase
# and verify our daemon runs
assert_nothing_raised {
- system(cmd)
+ %x{#{cmd} 2>&1}
}
sleep 1
assert($? == 0, "Puppetd exited with code %s" % $?)
diff --git a/test/executables/puppetmodule.rb b/test/executables/puppetmodule.rb
index fcd85f42c..cff43a0e5 100755
--- a/test/executables/puppetmodule.rb
+++ b/test/executables/puppetmodule.rb
@@ -44,7 +44,7 @@ class TestPuppetModule < Test::Unit::TestCase
ENV["CFALLCLASSES"] = "yaytest:all"
assert_nothing_raised {
- system(cmd + " " + file)
+ %x{#{cmd + " " + file} 2>&1}
}
assert($? == 0, "Puppet module exited with code %s" % $?.to_i)
diff --git a/test/language/ast.rb b/test/language/ast.rb
index 8860f4ad3..caa9cf156 100755
--- a/test/language/ast.rb
+++ b/test/language/ast.rb
@@ -247,8 +247,7 @@ class TestAST < Test::Unit::TestCase
end
assert(Puppet::Type.type(:file)["/#{name}"], "Could not find '#{name}'")
end
-
- Puppet::Type.type(:file).clear
+ Puppet::Type.allclear
end
end
diff --git a/test/other/transactions.rb b/test/other/transactions.rb
index 141d1d306..e898862e6 100644
--- a/test/other/transactions.rb
+++ b/test/other/transactions.rb
@@ -330,4 +330,26 @@ class TestTransactions < Test::Unit::TestCase
assert_events([:file_changed], comp)
assert(FileTest.exists?(fname), "File did not get recreated")
end
+
+ def test_failed_reqs_mean_no_run
+ exec = Puppet::Type.type(:exec).create(
+ :command => "/bin/mkdir /this/path/cannot/possibly/exit",
+ :name => "mkdir"
+ )
+
+ file = Puppet::Type.type(:file).create(
+ :path => tempfile(),
+ :require => ["exec", "mkdir"],
+ :ensure => :file
+ )
+
+ comp = newcomp(exec, file)
+
+ comp.finalize
+
+ assert_apply(comp)
+
+ assert(! FileTest.exists?(file[:path]),
+ "File got created even tho its dependency failed")
+ end
end
diff --git a/test/types/package.rb b/test/types/package.rb
index 416754ce1..1c18fa628 100644
--- a/test/types/package.rb
+++ b/test/types/package.rb
@@ -285,6 +285,9 @@ class TestPackages < Test::Unit::TestCase
assert_apply(pkg)
pkg.retrieve
assert(pkg.insync?, "Package does not think it's in sync")
+
+ pkg[:ensure] = :absent
+ assert_apply(pkg)
}
end
diff --git a/test/types/symlink.rb b/test/types/symlink.rb
index ace726ac5..c44668448 100755
--- a/test/types/symlink.rb
+++ b/test/types/symlink.rb
@@ -41,6 +41,7 @@ class TestSymlink < Test::Unit::TestCase
unless hash.include?(:ensure)
hash[:ensure] = mktmpfile()
end
+
link = Puppet.type(:symlink).create(hash)
return link
end
@@ -73,7 +74,7 @@ class TestSymlink < Test::Unit::TestCase
assert_nothing_raised {
link = newlink(:ensure => source, :recurse => true)
}
- comp = newcomp("linktest",link)
+ comp = newcomp(link)
cycle(comp)
path = link.name