Hi Nigel Kersten, Thank you for your elaborate answer. I am not sure how to proceed, though...
>> What I would like, is for Puppet to run `aptitude update` before it >> installs or upgrades packages. That doesn't seem out of the ordinary to >> me, but I can't make it work in Puppet. >> >> The approach I like best, is this one: >> >> class apt-update { >> exec { "/usr/bin/aptitude update": >> refreshonly => true, >> } >> } >> >> define apt_package($ensure="latest") { >> include apt-update >> package { $name: >> ensure => $ensure, >> require => Class["apt-update"], >> } >> } >> >> apt_package { "foo": >> } >> >> but that doesn't work, it doesn't run apt-update before installing 'foo', >> because of the "refreshonly => true". If I remove it, it works, but then >> `aptitude update` is run on /every/ Puppet run, which is worse than not >> running it at all. >> >> Is it at all possible to achieve what I want with Puppet? If so, how? > > Why do you want to run this before every package install? That will > add a fair bit of overhead. I don't quite understand the desire to run > before every package install, and yet not simply have it run once > before all package installs. I am not sure how I said I want to do an update before /every/ package install. Once at the start of a Puppet-run, /IF/ one or more packages need to be installed, would suffice. > We've used two approaches, both using our package::apt::update class > which runs apt-get update/upgrade/dpkg --configure -a etc. I think I read that in the posting that I referenced. > 1) Resource defaults: > > In the global scope, set a resource default for package to require the > package::apt::update class > The downside is that if you wish to set an additional require for a > specific package, you need to remember to include the global default > as well. > > 2) Defined types: > > Define a type much like yours that has the same require on the package > resource definition inside the defined type. Isn't that what I decribed above? The problem is, that by including the class in the define, it runs everytime, unless 'refreshonly => true' is set, in which case it never runs. If I don't include the class in the define, Puppet can't find the class when it evaluates the 'require'. How does that work for you? Would it be possible for you to share (relevant parts of) your configuration as-is? > The downside is that you are no longer just using 'package' resources, > which makes the use of other people's modules difficult. > The upside is that we have a similar defined type 'apt_repo' that sets > up repositories. With appropriate use of require in apt_package and > before in apt_repo, you know your repositories are being laid down > before apt-get update etc get run, and that the packages are installed > afterwards. > > Run stages make this a bit simpler, but you can achieve the same > functionality without them. I have been looking for examples using run stages, but they are scarce. The examples in the release notes are too simple to go by. >> I have tried to fiddle around with the new run stages feature, but that >> got me in a circular dependency mess I couldn't get out of. >> Best regards, Martijn.
smime.p7s
Description: S/MIME Cryptographic Signature