Skip to content

Instantly share code, notes, and snippets.

@deltamualpha
Last active August 29, 2015 14:06
Show Gist options
  • Save deltamualpha/614e1799f97c8be298f8 to your computer and use it in GitHub Desktop.
Save deltamualpha/614e1799f97c8be298f8 to your computer and use it in GitHub Desktop.
php phar download puppet
# 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,
}
}
@deltamualpha
Copy link
Author

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.

@DarrenN
Copy link

DarrenN commented Sep 6, 2014

lulz

@deltamualpha
Copy link
Author

(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