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

Document exec type's 'onlyif' and 'unless' commands behavior with --noop



    • Improvement
    • Status: Resolved
    • Normal
    • Resolution: Fixed
    • None
    • PUP 6.25.0, PUP 7.10.0
    • None
    • Night's Watch
    • 1
    • NW - 2021-08-11
    • Enhancement
    • Document {{noop}} behavior of {{onlyif}} and {{unless}} parameters of the {{exec}} resource. (not sure if this should make the release notes)
    • Needs Assessment


      Taken from: https://groups.google.com/g/puppet-users/c/axT5CfVNDXU

      The noop flag tells Puppet to determine which resources are out of sync, and to report them without actually synchronizing them. The 'onlyif' and 'unless' commands of an Exec are used in the process of determining whether the Exec is already in sync, therefore they must be run during a -noop Puppet run. The synchronization of an out-of-sync Exec resource involves only running the command given by its 'command' property, so that's the only part that -noop prevents.


      Up until https://github.com/puppetlabs/puppet/commit/c127bcb1f6b3d0a0e7b9122352162528fbb65b6c onlyif and unless commands did not run in the specified cwd, which might have given the wrong impression that noop also applies to those parameters. Applying something like the following manifest would have worked prior to that commit:

      exec { "hello world":
       cwd => '/home/gabi/tmp/abc',
       command => "/bin/echo hello world",
       onlyif => "/bin/test -e asd",

      After puppet 5.5.7 applying the manifest above with --noop fails with the following error (provided that the cwd does not exist):

      Error: /Stage[main]/Main/Exec[hello world]: Could not evaluate: Working directory /home/gabi/tmp/abc does not exist!

      This is expected behavior since noop does not prevent onlyif and unless from being run. We should document this behavior.


        Issue Links



              gabriel.nagy Gabriel Nagy
              gabriel.nagy Gabriel Nagy
              0 Vote for this issue
              3 Start watching this issue



                Zendesk Support