Ask Your Question

RPM install and action on failure with exec

asked 2017-03-07 12:02:40 -0600

Narahari gravatar image

updated 2017-03-07 12:03:43 -0600


I have a package resource that gets executed. It is an RPM and has post-install scripts that get run. In some case the RPM;s post-install script fails. This is being handled by the package resource in that it fails as well.

I however want to trap that always call an Exec resource that will do additional checks so we can remove the RPM.

package { 'mypackage':   ensure => installed, }

exec { '/path/to/myscript':
  onlyif  => ...,
  require => Package['mypackage'],

I want the Exec resource to get called always, whether the package resource got run with success or not.

Any idea how to get this accomplished ?

It is my understanding that if the package resource fails, the Exec resource does not get called.

Should I use the notify attribute on the package resource instead ?

Thank You for your time and attention.

Regards, -Narahari

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-03-07 13:51:35 -0600

puser gravatar image

What do the post installation scripts do? I would imagine Puppet can do the post installation piece easier than a script can. Then simply order them in your manifests so the package is installed first and the scripts run after the fact.

edit flag offensive delete link more


Thank you for your answer. We thought about that. One problem, we don't have control over the post-install script. It will fire off as a part of the rpm install(we don't author the rpm some other team does that).

Narahari gravatar imageNarahari ( 2017-03-07 14:45:02 -0600 )edit

that's where Puppet comes in. Do you know what the scripts are supposed to do? Have puppet do it anyway. If the RPM fails then puppet will run, if the RPM succeeds the puppet does nothing.

puser gravatar imagepuser ( 2017-03-08 14:57:00 -0600 )edit

The problem is that if the rpm is in the resource chain for the later script, the fact that it fails will prevent any resources that require it from running. I'm not sure if this is still true with a notify/subscribe relationship though....

DarylW gravatar imageDarylW ( 2017-03-14 08:49:38 -0600 )edit

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-07 12:02:40 -0600

Seen: 187 times

Last updated: Mar 07 '17