Ask Your Question
1

How can I update a managed directory after an rpm is upgraded?

asked 2014-08-14 11:45:43 -0500

quarlington gravatar image

updated 2014-08-14 12:33:55 -0500

ramindk gravatar image

I want to 'manage' the files in a certain directory ONLY if the rpm is updated. Any help is appreciated.

For example (this doesn't work):

package { 'package-name' :
  ensure   => 'Version-2',   
  provider => 'rpm',
}

file { '/home/thisuser/.java' :
   ensure    => directory,   
   subscribe => Package['package-name'],   
   recurse   => true,   
   purge     => true,   
   force     => true,   
   backup    => false,   
   source    => 'puppet:///modules/test/home/thisuser/.java',
}
edit retag flag offensive close merge delete

Comments

Could you elaborate your question more? What do you mean by doesn't work. What do you expect to happen vs what actually happens?

spuder gravatar imagespuder ( 2014-08-14 12:57:31 -0500 )edit

What I would like to happen is for puppet to purge the .java directory and leave it with only the files I have in the source directory. It actually does this. The problem is, it does it EVERY time. I only want it to do it if the package has been updated. I know I could write a little script to do this, I was just hoping that it could be done using basic puppet commands. Thank you for your time.

quarlington gravatar imagequarlington ( 2014-08-14 14:02:25 -0500 )edit

have you tried using refreshonly of your file resource?

Red Cricket gravatar imageRed Cricket ( 2014-08-15 03:10:59 -0500 )edit

http://ask.puppetlabs.com/users/373/red-cricket/ The file resource has no refreshonly parameter.

ramindk gravatar imageramindk ( 2014-08-15 11:41:19 -0500 )edit

I did try that. I guess I'm just going to have to script something. Thanks for the feedback.

quarlington gravatar imagequarlington ( 2014-08-15 12:18:28 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-08-26 14:03:19 -0500

WhatsARanjit gravatar image

Because Puppet is modeling state, we want to describe the directory as we mean it to be. Not necessarily be variable until a certain point, at which it then gets managed. But if you do want to trigger an event like this, you might have to use an exec resource with a refreshonly parameter. One creative way of doing this:

  1. Use replace => false on your file resource. This means the directory will be initialized, but not managed after that.
  2. Ensure the package
  3. Have an exec with a subscribe on the package, refreshonly => true, and before => Package[$mypackage]. The exec should delete the directory in question.

So what should happen is Puppet places the directory if it isn't there and only if it isn't there. A refresh on the package will trigger a delete of the directory, after which Puppet will re-create the directory.

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

Stats

Asked: 2014-08-14 11:45:43 -0500

Seen: 119 times

Last updated: Aug 26 '14