Skip to content

puppet resource should return non-zero if it fails to make changes #9292

Closed
@joshcooper

Description

@joshcooper

Describe the Bug

Puppet returns exit code 0 when it fails to modify the system. This is not specific to any resource type, for example:

❯ bundle exec puppet resource file / content=123
Notice: /File[/]: Not removing directory; use 'force' to override
Notice: /File[/]: Not removing directory; use 'force' to override
Error: Could not set 'file' on ensure: Permission denied @ dir_s_mkdir - /20240312-324986-1f7prcz.lock
Error: Could not set 'file' on ensure: Permission denied @ dir_s_mkdir - /20240312-324986-1f7prcz.lock
Wrapped exception:
Permission denied @ dir_s_mkdir - /20240312-324986-1f7prcz.lock
Error: /File[/]/ensure: change from 'directory' to 'file' failed: Could not set 'file' on ensure: Permission denied @ dir_s_mkdir - /20240312-324986-1f7prcz.lock
file { '/':
  ensure   => 'directory',
  provider => 'posix',
}
❯ echo $?
0

Expected Behavior

It should return non-zero, but do so in a backwards-compatible way through a feature flag. Proposal is to add --fail flag (inspiration taken from curl) like:

❯ bundle exec puppet resource file --fail / content=123
...
❯ echo $?
1

Additional Context

PE-36365

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions