This seems to have been solved by PUP-9357:
% cat ../tmp/pup-8399/unless_fail.pp ±[remotes/upstream/5.5.x]$mypassword = Sensitive('mypasswordhere')
exec { 'test_sensitive':
command => "/bin/sh -c echo command",
unless => "/bin/sh -c echo $mypassword; exit 0",
#onlyif => "/bin/sh -c echo $mypassword; exit 1",
}
% bx puppet apply ../tmp/pup-8399/unless_fail.pp --debug
...
Debug: Exec[test_sensitive](provider=posix): Executing check '/bin/sh -c echo Sensitive [value redacted]; exit 0'
Debug: Executing: '/bin/sh -c echo Sensitive [value redacted]; exit 0'
Debug: /Stage[main]/Main/Exec[test_sensitive]: '/bin/sh -c echo command' won't be executed because of failed check 'unless'
with similar results for the onlyif command.