Issue #5319 has been updated by Nick Moffitt.

I ended up writing a new provider in pure cargo-cult style.  I'm not much of a 
ruby hacker, and I can't find the APIs for this sort of thing documented 
anywhere and tracing through the provider code didn't reveal too much.  This 
does appear to have all the effects I desire, per some basic smoke tests.  

<pre>
require 'puppet/provider/package'

Puppet::Type.type(:package).provide :dpkgselect, :parent => :dpkg, :source => 
:dpkg do
  desc "Package management via `dpkg --set-selections`.  Because this only
    selects the package for later installation, manual intervention such
    as an `apt-get dselect-upgrade` must be performed to satisfy the
    selection."

  def install
    hash = self.query
    if hash[:desired] == 'hold'
      raise RuntimeError, "#{self.name} is on hold."
    end

    # This is lifted straight from the dpkg provider.  For some reason I did
    # not have access to self.unhold in this class.  Go figure.
    if hash[:desired] != 'install'
      Tempfile.open('puppet_dpkg_set_selection') { |tmpfile|
        tmpfile.write("#...@resource[:name]} install\n")
        tmpfile.flush
        execute([:dpkg, "--set-selections"], :stdinfile => tmpfile.path.to_s)
      }
    end

    if hash[:status] != 'installed'
      raise RuntimeError, "#{self.name} requires an administrator to run 
'apt-get dselect-upgrade'"
    end

  end

end
</pre>

I've set this as my default provider for package resources, and packages I 
trust not to go haywire when installed noninteractively have provider => apt 
set manually.  This achieves what I set out to do far more transparently than 
the exec madness, but it uses providers to make what amounts to a dpkg provider 
policy decision.  
----------------------------------------
Feature #5319: ensure => selected for packages requiring interactive 
installation (dpkg/apt provider at least)
https://projects.puppetlabs.com/issues/5319

Author: Nick Moffitt
Status: Needs design decision
Priority: Normal
Assignee: Nigel Kersten
Category: package
Target version: 
Affected Puppet version: 
Keywords: 
Branch: 


At times there are packages with catastrophic failure modes when they are run 
noninteractively, particularly when working with dpkg.  As a result I propose 
the following option in package providers, presented from a dpkg standpoint.

If a package resource is ensure => selected, it will have exactly the same 
status behavior as ensure => installed, but the installation process will run 
'echo "${packagename} install" | /usr/bin/dpkg --set-selections'.  This will 
cause the package to be installed the next time an administrator interactively 
runs "apt-get dselect-upgrade".

This allows configuration changes for a particular package to be held back 
until that package is installed interactively.


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to