How can managed directory be updated after an rpm is upgraded?

14 views
Skip to first unread message

Tim Arnold

unread,
Aug 14, 2014, 12:44:02 PM8/14/14
to puppet...@googlegroups.com
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',

}

Christopher Wood

unread,
Aug 14, 2014, 1:29:12 PM8/14/14
to puppet...@googlegroups.com
If somebody came to me with this question at work, I'd ask why they aren't already managing the files in the directory to eliminate this dependency.

There's no "refreshonly" for files like there is for execs per the type list, so you're out of luck there ("not all types can refresh").

https://docs.puppetlabs.com/references/latest/type.html#file

https://docs.puppetlabs.com/references/latest/metaparameter.html#subscribe

In this case, where configs depend very much on the version of the underlying rpm, I might on one hand:

1) create a custom fact with the version of this package

https://docs.puppetlabs.com/facter/2.1/custom_facts.html

2) manage files based on the version exposed by this fact (have the files depend on the package so that they're managed after)

However, facts are only read once, iirc, so an rpm version change during an agent run will mean that configs are fixed up on the next agent run, leaving the daemon with stale configs for a time. Not desirable.

To get around this I might have two sets of manifests, each for the separate rpm version, and use hiera + class parameter to decide which set of rpm+configs gets managed and which gets removed. Toggle the value and I get newer versus older daemons.

If I were doing this in a high availability environment I might use the dual manifests to build a new set of servers with the new rpm+configs, while managing the hosts with the old rpm+configs. Then swap those into the load balancer in the same action where I swap the older servers out and carry on. That way if we find a problem we can just swap in the old servers to restore service and go ponder.
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [1]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]https://groups.google.com/d/msgid/puppet-users/dfdda8af-df09-4fbd-b395-1a419d532564%40googlegroups.com.
> For more options, visit [3]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:puppet-users...@googlegroups.com
> 2. https://groups.google.com/d/msgid/puppet-users/dfdda8af-df09-4fbd-b395-1a419d532564%40googlegroups.com?utm_medium=email&utm_source=footer
> 3. https://groups.google.com/d/optout

jcbollinger

unread,
Aug 15, 2014, 9:33:28 AM8/15/14
to puppet...@googlegroups.com


On Thursday, August 14, 2014 11:44:02 AM UTC-5, Tim Arnold wrote:
I want to 'manage' the files in a certain directory ONLY if the rpm is updated.


Why?

If it is not only acceptable but desired that these files be managed during runs when the RPM is updated, then why is it not acceptable to manage them all the time?  The usual reason for wanting one-time management of files is to avoid clobbering later modifications, but this scheme in fact does clobber any and all modifications between RPM updates.

 
 Any help is appreciated.



Repackage your RPM to include the desired versions of the files in question.


John

Reply all
Reply to author
Forward
0 new messages