How to handle apt-get -f install -y with Puppet

1,184 views
Skip to first unread message

Yves Fauser

unread,
Aug 20, 2013, 9:15:36 AM8/20/13
to puppet...@googlegroups.com
Hi All,

I'm trying to install packages using the dpkg provider on Ubuntu that leave the package unconfigured because of missing dependencies. After installing all packages, I need to run "apt-get -f install -y" to fix the dependencies. Now with puppet I did not find a way to do so yet. 

I'm trying to do the following:
......
package { "mypackage":
    provider => dpkg,
    ensure => installed,
    source => "/tmp/mypkg/mypackage.deb",
    before => Exec['apt-get fix'],
  }
  exec { "apt-get fix":
    command => "/usr/bin/apt-get -f install -y",
  }
......

But dpkg exits with a failure, and therefore the exec of "apt-get -f install -y" is skipped because of failed (puppet) dependencies.

Error: /Stage[main]/mymodule::mypkg/Package[mypackage]/ensure: change from absent to present failed: Execution of '/usr/bin/dpkg --force-confold -i /tmp/mypkg/mypackage.deb' returned 1: (Reading database ... 84559 files and directories currently installed.)
Preparing to replace ..... (using .../mypackage.deb) ...
Unpacking replacement mypackage ...
dpkg: dependency problems prevent configuration of ....: etc

.....
Warning: /Stage[main]/Vswitch::Mypkg/Exec[apt-get fix]: Skipping because of failed dependencies

Any ideas on how I can make this work? can I somehow ignore the return code? Is there an great elegant way to work around this?

Many thanks! Any help is really appreciated.
Yves


Andy Coates

unread,
Aug 24, 2013, 1:37:41 AM8/24/13
to puppet...@googlegroups.com
Just come across this post after needing to do the exact same thing.  I can get it to run independently by making the exec a require of the package, but then it will always run itself as well and I only want to run this exec after the package (but as you said the package fails due to the dependancies).

Bryce Catlin

unread,
Aug 30, 2013, 9:51:29 PM8/30/13
to puppet...@googlegroups.com
I ran into this too, and I think this is working for me:

  exec { 'apt-get-fix':
    command => "/usr/bin/apt-get -f -y install",
    unless  => "/usr/bin/apt-get check",
  }

I'm still testing, but it's looking good right now.

Bryce
Reply all
Reply to author
Forward
0 new messages