Re: exec 'refresh' attribute possible values

530 views
Skip to first unread message

jcbollinger

unread,
Nov 26, 2012, 10:18:00 AM11/26/12
to puppet...@googlegroups.com


On Friday, November 23, 2012 9:05:07 AM UTC-6, badbishop wrote:
A quote from http://docs.puppetlabs.com/references/latest/type.html#exec

refresh
How to refresh this command. By default, the exec is just called again when it receives an event from another resource, but this parameter allows you to define a different command for refreshing.

A different command... like what?


Anything you like, though some things make more sense than others.  Here is a contrived example that I hope will communicate at least the spirit:

exec { 'Puppet Timestamps':
  command => 'echo "first run:" > /var/log/puppet_timestamp; date >> /var/log/puppet_timestamp',
  refresh => 'touch /var/log/puppet_timestamp',
  creates => '/var/log/puppet_timestamp',
  provider => 'sh'
}

That will manage a file /var/log/puppet_timestamp whose text records a timestamp of the Puppet run in which it was created, and whose file timestamp is updated to the current time every time Puppet refreshes it.

 
What does it add to 'refreshonly' attribute?


The 'refreshonly' attribute allows the Exec's refresh action to be executed without first executing its synchronization action.  Normally both the refresh and the synchronization action are given by the 'command' parameter (though I don't think that's quite how it should be, and there is a chance it will change in the future; see http://projects.puppetlabs.com/issues/5876).  If you assign a 'refresh' parameter then that -- instead of the 'command' parameter -- gives the refresh action.

 

Actually, what I'm looking for, is a conditional triggering of one exec by another. That is exec1 notifies exec2 only if exec1 command has been actually executed.
'onlyif' can prevent the execution of exec1 itself, but doesn't prevent, say, notify=>Exec['2'] from happening.


Then you are looking for the 'creates', 'unless', and/or 'onlyif' parameters of exec1.  Use those to determine whether exec1 needs to run.  If it is synchronized without actually running -- as controlled by those parameters -- then it will not broadcast events to other resources.

If exec2 should do nothing when it does not receive an event from exec1, then you want "refreshonly => true" on exec2.  The 'refresh' parameter is inappropriate for that use case.


John

Reply all
Reply to author
Forward
0 new messages