summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorMax Martin <max@puppetlabs.com>2011-04-13 17:20:24 -0700
committerMax Martin <max@puppetlabs.com>2011-04-13 17:20:24 -0700
commit3ab44c7ce01ab86a995deb66228f5be95239c92a (patch)
tree90520cf62bfa2f1bb9c992bbfe1bc47ae10471f2 /lib/puppet
parent7817ccb3438ad2742a98694373e42b65df86eda7 (diff)
parentbee1ef73e5c83541edcf1249f062ba832618da48 (diff)
downloadpuppet-3ab44c7ce01ab86a995deb66228f5be95239c92a.tar.gz
puppet-3ab44c7ce01ab86a995deb66228f5be95239c92a.tar.xz
puppet-3ab44c7ce01ab86a995deb66228f5be95239c92a.zip
Merge branch '2.6.x' into next
* 2.6.x: Updated CHANGELOG for 2.6.8rc1 (#2331) Remove darwinports pkg provider, replace with rewritten macports provider Fixed #7082 - Added system support for groups (#7018) Give more context on the service type's assumptions. Wording tweaks. (#7018) explain internals better in service provider documentation maint: Fix sqlite3 require to really be optional maint: Fix sporadic sqlite error (#6818) Stop from getting Rails 3 named_scope deprecation warning (#6856) Copy dangling symlinks with 'links => manage' File resource. Conflicts (Resolved manually): lib/puppet/type/group.rb spec/unit/indirector/facts/inventory_active_record_spec.rb
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/provider/group/groupadd.rb3
-rwxr-xr-xlib/puppet/provider/package/macports.rb106
-rw-r--r--lib/puppet/rails/inventory_node.rb5
-rwxr-xr-xlib/puppet/type/file/source.rb1
-rwxr-xr-xlib/puppet/type/group.rb13
-rw-r--r--lib/puppet/type/service.rb30
6 files changed, 145 insertions, 13 deletions
diff --git a/lib/puppet/provider/group/groupadd.rb b/lib/puppet/provider/group/groupadd.rb
index 82ed4c0c7..bcc08d9f7 100644
--- a/lib/puppet/provider/group/groupadd.rb
+++ b/lib/puppet/provider/group/groupadd.rb
@@ -9,6 +9,8 @@ Puppet::Type.type(:group).provide :groupadd, :parent => Puppet::Provider::NameSe
commands :add => "groupadd", :delete => "groupdel", :modify => "groupmod"
+ has_feature :system_groups
+
verify :gid, "GID must be an integer" do |value|
value.is_a? Integer
end
@@ -21,6 +23,7 @@ Puppet::Type.type(:group).provide :groupadd, :parent => Puppet::Provider::NameSe
end
end
cmd << "-o" if @resource.allowdupe?
+ cmd << "-r" if @resource.system?
cmd << @resource[:name]
cmd
diff --git a/lib/puppet/provider/package/macports.rb b/lib/puppet/provider/package/macports.rb
new file mode 100755
index 000000000..c43eb72f3
--- /dev/null
+++ b/lib/puppet/provider/package/macports.rb
@@ -0,0 +1,106 @@
+require 'puppet/provider/package'
+
+Puppet::Type.type(:package).provide :macports, :parent => Puppet::Provider::Package do
+ desc "Package management using MacPorts on OS X.
+
+ Supports MacPorts versions and revisions, but not variants.
+ Variant preferences may be specified using the MacPorts variants.conf file
+ http://guide.macports.org/chunked/internals.configuration-files.html#internals.configuration-files.variants-conf
+
+ When specifying a version in the Puppet DSL, only specify the version, not the revision
+ Revisions are only used internally for ensuring the latest version/revision of a port.
+ "
+
+ confine :operatingsystem => :darwin
+ commands :port => "/opt/local/bin/port"
+
+ has_feature :installable
+ has_feature :uninstallable
+ has_feature :upgradeable
+ has_feature :versionable
+
+
+ def self.parse_installed_query_line(line)
+ regex = /(\S+)\s+@(\S+)_(\S+)\s+\(active\)/
+ fields = [:name, :ensure, :revision]
+ hash_from_line(line, regex, fields)
+ end
+
+ def self.parse_info_query_line(line)
+ regex = /(\S+)\s+(\S+)/
+ fields = [:version, :revision]
+ hash_from_line(line, regex, fields)
+ end
+
+ def self.hash_from_line(line, regex, fields)
+ hash = {}
+ if match = regex.match(line)
+ fields.zip(match.captures) { |field, value|
+ hash[field] = value
+ }
+ hash[:provider] = self.name
+ return hash
+ end
+ nil
+ end
+
+ def self.instances
+ packages = []
+ port("-q", :installed).each do |line|
+ if hash = parse_installed_query_line(line)
+ packages << new(hash)
+ end
+ end
+ packages
+ end
+
+ def install
+ should = @resource.should(:ensure)
+ if [:latest, :installed, :present].include?(should)
+ output = port("-q", :install, @resource[:name])
+ else
+ output = port("-q", :install, @resource[:name], "@#{should}")
+ end
+ # MacPorts now correctly exits non-zero with appropriate errors in
+ # situations where a port cannot be found or installed.
+ end
+
+ def query
+ return self.class.parse_installed_query_line(port("-q", :installed, @resource[:name]))
+ end
+
+ def latest
+ # We need both the version and the revision to be confident
+ # we've got the latest revision of a specific version
+ # Note we're still not doing anything with variants here.
+ info_line = port("-q", :info, "--line", "--version", "--revision", @resource[:name])
+ return nil if info_line == ""
+
+ if newest = self.class.parse_info_query_line(info_line)
+ current = query
+ # We're doing some fiddling behind the scenes here to cope with updated revisions.
+ # If we're already at the latest version/revision, then just return the version
+ # so the current and desired values match. Otherwise return version and revision
+ # to trigger an upgrade to the latest revision.
+ if newest[:version] == current[:ensure] and newest[:revision] == current[:revision]
+ return current[:ensure]
+ else
+ return "#{newest[:version]}_#{newest[:revision]}"
+ end
+ end
+ nil
+ end
+
+ def uninstall
+ port("-q", :uninstall, @resource[:name])
+ end
+
+ def update
+ if query[:name] == @resource[:name] # 'port upgrade' cannot install new ports
+ port("-q", :upgrade, @resource[:name])
+ else
+ install
+ end
+ end
+end
+
diff --git a/lib/puppet/rails/inventory_node.rb b/lib/puppet/rails/inventory_node.rb
index 52f8621a4..da7e61040 100644
--- a/lib/puppet/rails/inventory_node.rb
+++ b/lib/puppet/rails/inventory_node.rb
@@ -3,6 +3,11 @@ require 'puppet/rails/inventory_fact'
class Puppet::Rails::InventoryNode < ::ActiveRecord::Base
has_many :facts, :class_name => "Puppet::Rails::InventoryFact", :foreign_key => :node_id, :dependent => :delete_all
+ if Puppet::Util.activerecord_version >= 3.0
+ # Prevents "DEPRECATION WARNING: Base.named_scope has been deprecated, please use Base.scope instead"
+ ActiveRecord::NamedScope::ClassMethods.module_eval { alias :named_scope :scope }
+ end
+
named_scope :has_fact_with_value, lambda { |name,value|
{
:conditions => ["inventory_facts.name = ? AND inventory_facts.value = ?", name, value],
diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb
index d3b3a48eb..76c646baf 100755
--- a/lib/puppet/type/file/source.rb
+++ b/lib/puppet/type/file/source.rb
@@ -114,6 +114,7 @@ module Puppet
param_name = (metadata_method == :checksum) ? :content : metadata_method
next if metadata_method == :owner and !Puppet.features.root?
next if metadata_method == :checksum and metadata.ftype == "directory"
+ next if metadata_method == :checksum and metadata.ftype == "link" and metadata.links == :manage
if resource[param_name].nil? or resource[param_name] == :absent
resource[param_name] = metadata.send(metadata_method)
diff --git a/lib/puppet/type/group.rb b/lib/puppet/type/group.rb
index 2573633f9..b534ef275 100755
--- a/lib/puppet/type/group.rb
+++ b/lib/puppet/type/group.rb
@@ -1,4 +1,3 @@
-
require 'etc'
require 'facter'
require 'puppet/property/keyvalue'
@@ -19,6 +18,9 @@ module Puppet
feature :manages_aix_lam,
"The provider can manage AIX Loadable Authentication Module (LAM) system."
+ feature :system_groups,
+ "The provider allows you to create system groups with lower GIDs."
+
ensurable do
desc "Create or remove the group."
@@ -112,7 +114,7 @@ module Puppet
def membership
:attribute_membership
end
-
+
def delimiter
" "
end
@@ -132,5 +134,12 @@ module Puppet
defaultto :minimum
end
+ newparam(:system, :boolean => true) do
+ desc "Whether the group is a system group with lower GID."
+
+ newvalues(:true, :false)
+
+ defaultto false
+ end
end
end
diff --git a/lib/puppet/type/service.rb b/lib/puppet/type/service.rb
index 3ef044932..5a2c69b87 100644
--- a/lib/puppet/type/service.rb
+++ b/lib/puppet/type/service.rb
@@ -8,19 +8,24 @@ module Puppet
newtype(:service) do
@doc = "Manage running services. Service support unfortunately varies
- widely by platform -- some platforms have very little if any
+ 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 make up for any inherent shortcomings (e.g., if there is no
+ 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. Or, you can just
- use a platform that has very good service support.
+ 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.
Note that if a `service` receives an event from another resource,
the service will get restarted. The actual command to restart the
- service depends on the platform. You can provide a special command
- for restarting with the `restart` attribute."
+ service depends on the platform. You can provide an explicit command
+ for restarting with the `restart` attribute, or use the init script's
+ restart command with the `hasrestart` attribute; if you do neither,
+ the service's stop and start commands will be used."
feature :refreshable, "The provider can restart the service.",
:methods => [:restart]
@@ -93,11 +98,14 @@ module Puppet
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 (or you can specify a specific command using the
- `status` parameter).
-
- If you do not specify anything, then the service name will be
- looked for in the process table."
+ 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."
newvalues(:true, :false)