summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMichael Stahnke <stahnma@puppetlabs.com>2011-07-25 14:35:35 -0700
committerMichael Stahnke <stahnma@puppetlabs.com>2011-07-25 14:35:35 -0700
commitfc420008b75a482575250df4b8cd132fae061557 (patch)
treeeae97ce11910499e4ffa5c1fc31dde16edee4181 /lib
parentd19fc2b34ddbb26c68edf6890588b771ec550cfd (diff)
parente1a4fed4f3bda7f1b76d0f1c4173cfa884319728 (diff)
downloadpuppet-fc420008b75a482575250df4b8cd132fae061557.tar.gz
puppet-fc420008b75a482575250df4b8cd132fae061557.tar.xz
puppet-fc420008b75a482575250df4b8cd132fae061557.zip
Merge branch '2.7rc' into 2.7.x
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet.rb2
-rw-r--r--lib/puppet/parser/functions/regsubst.rb26
-rw-r--r--lib/puppet/parser/functions/shellquote.rb26
-rw-r--r--lib/puppet/parser/functions/sprintf.rb26
-rw-r--r--lib/puppet/provider/package/pacman.rb94
-rw-r--r--lib/puppet/type/service.rb44
6 files changed, 193 insertions, 25 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb
index c895da921..765c95cbf 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -24,7 +24,7 @@ require 'puppet/util/run_mode'
# it's also a place to find top-level commands like 'debug'
module Puppet
- PUPPETVERSION = '2.7.1'
+ PUPPETVERSION = '2.7.2'
def Puppet.version
PUPPETVERSION
diff --git a/lib/puppet/parser/functions/regsubst.rb b/lib/puppet/parser/functions/regsubst.rb
index b6bb5afcf..397d2b2ee 100644
--- a/lib/puppet/parser/functions/regsubst.rb
+++ b/lib/puppet/parser/functions/regsubst.rb
@@ -1,3 +1,29 @@
+# Copyright (C) 2009 Thomas Bellman
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THOMAS BELLMAN BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of Thomas Bellman shall
+# not be used in advertising or otherwise to promote the sale, use or
+# other dealings in this Software without prior written authorization
+# from Thomas Bellman.
+
module Puppet::Parser::Functions
newfunction(
diff --git a/lib/puppet/parser/functions/shellquote.rb b/lib/puppet/parser/functions/shellquote.rb
index 3ddb988f2..ee070c740 100644
--- a/lib/puppet/parser/functions/shellquote.rb
+++ b/lib/puppet/parser/functions/shellquote.rb
@@ -1,3 +1,29 @@
+# Copyright (C) 2009 Thomas Bellman
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THOMAS BELLMAN BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of Thomas Bellman shall
+# not be used in advertising or otherwise to promote the sale, use or
+# other dealings in this Software without prior written authorization
+# from Thomas Bellman.
+
module Puppet::Parser::Functions
Safe = 'a-zA-Z0-9@%_+=:,./-' # Safe unquoted
diff --git a/lib/puppet/parser/functions/sprintf.rb b/lib/puppet/parser/functions/sprintf.rb
index 5eb4a4f9d..118020412 100644
--- a/lib/puppet/parser/functions/sprintf.rb
+++ b/lib/puppet/parser/functions/sprintf.rb
@@ -1,3 +1,29 @@
+# Copyright (C) 2009 Thomas Bellman
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THOMAS BELLMAN BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of Thomas Bellman shall
+# not be used in advertising or otherwise to promote the sale, use or
+# other dealings in this Software without prior written authorization
+# from Thomas Bellman.
+
module Puppet::Parser::Functions
newfunction(
diff --git a/lib/puppet/provider/package/pacman.rb b/lib/puppet/provider/package/pacman.rb
new file mode 100644
index 000000000..5e05d147e
--- /dev/null
+++ b/lib/puppet/provider/package/pacman.rb
@@ -0,0 +1,94 @@
+require 'puppet/provider/package'
+
+Puppet::Type.type(:package).provide :pacman, :parent => Puppet::Provider::Package do
+ desc "Support for the Package Manager Utility (pacman) used in Archlinux."
+
+ commands :pacman => "/usr/bin/pacman"
+ defaultfor :operatingsystem => :archlinux
+ confine :operatingsystem => :archlinux
+ has_feature :upgradeable
+
+ # Install a package using 'pacman'.
+ # Installs quietly, without confirmation or progressbar, updates package
+ # list from servers defined in pacman.conf.
+ def install
+ pacman "--noconfirm", "--noprogressbar", "-Sy", @resource[:name]
+
+ unless self.query
+ raise Puppet::ExecutionFailure.new("Could not find package %s" % self.name)
+ end
+ end
+
+ def self.listcmd
+ [command(:pacman), " -Q"]
+ end
+
+ # Fetch the list of packages currently installed on the system.
+ def self.instances
+ packages = []
+ begin
+ execpipe(listcmd()) do |process|
+ # pacman -Q output is 'packagename version-rel'
+ regex = %r{^(\S+)\s(\S+)}
+ fields = [:name, :ensure]
+ hash = {}
+
+ process.each_line { |line|
+ if match = regex.match(line)
+ fields.zip(match.captures) { |field,value|
+ hash[field] = value
+ }
+
+ name = hash[:name]
+ hash[:provider] = self.name
+
+ packages << new(hash)
+ hash = {}
+ else
+ warning("Failed to match line %s" % line)
+ end
+ }
+ end
+ rescue Puppet::ExecutionFailure
+ return nil
+ end
+ packages
+ end
+
+ # Because Archlinux is a rolling release based distro, installing a package
+ # should always result in the newest release.
+ def update
+ # Install in pacman can be used for update, too
+ self.install
+ end
+
+ def latest
+ pacman "-Sy"
+ output = pacman "-Sp", "--print-format", "%v", @resource[:name]
+ output.chomp
+ end
+
+ # Querys the pacman master list for information about the package.
+ def query
+ begin
+ output = pacman("-Qi", @resource[:name])
+
+ if output =~ /Version.*:\s(.+)/
+ return { :ensure => $1 }
+ end
+ rescue Puppet::ExecutionFailure
+ return {
+ :ensure => :purged,
+ :status => 'missing',
+ :name => @resource[:name],
+ :error => 'ok',
+ }
+ end
+ nil
+ end
+
+ # Removes a package from the system.
+ def uninstall
+ pacman "--noconfirm", "--noprogressbar", "-R", @resource[:name]
+ end
+end
diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb
index 5a2c69b87..3116f5f8e 100644
--- a/lib/puppet/type/service.rb
+++ b/lib/puppet/type/service.rb
@@ -8,17 +8,15 @@ module Puppet
newtype(:service) do
@doc = "Manage running services. Service support unfortunately varies
- widely by platform --- some platforms have very little if any
- concept of a running service, and some have a very codified and
- powerful concept. Puppet's service support will generally be able
- to do the right thing regardless (e.g., if there is no
- 'status' command, then Puppet will look in the process table for a
- command matching the service name), but the more information you
- can provide, the better behaviour you will get. In particular, any
- virtual services that don't have a predictable entry in the process table
- (for example, `network` on Red Hat/CentOS systems) will manifest odd
- behavior on restarts if you don't specify `hasstatus` or a `status`
- command.
+ widely by platform --- some platforms have very little if any concept of a
+ running service, and some have a very codified and powerful concept.
+ Puppet's service support is usually capable of doing the right thing, but
+ the more information you can provide, the better behaviour you will get.
+
+ Puppet 2.7 and newer expect init scripts to have a working status command.
+ If this isn't the case for any of your services' init scripts, you will
+ need to set `hasstatus` to false and possibly specify a custom status
+ command in the `status` attribute.
Note that if a `service` receives an event from another resource,
the service will get restarted. The actual command to restart the
@@ -93,19 +91,17 @@ module Puppet
end
newparam(:hasstatus) do
- desc "Declare the the service's init script has a
- functional status command. Based on testing, it was found
- that a large number of init scripts on different platforms do
- not support any kind of status command; thus, you must specify
- manually whether the service you are running has such a
- command. Alternately, you can provide a specific command using the
- `status` attribute.
-
- If you specify neither of these, then Puppet will look for the
- service name in the process table. Be aware that 'virtual' init
- scripts such as networking will respond poorly to refresh events
- (via notify and subscribe relationships) if you don't override
- this default behavior."
+ desc "Declare whether the service's init script has a functional status
+ command; defaults to `true`. This attribute's default value changed in
+ Puppet 2.7.0.
+
+ If a service's init script does not support any kind of status command,
+ you should set `hasstatus` to false and either provide a specific
+ command using the `status` attribute or expect that Puppet will look for
+ the service name in the process table. Be aware that 'virtual' init
+ scripts (like 'network' under Red Hat systems) will respond poorly to
+ refresh events from other resources if you override the default behavior
+ without providing a status command."
newvalues(:true, :false)