Ask Your Question

dpkg dependency problem

asked 2017-03-10 02:15:53 -0600

bigfoot74 gravatar image


im installing a bunch of packages, and 2 packages are having some dependency problems. First i got an arry of files, and then I do this:

$all_packages.each | String $packages| {
$package_name = split($packages, '_')[0]
exec { "install package: ${packages}":
  command => "dpkg -i /tmp/${packages}",
  unless  => "dpkg -l ${package_name}"

Does someone know how to build a dependency checker in here ??


  • Pascal
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2017-03-11 11:00:40 -0600

updated 2017-03-11 11:04:32 -0600

As Richard already mentioned usage of the package resource type is advised.

However, I guess Pascal's installing some software which isn't retrievable from a repository. We recently had to deal with some alike situation and solved it like that:

class some_software {
  # you have to resolve the dependencies for `foobar` package on your own!
  package {
    ensure => present,

  file { 'foobar_deb':
    # put your packages to some more appropriate location other than /tmp/
    path   => '/var/cache/apt/archives/foobar.deb',
    ensure => present,
    mode   => '0644',
    owner  => 'root',
    group  => 'root',
    source => '',

  package { 'foobar':
    name      => 'foobar',
    ensure    => latest,
    provider  => dpkg,
    source    => File['foobar_deb']['path'],
    require   => Package['libblub', 'libbla'],
    subscribe => File['foobar_deb'],

However, the more elegant way is to host your own (company-wide) package repository and include that one via an APT sources *.list instead. Here we're (knowingly) skipping any signature verification for foobar.

edit flag offensive delete link more

answered 2017-03-11 02:23:56 -0600

You should use the package-type for this.

$all_packages.each | String $packages | {
  $package_name = split($packages, '_')[0]
  package { $package_name:
    ensure => installed,

It will install on debian/ubuntu with apt, pulling any dependencies as required by the packages. Already installed packages are not re-installed.

With the right input-array, you can make it even simpler, since 'package' iterates itself over arrays:

$packages = [ 'zip', 'unzip' ]
package { $packages: 
  ensure => installed,
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2017-03-10 02:15:53 -0600

Seen: 120 times

Last updated: Mar 11 '17