Last active
December 19, 2015 02:28
-
-
Save jessepeterson/5882901 to your computer and use it in GitHub Desktop.
Puppet definition to download a tarball of a Github repo and extract it to a filesystem location.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example: | |
# | |
# github_dlextract { "mxcl/homebrew", | |
# path => "/my/path/directory", | |
# rev => "b8c7e203d1", # optional | |
# } | |
define github_dlextract ($repo = $title, $path, $rev = 'master') { | |
file { $path: | |
ensure => directory, | |
} | |
$reporepl = regsubst($repo, '\/', '-') | |
$inst_marker_file = "/var/db/.puppet_github_${reporepl}_${rev}" | |
exec { "github_dlextract-${repo}": | |
command => "curl -kL https://github.com/${repo}/tarball/${rev} | tar xzf - && cp -pR ${reporepl}-*/ ${path} && rm -rf /tmp/${reporepl}-*", | |
cwd => "/tmp", | |
path => ["/bin", "/sbin", "/usr/bin", "/usr/sbin"], | |
refreshonly => $rev ? { | |
'master' => false, | |
default => true}, | |
subscribe => File[$inst_marker_file], | |
require => File[$path], | |
} | |
if $rev == 'master' { | |
exec { "github_dlextract-delmarker-${repo}": | |
command => "rm -f /var/db/.puppet_github_${reporepl}_*", | |
path => ["/bin", "/sbin", "/usr/bin", "/usr/sbin"], | |
onlyif => "ls /var/db/.puppet_github_${reporepl}_*" | |
} | |
} | |
file { $inst_marker_file: | |
ensure => $rev ? { | |
'master' => absent, | |
default => present}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment