Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-5438

require => Exec with refreshonly still triggers if Exec isn't refreshed


    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Won't Fix
    • Affects Version/s: PUP 3.8.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
    • Template:


      This is a variation on PUP-2748, where the exec uses refreshonly

      Exec {
        logoutput => true,
        path => '/bin:/usr/bin',
      exec {'step 1':
        command => '/bin/echo step1',
        notify => Exec['step 2'],
      exec {'step 2':
        command => '/bin/echo step2',
        onlyif => 'false',
        refreshonly => true,
        notify => Exec['step 3'],
      exec {'step 3':
        path => '/bin:/usr/bin',
        command => '/bin/echo step3',
        refreshonly => true,

      with output

      Notice: Compiled catalog for michaels-macbook-pro.local in environment production in 0.07 seconds
      Info: Applying configuration version '1445983656'
      Notice: /Stage[main]/Main/Exec[step 1]/returns: step1
      Notice: /Stage[main]/Main/Exec[step 1]/returns: executed successfully
      Info: /Stage[main]/Main/Exec[step 1]: Scheduling refresh of Exec[step 2]
      Notice: /Stage[main]/Main/Exec[step 2]: Triggered 'refresh' from 1 events
      Info: /Stage[main]/Main/Exec[step 2]: Scheduling refresh of Exec[step 3]
      Notice: /Stage[main]/Main/Exec[step 3]/returns: step3
      Notice: /Stage[main]/Main/Exec[step 3]: Triggered 'refresh' from 1 events
      Notice: Finished catalog run in 0.05 seconds

      If you use onlyif => 'false' in 'step 1' nothing is triggered. If 'step 1' acts, then the 'onlyif' behavior in 'step 2' means the exec command isn't invoked, but triggers 'step 3'. This behavior is definitely inconsistent.

      Some paraphrased notes from Charlie Sharpsteen on why that might be:

      The issue appears to be that Exec[step 2] is generating or propagating a refresh event when it isn't actually firing. So, refreshes are wierd... I suspect it's just propagating regardless of the hackery Exec has to conditionally run commands.

      Refreshes were originally built to trigger service restarts — so I'd bet there is an assumption that refreshing a resource will "do something" and thus should be propagated. refreshonly was totally bolted onto that service restart mechanism and probably violates several of the original assumptions.

      So, what happens is that the event_manager queues up refresh events if a refreshed resource "restarted successfully": https://github.com/puppetlabs/puppet/blob/4.2.2/lib/puppet/transaction/event_manager.rb#L32-L39

      That gets set depending on how process_callback goes, which always returns true if the method completes without raising an error: https://github.com/puppetlabs/puppet/blob/4.2.2/lib/puppet/transaction/event_manager.rb#L152

      In the case of an Exec, what gets called there is resource.refresh.


          Issue Links



              • Assignee:
                michael.smith Michael Smith
              • Votes:
                0 Vote for this issue
                2 Start watching this issue


                • Created:

                  Zendesk Support