Ask Your Question
1

onlyif doesn't seem to be executing

asked 2015-03-11 15:01:55 -0500

mydogspot gravatar image

updated 2015-03-11 23:49:34 -0500

ramindk gravatar image

I'm trying to use exec with unless and going in circles. I want to use exec to do a solaris silent install. my exec command is

command => '/usr/sbin/pkgadd -n -r /tmp/response_file -a /tmp/admin_file -d /tmp/te_agent.pkg TWeagent',
unless => '/usr/bin/pkginfo | grep TWeagent | wc -l > 0',

This works great if the package is already installed, in that it stops trying to re-install it. But if the package is not installed it doesn't get installed. I can see it executing in debug mode -

 Debug: Exec[install_te](provider=posix): Executing check '/usr/bin/pkginfo | grep TWeagent | wc -l > 0'
 Debug: Executing '/usr/bin/pkginfo | grep TWeagent | wc -l > 0'

but that's it. no execute. Can someone please tell me what I'm doing wrong? If I take out the unless line it will install, but it will install every time puppet runs.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-03-11 23:59:33 -0500

ramindk gravatar image

updated 2015-03-12 02:31:14 -0500

Your command is always exiting with a status code of 0. That's the only thing Puppet cares about when used with unless or onlyif. Try changing your command to

unless => '/usr/bin/pkginfo | grep TWeagent'
edit flag offensive delete link more

Comments

Thanks! this fixed the problem.

mydogspot gravatar imagemydogspot ( 2015-03-12 12:10:22 -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: 2015-03-11 15:01:06 -0500

Seen: 467 times

Last updated: Mar 12 '15