Ask Your Question
3

puppet only exec when file does NOT exist

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

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 https://github.com/testing/puppet.git',
    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
6

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

KlavsKlavsen gravatar image

Have a look at http://docs.puppetlabs.com/references/stable/type.html#exec-attribute-creates

The creates attribute for exec.

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

edit flag offensive delete link more
0

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

rohithmn03 gravatar image

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

edit flag offensive delete link more
0

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

DarylW gravatar image

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

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   => 'https://github.com/testing/puppet.git',
  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

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: 2013-12-03 19:05:32 -0500

Seen: 3,668 times

Last updated: Oct 06 '16