Skip to content

Instantly share code, notes, and snippets.

@oko
Created November 15, 2014 15:40
Show Gist options
  • Save oko/bbd1554b9d1e80c77b8d to your computer and use it in GitHub Desktop.
Save oko/bbd1554b9d1e80c77b8d to your computer and use it in GitHub Desktop.
Quick and dirty Puppet manifest for Git repository cloning.
# Works, but minimally tested. U@YOR.
define git::repo($repo, $location, $autoupdate = false) {
package { 'git':
ensure => installed,
}
# Clone repository if $location/.git doesn't already exist
exec { "clone-$repo":
provider => shell,
command => "/usr/bin/git clone $repo $location",
onlyif => "/usr/bin/test '!' -d $location/.git",
}
# If enabled, automatically pull down the latest version
if $autoupdate {
exec { "pull-$repo":
provider => shell,
command => "cd $location && /usr/bin/git pull",
onlyif => "/usr/bin/test -d $location/.git",
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment