summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-07-08 15:03:13 -0500
committerLuke Kanies <luke@madstop.com>2008-07-08 15:03:13 -0500
commitc1dc92b9a14c04096e0bed0f2c4acc4dfe1ed7d2 (patch)
treeb3269b4e76edbcb3458fcdf1832421fb11e57890 /lib/puppet
parentb0febd263c0cb8e61d512898f7c79868ea77e619 (diff)
parentedf99c508dabb58342eeff251ad5701d2755426d (diff)
downloadpuppet-c1dc92b9a14c04096e0bed0f2c4acc4dfe1ed7d2.tar.gz
puppet-c1dc92b9a14c04096e0bed0f2c4acc4dfe1ed7d2.tar.xz
puppet-c1dc92b9a14c04096e0bed0f2c4acc4dfe1ed7d2.zip
Merge branch '0.24.x'
Conflicts: CHANGELOG
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/parser/ast/function.rb2
-rw-r--r--lib/puppet/parser/functions.rb8
-rw-r--r--lib/puppet/provider/group/ldap.rb9
-rwxr-xr-xlib/puppet/provider/package/gem.rb45
-rw-r--r--lib/puppet/provider/user/ldap.rb16
5 files changed, 67 insertions, 13 deletions
diff --git a/lib/puppet/parser/ast/function.rb b/lib/puppet/parser/ast/function.rb
index 63d7c7abf..eb36fa906 100644
--- a/lib/puppet/parser/ast/function.rb
+++ b/lib/puppet/parser/ast/function.rb
@@ -42,7 +42,7 @@ class Puppet::Parser::AST
raise Puppet::DevError, "Invalid function type %s" % @ftype.inspect
end
- # Lastly, check the arity
+ # Lastly, check the parity
end
end
end
diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb
index 8decb8227..51903e919 100644
--- a/lib/puppet/parser/functions.rb
+++ b/lib/puppet/parser/functions.rb
@@ -317,6 +317,14 @@ module Functions
end
output
end
+
+ newfunction(:sha1, :type => :rvalue,
+ :doc => "Returns a SHA1 hash value from a provided string.") do |args|
+ require 'sha1'
+
+ Digest::SHA1.hexdigest(args[0])
+ end
+
end
end
diff --git a/lib/puppet/provider/group/ldap.rb b/lib/puppet/provider/group/ldap.rb
index a4870fc68..37a7e7343 100644
--- a/lib/puppet/provider/group/ldap.rb
+++ b/lib/puppet/provider/group/ldap.rb
@@ -36,4 +36,13 @@ Puppet::Type.type(:group).provide :ldap, :parent => Puppet::Provider::Ldap do
largest + 1
end
+ # Convert a group name to an id.
+ def self.name2id(group)
+ return nil unless result = manager.search("cn=%s" % group) and result.length > 0
+
+ # Only use the first result.
+ group = result[0]
+ gid = group[:gid][0]
+ return gid
+ end
end
diff --git a/lib/puppet/provider/package/gem.rb b/lib/puppet/provider/package/gem.rb
index bb09bc5b0..133243c86 100755
--- a/lib/puppet/provider/package/gem.rb
+++ b/lib/puppet/provider/package/gem.rb
@@ -1,9 +1,12 @@
require 'puppet/provider/package'
+require 'uri'
# Ruby gems support.
Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package do
- desc "Ruby Gem support. By default uses remote gems, but you can specify
- the path to a local gem via ``source``."
+ desc "Ruby Gem support. If a URL is passed via ``source``, then that URL is used as the
+ remote gem repository; if a source is present but is not a valid URL, it will be
+ interpreted as the path to a local gem file. If source is not present at all,
+ the gem will be installed from the default gem repositories."
has_feature :versionable
@@ -65,20 +68,38 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
end
def install(useversion = true)
- command = ["install"]
- if (! @resource.should(:ensure).is_a? Symbol) and useversion
- command << "-v" << @resource.should(:ensure)
+ command = [command(:gemcmd), "install"]
+ if (! resource[:ensure].is_a? Symbol) and useversion
+ command << "-v" << resource[:ensure]
end
# Always include dependencies
command << "--include-dependencies"
- if source = @resource[:source]
- command << source
+ if source = resource[:source]
+ begin
+ uri = URI.parse(source)
+ rescue => detail
+ fail "Invalid source '%s': %s" % [uri, detail]
+ end
+
+ case uri.scheme
+ when nil:
+ # no URI scheme => interpret the source as a local file
+ command << source
+ when /file/i
+ command << uri.path
+ when 'puppet'
+ # we don't support puppet:// URLs (yet)
+ raise Puppet::Error.new("puppet:// URLs are not supported as gem sources")
+ else
+ # interpret it as a gem repository
+ command << "--source" << "#{source}" << resource[:name]
+ end
else
- command << @resource[:name]
+ command << resource[:name]
end
- output = gemcmd(*command)
+ output = execute(command)
# Apparently some stupid gem versions don't exit non-0 on failure
if output.include?("ERROR")
self.fail "Could not install: %s" % output.chomp
@@ -87,17 +108,17 @@ Puppet::Type.type(:package).provide :gem, :parent => Puppet::Provider::Package d
def latest
# This always gets the latest version available.
- hash = self.class.gemlist(:justme => @resource[:name])
+ hash = self.class.gemlist(:justme => resource[:name])
return hash[:ensure]
end
def query
- self.class.gemlist(:justme => @resource[:name], :local => true)
+ self.class.gemlist(:justme => resource[:name], :local => true)
end
def uninstall
- gemcmd "uninstall", "-x", "-a", @resource[:name]
+ gemcmd "uninstall", "-x", "-a", resource[:name]
end
def update
diff --git a/lib/puppet/provider/user/ldap.rb b/lib/puppet/provider/user/ldap.rb
index 0d149ac9a..2e200a88e 100644
--- a/lib/puppet/provider/user/ldap.rb
+++ b/lib/puppet/provider/user/ldap.rb
@@ -14,6 +14,8 @@ Puppet::Type.type(:user).provide :ldap, :parent => Puppet::Provider::Ldap do
confine :feature => :ldap, :false => (Puppet[:ldapuser] == "")
+ has_feature :manages_passwords
+
manages(:posixAccount, :person).at("ou=People").named_by(:uid).and.maps :name => :uid,
:password => :userPassword,
:comment => :cn,
@@ -45,6 +47,15 @@ Puppet::Type.type(:user).provide :ldap, :parent => Puppet::Provider::Ldap do
largest + 1
end
+ # Convert our gid to a group name, if necessary.
+ def gid=(value)
+ unless [Fixnum, Bignum].include?(value.class)
+ value = group2id(value)
+ end
+
+ @property_hash[:gid] = value
+ end
+
# Find all groups this user is a member of in ldap.
def groups
# We want to cache the current result, so we know if we
@@ -101,6 +112,11 @@ Puppet::Type.type(:user).provide :ldap, :parent => Puppet::Provider::Ldap do
end
end
+ # Convert a gropu name to an id.
+ def group2id(group)
+ Puppet::Type.type(:group).provider(:ldap).name2id(group)
+ end
+
private
def group_manager