This site is for tech Q&A. Please keep your posts focused on the subject at hand.

Ask one question at a time. Don't conflate multiple problems into a single question.

Make sure to include all relevant information in your posts. Try to avoid linking to external sites.

Links to documentation are fine, but in addition you should also quote the relevant parts in your posts.

0 votes

In Puppet I need to trigger an action if a file resource is changed. I know I can define an execresource for the action, and notify that from the file resoure:

file { '/path/to/myfile':
  content => template("${module_name}/mytemplate.erb"),
  notify  => Exec['my action'],

exec { 'my action':
  command   => '...',
  logoutput => true,

However, if I do the above, Puppet tries to always apply the exec resource, not just on file changes. How do I ensure that the action is only triggered when the file is modified?

in General by (335) 2 9

Your answer


Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
By submitting this post you agree to our Terms & Conditions.
To avoid this verification in future, please log in or register.

1 Answer

0 votes

Add the parameter refreshonly to your exec resource and set it to true:

exec { 'my action':
  command     => '...',
  refreshonly => true,
  logoutput   => true,

From the documentation:

Refresh: exec resources can respond to refresh events (via notify, subscribe, or the ~> arrow). The refresh behavior of execs is non-standard, and can be affected by the refresh and refreshonly attributes:

  • If refreshonly is set to true, the exec runs only when it receives an event. This is the most reliable way to use refresh with execs.
by (335) 2 9