Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I only want to exec following command when file (/usr/local/bin/papply) does not exist. not sure what to put there.

    exec { 'git add url':
        command =>'git remote add origin https://github.com/testing/puppet.git',
        require => Exec['git init'],
        cwd => '/home/vagrant/django',
        user => 'vagrant',
        onlyif => "not sure what to put here"
    }
share|improve this question

2 Answers 2

up vote 7 down vote accepted

Have you tried this?

onlyif => "test ! -f /usr/local/bin/papply"

Not sure if Puppet can use the '!' character

Perhaps a better alternaltive:

creates => '/usr/local/bin/papply'

even if i don't like the fact that the command doesn't really creates the file

share|improve this answer
    
not working, got this error message. Could not evaluate: Could not find command '!' –  user61752 Dec 4 '13 at 1:22
    
And this: onlyif => "test ! -f /usr/local/bin/papply" –  sebastien.prudhomme Dec 4 '13 at 1:27
    
creates => '/usr/local/bin/papply' works, thank you. let me test your updates, see if htat one works. –  user61752 Dec 4 '13 at 1:36
1  
onlyif => "test ! -f /usr/local/bin/papply" works, also the one I prefer to use. thank you. –  user61752 Dec 4 '13 at 2:03

If you're on linux just do

unless => 'ls /somefile'

ls will return with a non-zero return code if the file does not exist and unless will only let the exec it is under execute if its test returns a non-zero return code.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.