Skip to content

Commit

Permalink
Merge pull request #274 from igalic/use-archive
Browse files Browse the repository at this point in the history
use voxpupuli/archive to download composer
  • Loading branch information
alexjfisher committed Dec 1, 2016
2 parents a87005f + 30410e3 commit 5ad2323
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 41 deletions.
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ fixtures:
apt: "git://github.com/puppetlabs/puppetlabs-apt.git"
zypprepo: "git://github.com/deadpoint/puppet-zypprepo.git"
inifile: "git://github.com/puppetlabs/puppetlabs-inifile.git"
archive: "git://github.com/voxpupuli/puppet-archive.git"
symlinks:
php: "#{source_dir}"
45 changes: 21 additions & 24 deletions manifests/composer.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
# [*path*]
# Holds path to the Composer executable
#
# [*environment*]
# Environment variables for settings such as http_proxy, https_proxy, or ftp_proxy
# [*proxy_type*]
# proxy server type (none|http|https|ftp)
#
# [*manage_curl*]
# Should we ensure curl is installed or do you want to manage that?
# [*proxy_server*]
# specify a proxy server, with port number if needed. ie: https://example.com:8080.
#
# [*auto_update*]
# Defines if composer should be auto updated
Expand All @@ -24,13 +24,13 @@
# UNIX group of the root user
#
class php::composer (
$source = $::php::params::composer_source,
$path = $::php::params::composer_path,
$environment = undef,
$manage_curl = true,
$auto_update = true,
$max_age = $::php::params::composer_max_age,
$root_group = $::php::params::root_group,
$source = $::php::params::composer_source,
$path = $::php::params::composer_path,
$proxy_type = undef,
$proxy_server = undef,
$auto_update = true,
$max_age = $::php::params::composer_max_age,
$root_group = $::php::params::root_group,
) inherits ::php::params {

if $caller_module_name != $module_name {
Expand All @@ -42,15 +42,11 @@
validate_bool($auto_update)
validate_re("x${max_age}", '^x\d+$')

if $manage_curl { ensure_packages(['curl']) }

exec { 'download composer':
command => "curl -L ${source} -o ${path}",
environment => $environment,
creates => $path,
path => ['/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/',
'/usr/local/bin', '/usr/local/sbin'],
require => [Class['::php::cli'],Package['curl']],
archive { 'download composer':
source => $source,
creates => $path,
proxy_type => $proxy_type,
proxy_server => $proxy_server,
} ->
file { $path:
mode => '0555',
Expand All @@ -60,10 +56,11 @@

if $auto_update {
class { '::php::composer::auto_update':
max_age => $max_age,
source => $source,
path => $path,
environment => $environment,
max_age => $max_age,
source => $source,
path => $path,
proxy_type => $proxy_type,
proxy_server => $proxy_server,
}
}
}
23 changes: 17 additions & 6 deletions manifests/composer/auto_update.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
# [*path*]
# Holds path to the Composer executable
#
# [*environment*]
# Environment variables for settings such as http_proxy, https_proxy, or ftp_proxy
# [*proxy_type*]
# proxy server type (none|http|https|ftp)
#
# [*proxy_server*]
# specify a proxy server, with port number if needed. ie: https://example.com:8080.
#
#
# === Examples
#
Expand All @@ -25,18 +29,25 @@
$max_age,
$source,
$path,
$environment = undef,
$proxy_type = undef,
$proxy_server = undef,
) {

if $caller_module_name != $module_name {
warning('php::composer::auto_update is private')
}

if $proxy_type and $proxy_server {
$env = {"${proxy_type}_proxy" => $proxy_server}
} else {
$env = {}
}

exec { 'update composer':
command => "curl -L ${source} -o ${path}",
environment => $environment,
command => "${path} self-update",
environment => $env,
onlyif => "test `find '${path}' -mtime +${max_age}`",
path => [ '/bin/', '/sbin/' , '/usr/bin/', '/usr/sbin/', '/usr/local/bin', '/usr/local/sbin' ],
require => File[$path],
require => [File[$path], Class['::php::cli']],
}
}
19 changes: 8 additions & 11 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@
# [*apache_config*]
# Manage apache's mod_php configuration
#
# [*environment*]
# Environment variables for settings such as http_proxy, https_proxy, or ftp_proxy.
# These are passed through to the underlying exec(s), so it follows the same format
# of the exec type `environment`
# [*proxy_type*]
# proxy server type (none|http|https|ftp)
#
# [*manage_curl*]
# Should we ensure curl is installed or do you want to manage that?
# [*proxy_server*]
# specify a proxy server, with port number if needed. ie: https://example.com:8080.
#
# [*extensions*]
# Install PHP extensions, this is overwritten by hiera hash `php::extensions`
Expand Down Expand Up @@ -123,8 +121,8 @@
$pear_ensure = $::php::params::pear_ensure,
$phpunit = false,
$apache_config = false,
$environment = undef,
$manage_curl = true,
$proxy_type = undef,
$proxy_server = undef,
$extensions = {},
$settings = {},
$package_prefix = $::php::params::package_prefix,
Expand All @@ -147,7 +145,6 @@
validate_string($pear_ensure)
validate_bool($phpunit)
validate_bool($apache_config)
validate_bool($manage_curl)
validate_hash($extensions)
validate_hash($settings)
validate_hash($fpm_pools)
Expand Down Expand Up @@ -221,8 +218,8 @@
if $composer {
Anchor['php::begin'] ->
class { '::php::composer':
environment => $environment,
manage_curl => $manage_curl,
proxy_type => $proxy_type,
proxy_server => $proxy_server,
} ->
Anchor['php::end']
}
Expand Down
1 change: 1 addition & 0 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
{ "name": "puppetlabs/apt", "version_requirement": ">= 1.8.0 < 3.0.0" },
{ "name": "puppetlabs/inifile", "version_requirement": "1.x" },
{ "name": "darin/zypprepo", "version_requirement": "1.x" },
{ "name": "puppet/archive", "version_requirement": "1.x" },
{ "name": "example42/yum", "version_requirement": "2.x" }
],
"requirements": [
Expand Down

0 comments on commit 5ad2323

Please sign in to comment.