Ask Your Question

onlyif doesn't seem to be executing

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

mydogspot gravatar image

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

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

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

ramindk gravatar image

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

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


Thanks! this fixed the problem.

mydogspot gravatar imagemydogspot ( 2015-03-12 12:10:22 -0600 )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


Asked: 2015-03-11 15:01:06 -0600

Seen: 586 times

Last updated: Mar 12 '15