Jira (PUP-6399) puppet resource $type $thing shouldn't return non-zero if $thing doesn't exist

2 views
Skip to first unread message

Matthaus Owens (JIRA)

unread,
Jun 9, 2016, 4:44:03 PM6/9/16
to puppe...@googlegroups.com
Matthaus Owens created an issue
 
Puppet / Bug PUP-6399
puppet resource $type $thing shouldn't return non-zero if $thing doesn't exist
Issue Type: Bug Bug
Affects Versions: PUP 4.2.3
Assignee: Unassigned
Created: 2016/06/09 1:43 PM
Priority: Normal Normal
Reporter: Matthaus Owens

Puppet seems to behave very differently when querying some types from the command line for resources that don't exist. For example, on ubuntu 12.04...

root@wzt7vze95hmfvb5:~# puppet resource service foo-bar
Error: Could not run: Could not find init script or upstart conf file for 'foo-bar'
root@wzt7vze95hmfvb5:~# echo $?
1
root@wzt7vze95hmfvb5:~# puppet resource user foo-bar
user { 'foo-bar':
  ensure => 'absent',
}
root@wzt7vze95hmfvb5:~# echo $?
0

In this case, foo-bar doesn't exist as either a service or user. Puppet returns non-zero for the service, but 0 for the user.

On redhat 7:

[matthaus@fontana ~]$ puppet resource service foo-bar
service { 'foo-bar':
  ensure => 'stopped',
  enable => 'false',
}
[matthaus@fontana ~]$ echo $?
0
[matthaus@fontana ~]$ puppet resource user foo-bar
Error: Could not run: undefined method `exists?' for nil:NilClass
[matthaus@fontana ~]$ echo $?
1

On redhat 7 the non-existent service returns 0 while the non-existent user returns non-zero.

Ideally puppet would return 0 in all of these cases and simply indicate that the resource is absent (or whatever the service equivalent is).

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.13#64028-sha1:b7939e9)
Atlassian logo

Henrik Lindberg (JIRA)

unread,
Jun 9, 2016, 9:52:34 PM6/9/16
to puppe...@googlegroups.com

Sean McDonald (JIRA)

unread,
May 16, 2017, 8:09:02 PM5/16/17
to puppe...@googlegroups.com
Sean McDonald updated an issue
Change By: Sean McDonald
Labels: triaged
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Sean McDonald (JIRA)

unread,
May 16, 2017, 8:09:02 PM5/16/17
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Jan 27, 2021, 11:29:03 AM1/27/21
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-6399
 
Re: puppet resource $type $thing shouldn't return non-zero if $thing doesn't exist

Can't reproduce using current puppet:

 

[root@pan-providence ~]# puppet resource user foo-bar
echo user

{ 'foo-bar': ensure => 'absent', provider => 'useradd', }

[root@pan-providence ~]# echo $?
0
[root@pan-providence ~]# puppet resource service foo-bar
echo service

{ 'foo-bar': ensure => 'stopped', enable => 'false', provider => 'systemd', }

[root@pan-providence ~]# echo $?
0
[root@pan-providence ~]# puppet --version
6.19.1
[root@

{nofomat}
This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages