Jira (PUP-11199) Document exec type's 'onlyif' and 'unless' commands behavior with --noop

11 views
Skip to first unread message

Gabriel Nagy (Jira)

unread,
Aug 5, 2021, 9:19:04 AM8/5/21
to puppe...@googlegroups.com
Gabriel Nagy created an issue
 
Puppet / Improvement PUP-11199
Document exec type's 'onlyif' and 'unless' commands behavior with --noop
Issue Type: Improvement Improvement
Assignee: Unassigned
Created: 2021/08/05 6:18 AM
Priority: Normal Normal
Reporter: Gabriel Nagy
Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Gabriel Nagy (Jira)

unread,
Aug 5, 2021, 9:19:04 AM8/5/21
to puppe...@googlegroups.com

Gabriel Nagy (Jira)

unread,
Aug 5, 2021, 9:22:01 AM8/5/21
to puppe...@googlegroups.com
Gabriel Nagy updated an issue
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:

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

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

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

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

Gabriel Nagy (Jira)

unread,
Aug 5, 2021, 9:22:04 AM8/5/21
to puppe...@googlegroups.com
Gabriel Nagy updated an issue
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:

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

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

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

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

Gheorghe Popescu (Jira)

unread,
Aug 12, 2021, 4:41:02 AM8/12/21
to puppe...@googlegroups.com

Claire Cadman (Jira)

unread,
Aug 12, 2021, 8:07:02 AM8/12/21
to puppe...@googlegroups.com

Dorin Pleava (Jira)

unread,
Sep 27, 2021, 8:53:03 AM9/27/21
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages