I have a very simple Puppet (sub)module that should use Git to clone a repository from a remote location:
class wppuppet::git(
$location = '/var/www/wp'
) {
file { $location:
ensure => 'directory',
mode => '0755',
}
exec { 'git-wp':
command => 'git clone https://github.com/WordPress/WordPress ${location}',
require => Package['git'],
}
Package['git']
-> File[ $location ]
-> Exec['git-wp']
}
For some reason it constantly fails with the following error:
Error: git clone https://github.com/WordPress/WordPress ${location} returned 128 instead of one of [0]
Error: /Stage[main]/Wppuppet::Git/Exec[git-wp]/returns: change from notrun to 0 failed:
git clone https://github.com/WordPress/WordPress ${location} returned 128 instead one of [0]
I tried it with ${location}
as well as with $location
, but the result stays the same.
Best Answer
Your first problem is that you have your
command
parameter surrounded with single quotes ('
), which inhibit variable expansion. If you have:Then:
Will attempt to create a directory called "
$location
", whereas this:Would actually try to create
/path/to/target
.With that in mind, your
exec
resource should probably look like:Also, it's not necessary to pre-create the target directory;
git
will do this for you.You can run puppet with
--debug
in order to see the actual error messages output bygit
.