Ask Your Question
0

exec returns command not working

asked 2017-04-03 13:46:11 -0500

I am having code as follows and i expect this to be set for all Execs running unzip command. However it doesn't work. I still get errors when the unzip returns 1.

Exec <| command == unzip |> { returns => [0,1] }

My test case is to set return code 0 and 1 as acceptable return codes for unzip something in Exec resource.

What is wrong with my Exec spaceship operator?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-04-03 14:38:45 -0500

puser gravatar image

I have never seen syntax like that in Puppet. That being said is the path to your unzip binary fully qualified?

what is wrong with...

exec { '/usr/bin/unzip /path/to/file':
  returns => [0,1],
}
edit flag offensive delete link more

Comments

I was trying to use the new spaceship operator functionality.i expect The resource collector to apply that on all exec resources running unzip command .

Redsmile gravatar imageRedsmile ( 2017-04-03 15:28:30 -0500 )edit

I don't think you can use the spaceship operator to set 'global' defaults for resources. As far as I know, https://docs.puppet.com/puppet/4.9/lang_defaults.html are generally considered a bad practice, since they can 'leak' in unintended ways...

DarylW gravatar imageDarylW ( 2017-04-03 16:03:37 -0500 )edit

"This means that if you use a resource default statement in a class, it has the potential to affect any classes or defined types that class declares"

DarylW gravatar imageDarylW ( 2017-04-03 16:03:43 -0500 )edit
DarylW gravatar imageDarylW ( 2017-04-03 16:04:49 -0500 )edit

Thanks for the link DaryIW, now my question is, are you saying that we can never have resource collectors with conditions on resources ?

Redsmile gravatar imageRedsmile ( 2017-04-06 12:39:11 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-04-03 13:46:11 -0500

Seen: 50 times

Last updated: Apr 03