Ask Your Question
0

How to run exec only if other exec actually runs

asked 2015-03-12 19:09:15 -0500

cjeffries gravatar image

This is a common topic, but I'm unable to figure out why my code is failing. From what I understand, the "clonerepo" exec would not run because the folder already exists. Then the "buildrepo" shouldn't run because the clone failed.

exec{ 'clonerepo': cwd => '/var/www/', command => "git clone -b $branch $gitrepo", creates => '/var/www/folder'; 'buildrepo': cwd => '/var/www/folder/src/', require => Exec[clonerepo], command => 'ant [both]'; }

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-03-13 05:15:11 -0500

have you tried the 'onlyif' e.g.

exec { "runrepostuff": command => "ant", onlyif => "clonerepo", } or something similar!

edit flag offensive delete link more

Comments

I tried something similar, but I can't get onlyif to recognize the first block. It seems that if "creates" is satisfied, puppet treats the command as if it was run succesfully, rather than that is was skipped. Is there something that I could use to treat it as a failed dependency instead?

cjeffries gravatar imagecjeffries ( 2015-03-13 15:26:06 -0500 )edit
0

answered 2015-03-13 16:53:51 -0500

cjeffries gravatar image

I modified it to this, and it works now as expected.

exec{ 'clonerepo': cwd => '/var/www/', command => "git clone -b $branch $gitrepo", creates => '/var/www/folder'; 'buildrepo': cwd => '/var/www/folder/src/', subscribe[clonerepo], refreshonly => true, command => 'ant [both]'; }

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2015-03-12 19:09:15 -0500

Seen: 125 times

Last updated: Mar 13 '15