Pkgsync
Pkgsync is a tool to keep the set of installed packages on a Debian or Ubuntu machine consistent. By itself, it does not have any support for classes. Pkgsync needs three files to operate: /etc/pkgsync/musthave, /etc/pkgsync/mayhave and /etc/pkgsync/maynothave, the first is a list of the packages which must be installed, the second those which may or may not be installed, the last one is the set of packages which should be removed.
You probably want to remove the -s from the pkgsync invocation to make it actually do anything useful and not just simulate installing and removing packages.
# Copyright Tollef Fog Heen <tfheen@err.no>, 2007
#
# This receipe is licenced under the same terms as Puppet itself, GPLv2 or any later version.
Exec { path => "/usr/bin:/bin:/usr/sbin:/sbin" }
class pkgsync_setup {
file { ["/etc/pkgsync/musthave", "/etc/pkgsync/mayhave", "/etc/pkgsync/maynothave"]:
ensure => present
}
file { [ "/var/lib/puppet/pkgsync", "/etc/pkgsync"]: ensure => directory }
file { "/var/lib/puppet/pkgsync/musthave.d": ensure => directory,
purge => true,
backup => false,
recurse => true,
notify => Exec[pkgsync-musthave-rebuild]
}
file { "/var/lib/puppet/pkgsync/mayhave.d": ensure => directory,
purge => true,
backup => false,
recurse => true,
notify => Exec[pkgsync-mayhave-rebuild]
}
file { "/var/lib/puppet/pkgsync/maynothave.d": ensure => directory,
purge => true,
backup => false,
recurse => true,
notify => Exec[pkgsync-maynothave-rebuild]
}
exec { "pkgsync-musthave-rebuild":
command => "find /var/lib/puppet/pkgsync/musthave.d/ -type f | xargs cat > /etc/pkgsync/musthave",
refreshonly => true,
notify => Exec[pkgsync]
}
exec { "pkgsync-mayhave-rebuild":
command => "find /var/lib/puppet/pkgsync/mayhave.d/ -type f | xargs cat > /etc/pkgsync/mayhave",
refreshonly => true,
}
exec { "pkgsync-maynothave-rebuild":
command => "find /var/lib/puppet/pkgsync/maynothave.d/ -type f | xargs cat > /etc/pkgsync/maynothave",
refreshonly => true,
}
exec { "pkgsync": refreshonly => true, command => "pkgsync -s" }
}
define pkgsync($ensure) {
include pkgsync_setup
file { "pkgsync_$ensure_$name":
name => $ensure ? {
present => "/var/lib/puppet/pkgsync/musthave.d/$name",
absent => "/var/lib/puppet/pkgsync/maynothave.d/$name",
optional => "/var/lib/puppet/pkgsync/mayhave.d/$name"
},
ensure => present,
content => "$name\n",
notify => $ensure ? {
present => Exec[pkgsync-musthave-rebuild],
absent => Exec[pkgsync-maynothave-rebuild],
optional => Exec[pkgsync-mayhave-rebuild]
}
}
}
Usage is fairly trivial:
pkgsync { [ "emacs21" ]: ensure => present
pkgsync { [ "vim" ]: ensure => absent
pkgsync { [ "joe" ]: ensure => optional
