Ask Your Question

puppet only exec when file does NOT exist

asked 2013-12-03 19:05:32 -0600

qinking126 gravatar image

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',
    require => Exec['git init'],
    cwd => '/home/vagrant/django',
    user => 'vagrant',
    onlyif => "not sure what to put here"
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2016-10-06 11:32:05 -0600

DarylW gravatar image

updated 2016-10-06 11:34:46 -0600

Not a direct answer to your actual question, but if you want to manage a repository with puppet, look to the vcsrepo module.

You could duplicate what you are doing above (and probably remove a few other exec statements) using the following parameters.

vcsrepo { '/home/vagrant/django':
  ensure   => present,
  provider => git,
  source   => '',
  user     => 'vagrant',

This also is advantageous because you are describing 'how it should be' instead of 'what to do'

edit flag offensive delete link more

answered 2013-12-04 02:55:27 -0600

KlavsKlavsen gravatar image

Have a look at

The creates attribute for exec.

you would just add: creates => '/usr/local/bin/papply'

edit flag offensive delete link more

answered 2016-10-06 00:57:00 -0600

rohithmn03 gravatar image

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

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

1 follower


Asked: 2013-12-03 19:05:32 -0600

Seen: 4,534 times

Last updated: Oct 06 '16