As I understand it, refreshonly ensures the command will only run when a dependent object is changed, hence only subscribe and notify trigger it, not require. So I don't think either exec would be called in your manifest. I might be missing something there though.
But regardless, I'm not sure how you could get the exec to run before the binary is changed. As I understand it, if you use require without refreshonly, the exec resource will just be applied before the file resource regardless of whether the file is being changed or not. To only run the exec when the file is being changed, you'd have to use refreshonly with notify or subscribe, or independently determine that the file is about to be changed (possibly with an onlyif command). And if you do use refreshonly, with notify, it will only notify after the file has changed I believe. Similarly a subscribe will only run the exec after the file has changed. I don't think there's any way to notify an object that something is about to change. Basically, notify is 'notify after', and AFAIK there's no 'notify before'. One option might be to stop and start the server every time regardless of whether the file is being updated or not, but that seems less than ideal. An expert may well be able to offer a better solution, but as a workaround I'd suggest managing a copy of the server binary rather than the binary itself. Then have an exec type subscribed to the copy that, upon changes, stops the server, copies the new binary over the old binary, and starts the server. It's not particularly elegant, but it should definitely work and it's probably simpler than trying to determine whether the file is about to change from within the stop-server exec. Rob Mathew Binkley wrote: > Hi. I'm hoping that someone can help me with a simple example. We > are trying to use puppet to update a server binary to a group of > machines. Here's pseudocode for what I'm trying: > > if (server_binary has changed) { > 1) stop the old server > 2) overwrite the old server binary by > fetching the new server binary from puppet > 3) start the new server > } > > Below is the puppet manifest I wrote to handle this, but it isn't > working properly. It is 1) downloading the new binary and then 2) > stopping the server, which screws up our data. I've been looking > through the documentation, and it isn't clear which permutation of > before, require, subscribe, or notify is necessary to accomplish > this. Hope someone can enlighten me. - Mat > > > file { "/usr/local/sbin/server_binary": > source => "puppet:///files/server_binary", > require => Exec["stop-server"], > before => Exec["start-server"] > } > > # Stops the server > exec { "/usr/local/sbin/stop-server": > alias => "stop-server", > refreshonly => true > } > > # Starts the server > exec { "/usr/local/sbin/start-server": > alias => "start-server", > refreshonly => true > } > > -- Robert Fay [EMAIL PROTECTED] System Administrator office: 220 High Energy Physics Division tel (int): 43396 Oliver Lodge Laboratory tel (ext): +44 (0)151 794 3396 University of Liverpool http://www.liv.ac.uk/physics/hep/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---