Last active
August 29, 2015 14:06
-
-
Save deltamualpha/614e1799f97c8be298f8 to your computer and use it in GitHub Desktop.
php phar download puppet
This file contains 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
# install a phar file from a remote server directly | |
define php::phar ($url, $insecure = false, $target = $title) { | |
$split = split($url, '/') | |
$filename = $split[-1] | |
# for wget bug workarounds | |
if ($insecure == true) { | |
$wget_options = "--no-check-certificate" | |
} | |
exec { "download-phar-${title}": | |
command => "wget ${wget_options} ${url}", | |
cwd => '/var/tmp', | |
path => [ '/bin', '/usr/bin'], | |
notify => Exec["chmod-${filename}"], | |
creates => "/var/tmp/${filename}" | |
} | |
exec { "chmod-${filename}": | |
command => "chmod +x ${filename}", | |
cwd => '/var/tmp', | |
path => [ '/bin', '/usr/bin'], | |
notify => Exec["cp-${filename}"], | |
require => Exec["download-phar-${title}"], | |
refreshonly => true, | |
} | |
exec { "cp-${filename}": | |
command => "cp ${filename} /usr/local/bin/${target}", | |
cwd => '/var/tmp', | |
path => [ '/bin', '/usr/bin'], | |
require => Exec["chmod-${filename}"], | |
refreshonly => true, | |
} | |
} |
lulz
(It should be noted that, yeah, this is a way to install arbitrary binaries from remote servers and make them executable. Use with caution.)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does calling this with
insecure => true
sound like a bad idea to you too? Too bad! Try and avoid it in environments you actually care about.