Further to freiheit's answer, here's what I ended up with.
class packages-layman {
Exec { path => '/usr/bin:/bin:/usr/sbin:/sbin', loglevel => 'debug' }
package { 'app-portage/layman': ensure => 'installed' }
file { '/etc/eix-sync.conf':
ensure => present,
content => '*',
}
line { 'layman-make.conf-overlay':
file => '/etc/make.conf',
line => 'source /var/lib/layman/make.conf',
}
exec { 'layman-list':
command => 'layman -o "http://dev.mycompany.com" -L',
require => [
Package['app-portage/layman'],
Service['openvpn']
],
}
exec { 'layman-my-overlay':
command => 'layman -o "http://dev.mycompany.com" -a myoverlay',
returns => [0,1],
require => Exec['layman-list'],
}
exec { 'layman-eix-sync':
command => 'eix-sync',
require => [
File['/etc/eix-sync.conf'],
Line['layman-make.conf-overlay'],
Exec['layman-my-overlay'],
],
}
}
Note that the 'layman-list' exec is there to overcome what appears to be a bug in the version of layman on Gentoo that prevents overlays from working until they've been listed.
Puppet can choose to run commands in any random order, so the order of the various tasks is enforced with all the require
entries. To make sure a task happens after this one, use a require
like so:
package { 'app-misc/my-custom-package':
ensure => 'installed',
require => Exec['layman-eix-sync']
}
It needs this definition of line
from the Puppet wiki to let you edit single lines of a bigger file:
define line($file, $line, $ensure = 'present') {
case $ensure {
default : { err ( "unknown ensure value ${ensure}" ) }
present: {
exec { "/bin/echo '${line}' >> '${file}'":
unless => "/bin/grep -qFx '${line}' '${file}'"
}
}
absent: {
exec { "/usr/bin/perl -ni -e 'print unless /^\\Q${line}\\E\$/' '${file}'":
onlyif => "/bin/grep -qFx '${line}' '${file}'"
}
}
}
}