OS/X, Puppet (and boxen) and installing new software versions from DMGs (VirtualBox for me) by jgn on Tuesday, February 19, 2013 in Technology and Code

Puppet can install from an OS/X DMG. The manifest looks like this:

class virtualbox {
  package { 'VirtualBox':
    provider => 'pkgdmg',
    source => 'http://download.virtualbox.org/virtualbox/4.2.6/VirtualBox-4.2.6-82870-OSX.dmg'
  }
}

However, there is some bad news about that pkgdmg provider. Unless I am mistaken, there is no way to remove that package in such a way that Puppet believes it's gone.

This is bad because it means that Puppet won't let you install a newer version because it thinks that the package is already installed.

For instance, you can't do this:

puppet apply --execute "package { 'VirtualBox': ensure => absent, }"

Here's what you'll get:

Error: Could not set 'absent' on ensure: undefined method `uninstall' for #<Puppet::Type::Package::ProviderPkgdmg:0x1074a6228> in 1
Error: Could not set 'absent' on ensure: undefined method `uninstall' for #<Puppet::Type::Package::ProviderPkgdmg:0x1074a6228> in 1
Wrapped exception:
undefined method `uninstall' for #<Puppet::Type::Package::ProviderPkgdmg:0x1074a6228>
Error: /Stage[main]//Package[VirtualBox]/ensure: change from installed to absent failed: Could not set 'absent' on ensure: undefined method `uninstall' for #<Puppet::Type::Package::ProviderPkgdmg:0x1074a6228> in 1
Notice: Finished catalog run in 0.12 seconds

Other obvious values for "ensure" (uninstall, purge) won't work either.

What you need to do to fix this is find this file on your system: .puppet_pkgdmg_installed_VirtualBox

On my system, it's in /private/var/db/

So just remove it:

sudo rm /private/var/db/.puppet_pkgdmg_installed_VirtualBox

Then reapply your Puppet manifests (or run boxen) and you should be good to go.

comments powered by Disqus