I would like to install multiple packages by using the command zypper with puppet. I created my own repository and dumped some bacula packages in there. My manifest is as follows:
#cat manifests/init.pp
class bacula()
{
$baculas = [ "bacula-dir", "bacula-fd", "bacula-bat", "bacula-bconsole", "bacula- catalog-postgresql", "bacula-libs", "bacula-postgresql", "bacula-sd", "bacula-sql", "bacula-tools", "bacula-updatedb" ]
package { $baculas: ensure => "installed" }
exec { 'install_bacula':
provider => shell,
path => [ "/bin/", "/usr/bin", "/sbin" ],
command => "/usr/bin/zypper -n in $baculas;",
logoutput => on_failure,
}
}
While the packages got installed fine, there is an error in the output. It seems like the packages' names got concatenated and puppet returned an error for not being able to find such a lengthy package name. Output below:
# puppet agent --test
info: Caching catalog for otoyas
info: Applying configuration version '1418720157'
notice: /Stage[main]/Bacula/Package[bacula-dir]/ensure: created
notice: /Stage[main]/Bacula/Package[bacula-sd]/ensure: created
notice: /Stage[main]/Bacula/Package[bacula-fd]/ensure: created
notice: /Stage[main]/Bacula/Exec[install_bacula]/returns: Loading repository data...
notice: /Stage[main]/Bacula/Exec[install_bacula]/returns: Reading installed packages...
notice: /Stage[main]/Bacula/Exec[install_bacula]/returns: 'bacula-dirbacula-fdbacula-batbacula-bconsolebacula-catalog-postgresqlbacula-libsbacula-postgresqlbacula-sdbacula-sqlbacula-toolsbacula-updatedb' not found in package names. Trying capabilities.
notice: /Stage[main]/Bacula/Exec[install_bacula]/returns: No provider of 'bacula-dirbacula-fdbacula-batbacula-bconsolebacula-catalog-postgresqlbacula-libsbacula-postgresqlbacula-sdbacula-sqlbacula-toolsbacula-updatedb' found.
err: /Stage[main]/Bacula/Exec[install_bacula]/returns: change from notrun to 0 failed: /usr/bin/zypper -n in bacula-dirbacula-fdbacula-batbacula-bconsolebacula-catalog-postgresqlbacula-libsbacula-postgresqlbacula-sdbacula-sqlbacula-toolsbacula-updatedb; returned 104 instead of one of [0] at /etc/puppet/modules/bacula/manifests/init.pp:12
notice: /Stage[main]/Bacula/Package[bacula-bat]/ensure: created
notice: /Stage[main]/Bacula/Package[bacula-updatedb]/ensure: created
notice: /Stage[main]/Vsftpd/Exec[install_vsftpd]/returns: executed successfully
notice: /Stage[main]/Bacula/Package[bacula-tools]/ensure: created
notice: /Stage[main]/Bacula/Package[bacula-postgresql]/ensure: created
notice: Finished catalog run in 6.28 seconds
How do I fix this? If there is a better way to perform this task, I am open for suggestions since I am new to puppet.
Thanks.
Yes, your approach is flawed.
You should leave the gory details of how to invoke zypper
to Puppet. Don't use the exec
type unless it is absolutely necessary. For packages, use package
instead.
package {
$baculas:
ensure => 'installed',
provider => 'zypper',
}
Actually, Puppet should pick the zypper
provider on its own, if you're on a SUSE system. Just dropping the exec
might do the trick already.