summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-13 15:57:06 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-06-13 15:57:06 +0000
commitec0609d81cb5f2b44fce7174b72dd2c5a06dfbe6 (patch)
treea20175019bd423232062925f860f2b2fb0408c0f /lib/puppet
parent9af5d697385fd28843d1603e9e6afd272ec5e560 (diff)
downloadpuppet-ec0609d81cb5f2b44fce7174b72dd2c5a06dfbe6.tar.gz
puppet-ec0609d81cb5f2b44fce7174b72dd2c5a06dfbe6.tar.xz
puppet-ec0609d81cb5f2b44fce7174b72dd2c5a06dfbe6.zip
A round of bug-fixing in preparation for the next release.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1256 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-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
8 files changed, 65 insertions, 23 deletions
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