Hi,
the handling/managing of service flags, and package flavors is a bit
flawed in the current puppet.
With regard to services, they are started before the flags are
given to rc.conf.local.
With regard to packages, flavors are not always enforced, esp. when
you manage with packages that have dependencies with flavors...
Esp. on initial configuration, you should recognize the service now
running with the flags written to rc.conf.local
When you have flavored packages installed/managed, run
puppet resource package before and after upgrade. You should then
see the flavor as listed in the output.
Attached patch tries to address both issues, can puppet users throw
that onto their environment.
Generally works well for me. success/failure reports please ;)
cheers,
Sebastian
Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/ruby-puppet/3/Makefile,v
retrieving revision 1.105
diff -u -p -u -r1.105 Makefile
--- Makefile 30 Jan 2015 10:19:27 -0000 1.105
+++ Makefile 6 Feb 2015 19:18:40 -0000
@@ -1,6 +1,7 @@
# $OpenBSD: Makefile,v 1.105 2015/01/30 10:19:27 jasper Exp $
VERSION= 3.7.4
+REVISION= 0
RUN_DEPENDS+= archivers/gtar \
devel/ruby-rgen,${MODRUBY_FLAVOR}
Index: patches/patch-lib_puppet_provider_package_openbsd_rb
===================================================================
RCS file:
/cvs/ports/sysutils/ruby-puppet/3/patches/patch-lib_puppet_provider_package_openbsd_rb,v
retrieving revision 1.27
diff -u -p -u -r1.27 patch-lib_puppet_provider_package_openbsd_rb
--- patches/patch-lib_puppet_provider_package_openbsd_rb 6 Nov 2014
20:28:16 -0000 1.27
+++ patches/patch-lib_puppet_provider_package_openbsd_rb 6 Feb 2015
19:18:40 -0000
@@ -5,9 +5,92 @@ From: Jasper Lievisse Adriaanse <jasper@
Date: Wed, 29 Oct 2014 16:23:39 +0100
Subject: [PATCH] (PUP-3604) Rework handling of :ensure with a version
---- lib/puppet/provider/package/openbsd.rb.orig Mon Nov 3 23:23:13 2014
-+++ lib/puppet/provider/package/openbsd.rb Thu Nov 6 21:27:12 2014
-@@ -149,18 +149,7 @@ Puppet::Type.type(:package).provide :openbsd, :parent
+The flavor of a package is a property, not a parameter, therefore, add
+a new feature :flavorable, and make the code a bit easier.
+Is now also a bit more performat, since the implementation of self.prefetch
+
+--- lib/puppet/provider/package/openbsd.rb.orig Tue Jan 27 00:46:47 2015
++++ lib/puppet/provider/package/openbsd.rb Fri Feb 6 20:13:57 2015
+@@ -20,48 +20,49 @@ Puppet::Type.type(:package).provide :openbsd, :parent
+ has_feature :install_options
+ has_feature :uninstall_options
+ has_feature :upgradeable
++ has_feature :flavorable
+
++ mk_resource_methods
++
+ def self.instances
+- packages = []
++ # our regex for matching pkg_info output
++ regex = /^(.*)-(\d[^-]*)[-]?(\w*)(.*)$/
++ fields = [:name, :ensure, :flavor ]
+
+ begin
+- execpipe(listcmd) do |process|
+- # our regex for matching pkg_info output
+- regex = /^(.*)-(\d[^-]*)[-]?(\w*)(.*)$/
+- fields = [:name, :ensure, :flavor ]
+- hash = {}
+-
+- # now turn each returned line into a package object
+- process.each_line { |line|
+- if match = regex.match(line.split[0])
+- fields.zip(match.captures) { |field,value|
+- hash[field] = value
+- }
+-
+- hash[:provider] = self.name
+-
+- packages << new(hash)
+- hash = {}
+- else
+- unless line =~ /Updating the pkgdb/
+- # Print a warning on lines we can't match, but move
+- # on, since it should be non-fatal
+- warning("Failed to match line #{line}")
+- end
++ packages = pkginfo('-a')
++ packages.split("\n").collect do |package|
++ if match = regex.match(package.split[0])
++ new( :name => match.captures[0],
++ :ensure => match.captures[1],
++ :flavor => match.captures[2],
++ )
++ else
++ unless line =~ /Updating the pkgdb/
++ # Print a warning on lines we can't match, but move
++ # on, since it should be non-fatal
++ warning("Failed to match line #{line}")
+ end
+- }
++ end
+ end
+-
+- return packages
+ rescue Puppet::ExecutionFailure
+ return nil
+ end
+ end
+
+- def self.listcmd
+- [command(:pkginfo), "-a"]
++ def self.prefetch(resources)
++ packages = instances
++ resources.keys.each do |name|
++ if provider = packages.find{ |pkg| pkg.name == name }
++ resources[name].provider = provider
++ end
++ end
+ end
+
++ def flavor=(value)
++ install
++ end
++
+ def latest
+ parse_pkgconf
+
+@@ -149,31 +150,46 @@ Puppet::Type.type(:package).provide :openbsd, :parent
if @resource[:source][-1,1] == ::File::SEPARATOR
e_vars = { 'PKG_PATH' => @resource[:source] }
@@ -27,7 +110,15 @@ Subject: [PATCH] (PUP-3604) Rework handl
else
e_vars = {}
full_name = @resource[:source]
-@@ -174,6 +163,31 @@ Puppet::Type.type(:package).provide :openbsd, :parent
+ end
+
++ cmd << '-r'
+ cmd << install_options
+ cmd << full_name
+
+ if latest
+- cmd.unshift('-rz')
++ cmd.unshift('-z')
end
Puppet::Util.withenv(e_vars) { pkgadd cmd.flatten.compact }
Index: patches/patch-lib_puppet_provider_service_openbsd_rb
===================================================================
RCS file:
/cvs/ports/sysutils/ruby-puppet/3/patches/patch-lib_puppet_provider_service_openbsd_rb,v
retrieving revision 1.24
diff -u -p -u -r1.24 patch-lib_puppet_provider_service_openbsd_rb
--- patches/patch-lib_puppet_provider_service_openbsd_rb 28 Jan 2015
08:43:50 -0000 1.24
+++ patches/patch-lib_puppet_provider_service_openbsd_rb 6 Feb 2015
19:18:40 -0000
@@ -12,9 +12,13 @@ $OpenBSD: patch-lib_puppet_provider_serv
* https://github.com/puppetlabs/puppet/pull/3510
---- lib/puppet/provider/service/openbsd.rb.orig Mon Nov 3 23:23:13 2014
-+++ lib/puppet/provider/service/openbsd.rb Wed Jan 28 10:34:13 2015
-@@ -2,341 +2,98 @@ Puppet::Type.type(:service).provide :openbsd, :parent
+* start command with the right flags, if flags are given
+
+* fix output of "puppet resource service"
+
+--- lib/puppet/provider/service/openbsd.rb.orig Tue Jan 27 00:46:47 2015
++++ lib/puppet/provider/service/openbsd.rb Tue Feb 3 19:36:34 2015
+@@ -2,341 +2,108 @@ Puppet::Type.type(:service).provide :openbsd, :parent
desc "Provider for OpenBSD's rc.d daemon control scripts"
@@ -30,6 +34,15 @@ $OpenBSD: patch-lib_puppet_provider_serv
- def self.defpath
- ["/etc/rc.d"]
+ def startcmd
++ if @resource[:flags] and flags != @resource[:flags]
++ # Unfortunately, the startcmd gets called, before
++ # the service is enabled (in case its supposed to be enabled).
++ # Setting flags via rcctl is only possible, when the service is enabled
++ # In case the service is not to be enabled, it will be automatically
++ # disabled later in the same puppet run.
++ self.enable
++ self.flags = @resource[:flags]
++ end
+ [command(:rcctl), '-f', :start, @resource[:name]]
end
@@ -159,6 +172,7 @@ $OpenBSD: patch-lib_puppet_provider_serv
+ execpipe([command(:rcctl), :getall]) do |process|
+ process.each_line do |line|
+ match = /^(.*?)(?:_flags)?=(.*)$/.match(line)
++ next if match[1].match(/.*?_timeout$|.*?_user$/)
+ attributes_hash = {
+ :name => match[1],
+ :flags => match[2],
Index: patches/patch-lib_puppet_type_package_rb
===================================================================
RCS file: patches/patch-lib_puppet_type_package_rb
diff -N patches/patch-lib_puppet_type_package_rb
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-lib_puppet_type_package_rb 6 Feb 2015 19:18:40 -0000
@@ -0,0 +1,25 @@
+$OpenBSD$
+
+The flavor of a package is a property, not a parameter, therefore, add
+a new feature :flavorable, and only have the :flavor property when
+feature :flavorable.
+
+--- lib/puppet/type/package.rb.orig Fri Feb 6 20:13:15 2015
++++ lib/puppet/type/package.rb Fri Feb 6 20:13:30 2015
+@@ -56,6 +56,7 @@ module Puppet
+ provider-specific.",
+ :methods => [:package_settings_insync?, :package_settings,
:package_settings=]
+ feature :virtual_packages, "The provider accepts virtual package names
for install and uninstall."
++ feature :flavorable, "The provider accepts package flavors."
+
+ ensurable do
+ desc <<-EOT
+@@ -371,7 +372,7 @@ module Puppet
+ newvalues(:true, :false)
+ end
+
+- newparam(:flavor) do
++ newproperty(:flavor, :required_features => :flavorable) do
+ desc "OpenBSD supports 'flavors', which are further specifications for
+ which type of package you want."
+ end