Reputation: 549
Suppose I want to make sure that my VM has devstack on it.
exec{ "openstack":
command => "git clone https://git.openstack.org/openstack-dev/devstack",
}
This is the puppet code I write for it and it works fine for the first time. Now I want to put a check. I want to clone the repository only if it has not been done already. How to do that
Upvotes: 3
Views: 767
Reputation: 15472
You say
exec { 'openstack':
command => 'git clone https://git.openstack.org/openstack-dev/devstack',
creates => '/path/to/somewhere/devstack',
cwd => '/path/to/somewhere',
path => '/usr/bin',
}
Now if the directory /path/to/somewhere/devstack
exists the clone command won't run.
Upvotes: 5
Reputation: 10074
exec { "openstack":
command => 'git clone https://git.openstack.org/openstack-dev/devstack /path/to/devstack",
unless => 'test -d /path/to/devstack'
}
its a really hacky way to handle this. you should look into the vcsrepo puppet module https://github.com/puppetlabs/puppetlabs-vcsrepo
Upvotes: 4