Jira (PUP-11403) Add attribute to Exec resource type which defines an exit code(s) to mean "no changes made"

9 views
Skip to first unread message

Mark Nejedlo (Jira)

unread,
Jan 3, 2022, 4:18:01 PM1/3/22
to puppe...@googlegroups.com
Mark Nejedlo created an issue
 
Puppet / New Feature PUP-11403
Add attribute to Exec resource type which defines an exit code(s) to mean "no changes made"
Issue Type: New Feature New Feature
Assignee: Unassigned
Created: 2022/01/03 1:17 PM
Priority: Normal Normal
Reporter: Mark Nejedlo

As a complement to onlyif and unless, sometimes the command itself is the best positioned to decide if a change needs to be made.  It would be nice if there was an attribute to the Exec resource type that allowed to command to inform puppet that no changes were made.

If, for example, I had:

exec {'stuff':
  command   => '/usr/local/bin/foo',
  unchanged => '42',
  notify    => Service['bar']
}

If /usr/local/bin/foo exited with code 42, the exec would show up as unchanged (instead of as a failure) in the puppet results and would NOT trigger the notify.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo

Josh Cooper (Jira)

unread,
Jan 4, 2022, 10:55:02 AM1/4/22
to puppe...@googlegroups.com
Josh Cooper commented on New Feature PUP-11403
 
Re: Add attribute to Exec resource type which defines an exit code(s) to mean "no changes made"

I believe this is already supported using the returns parameter, e.g.

$ bundle exec puppet apply -e 'exec { "returns": command => "/bin/sh -c exit 42", returns => [0, 42] }'
Notice: Compiled catalog for localhost in environment production in 0.03 seconds
Notice: /Stage[main]/Main/Exec[returns]/returns: executed successfully

Mark Nejedlo (Jira)

unread,
Jan 4, 2022, 11:17:01 AM1/4/22
to puppe...@googlegroups.com
Mark Nejedlo commented on New Feature PUP-11403

Returns defines acceptable exit codes to be interpreted as "changes made."  Returns does NOT, according to the documentation, define "successful, but no changes made".

Josh Cooper (Jira)

unread,
Jan 4, 2022, 12:09:01 PM1/4/22
to puppe...@googlegroups.com
Josh Cooper commented on New Feature PUP-11403

Ah yeah right. Usually one defines onlyif, unless or creates parameter(s) to control whether the exec runs in the first place.

Unfortunately, I think it would fairly difficult to add an unchanged type of parameter due to the way puppet's resource harness checks to see if the exec is insync before running the exec. In other words, puppet has already decided that the resource is not insync (and therefore there is a change) by the time the exec runs. Trying to "undo" the change after the fact would be difficult.

Reply all
Reply to author
Forward
0 new messages