Ask Your Question

refresh exec before executing package install

asked 2015-12-15 11:24:23 -0600

jimr-piq gravatar image

I keep coming up against this issue so me thinks I must be approaching it the wrong way. It seems like such a common thing that one would want to do and yet it seems very hard with Puppet. Thus, I must be trying to do it wrong :)

Say you have a package resource and you want to make sure you do a "yum clean all" before that Package triggers an update because the package is ensure => latest.

The only way I know how to do a "yum clean all" is via an exec. But, I don't want the exec to fire on every puppet run so of course I want to set it to either "refresh only" or set an "only if" condition.

As far as I can tell there is no way to send a refresh to the exec BEFORE puppet tries to update the package and I have no idea what "only if" condition I could set that would correspond with the package being updated such that the exec "yum clean all" would always happen just before the package update...

Can someone give me a hint please?


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-12-16 00:18:07 -0600

I think what you're doing differently is that some feel that ensure => latest is a Puppet feature that is best avoided. I prefer to take care of system upgrades and yum updates either manually or by using orchestration tools like PE's Live Management, Mcollective, Ansible etc or dedicated package management tools like Red Hat Satellite, Pulp etc.

edit flag offensive delete link more

answered 2015-12-16 03:25:51 -0600

Anandk gravatar image

You can opt to use onlyif, the yum will install the latest after the yum clean all is ran. Use it with an exec combo.

Something like this:

exec { "check_dir":
      command => '/bin/true',
      onlyif => '/usr/bin/test -d  /var/tmp/',

This is just an example. In above the file in a directory is replaced onlyif the directory exists.

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: 2015-12-15 11:24:23 -0600

Seen: 896 times

Last updated: Dec 16 '15