1

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.

9

Your first problem is that you have your command parameter surrounded with single quotes ('), which inhibit variable expansion. If you have:

$location = "/path/to/target"

Then:

file { '$location':
  ensure => directory,
}

Will attempt to create a directory called "$location", whereas this:

file { "$location":
  ensure => directory,
}

Would actually try to create /path/to/target.

With that in mind, your exec resource should probably look like:

exec { 'git-wp':
  command => "git clone https://github.com/WordPress/WordPress ${location}",
  require => Package['git'],
}

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 by git.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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