Skip to content

Commit

Permalink
feat(composer) deprecate composer dependency (#40)
Browse files Browse the repository at this point in the history
* feat(willdurand) use new composer puppet module

Use the community accepted standard composer module

* fix(composer) change to use willdurand composer class

* fix(syntax) remove undefined param

* fix(home) change to be in default path

* change again

* add composer bin dir param

* change bin dir

* fix(path) fix path default

* feat(dl) use github to dl drush

* remove composer dep

* fix(drush 8) set to only work with drush 8 for now

* fix(require) remove some deps

* simplify drush dl

* fix drush dep

* use exec to dl

* remove drush init

* fix(version) ensure dropfort update is dl 7

* update php dep

* fix(mode) use string

* update to drush 8.1.15

* add version improvements

* add version check

* fix typo

* fix test

* switch to unless

* refac(deps) use download

* fix(db) disable db requirement

* disable db require for now

* refac(deps) remove deps

* remove deps

* feat(launcher) update launcher to 0.6.0
  • Loading branch information
minorOffense authored Apr 22, 2019
1 parent 64746b8 commit c1e7fb0
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 87 deletions.
24 changes: 11 additions & 13 deletions manifests/arr.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@
if $db_url {
$dburl = "--db-url=${db_url}"

if $db_url =~ /^pgsql:/ {
$php_pgsql_package = hiera('php::pgsql_package', 'php-pgsql')
ensure_packages([$php_pgsql_package], {'ensure' => 'installed'})
$db_require = Php::Extension['pgsql']
} else {
$php_mysql_package = hiera('php::mysql_package', 'php-mysql')
ensure_packages([$php_mysql_package], {'ensure' => 'installed'})
$db_require = Php::Extension['mysql']
}
#if $db_url =~ /^pgsql:/ {
# $php_pgsql_package = hiera('php::pgsql_package', 'php-pgsql')
# ensure_packages([$php_pgsql_package], {'ensure' => 'installed'})
# $db_require = Php::Extension['pgsql']
#} else {
# $php_mysql_package = hiera('php::mysql_package', 'php-mysql')
# ensure_packages([$php_mysql_package], {'ensure' => 'installed'})
# $db_require = Php::Extension['mysql']
#}
}

if $overwrite {
Expand All @@ -60,14 +60,12 @@
creates => "${destination}/index.php",
timeout => 0,
require => [
Exec['drush_status_check'],
Exec['drush-global-download'],
Class['php::cli'],
Php::Extension['mbstring'],
Php::Extension['pdo'],
Php::Extension['process'],
Php::Extension['xml'],
Php::Extension['gd'],
$db_require,
#$db_require,
],
}
}
2 changes: 1 addition & 1 deletion manifests/cc.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
exec {"drush-cc-${name}":
command => "drush cc $cache $siteroot $u -y",
onlyif => $onlyif,
require => Exec['drush_status_check'],
require => Exec['drush-global-download'],
}
}
2 changes: 1 addition & 1 deletion manifests/dis.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
onlyif => $onlyif,
# @todo add a check here that the module is enabled. That way
# puppet doesn't constantly run drush dis and clear the drupal cache
require => Exec['drush_status_check'],
require => Exec['drush-global-download'],
}
}
2 changes: 1 addition & 1 deletion manifests/dl.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
exec {"drush-dl-${name}":
command => "drush dl $project_name $dst $src $dm $dpr $siteroot $u -y",
onlyif => $onlyif,
require => Exec['drush_status_check'],
require => Exec['drush-global-download'],
}

if defined(Exec["drush-en-${name}"]) {
Expand Down
2 changes: 1 addition & 1 deletion manifests/en.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
onlyif => $onlyif,
# @todo add a check here that the module is not enabled. That way
# puppet doesn't constantly run drush en and clear the drupal cache
require => Exec['drush_status_check'],
require => Exec['drush-global-download'],
}
}
79 changes: 36 additions & 43 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,60 +1,63 @@

class drush (
$version = '6.*',
$version = '8.1.15',
$drush_cmd = $::drush::params::drush_cmd,
$composer_home = $::drush::params::composer_home
$drush_release_url = $::drush::params::drush_release_url
) inherits ::drush::params {


Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/", "/usr/local/bin", "/usr/local/sbin"], environment => ["HOME=${::root_home}"] }

ensure_packages(['zip', 'unzip', 'gzip', 'tar', 'bash-completion'])

file {"${composer_home}":
ensure => 'directory',
# Pick the latest stable version if using wildcard.
case $version[0] {
'6': { $version_actual = '6.7.0' }
'7': { $version_actual = '7.4.0' }
'8': { $version_actual = '8.1.15' }
'9': { $version_actual = '0.6.0' }
default: { $version_actual = '8.1.15' } # Default to latest stable.
}

class { 'composer':
logoutput => true,
composer_home => $composer_home,
require => File["${composer_home}"],
}
# Download the drush version.
$drush_dl_url = "${drush_release_url}/${version_actual}/drush.phar"

if str2bool("$hasdrush") {
file {"${drush_cmd}":
ensure => 'link',
target => "${composer_home}/vendor/bin/drush",
if $version[0] == '9' {
exec{'drush-global-download':
command => "/usr/bin/wget -O ${drush_cmd} https://github.com/drush-ops/drush-launcher/releases/download/${version_actual}/drush.phar",
creates => "${drush_cmd}",
returns => [0],
require => Package['wget'],
}
} else {
composer::exec {"drush_global":
cmd => 'require',
cwd => $composer_home,
packages => ["drush/drush:${version}"],
global => true,
require => Class['composer'],
}
-> file {"${drush_cmd}":
ensure => 'link',
target => "${composer_home}/vendor/bin/drush",
require => Composer::Exec['drush_global'],
}
else {
exec{'drush-global-download':
command => "/usr/bin/wget -q ${drush_dl_url} -O ${drush_cmd}",
creates => "${drush_cmd}",
returns => [0],
unless => "test $(${drush_cmd} --version --pipe) == ${version_actual}",
require => Package['wget'],
}
-> exec{"drush-global-status":
command => "drush status",
cwd => "${composer_home}",
-> exec {'drush_status_check':
command => 'phar ${drush_cmd} status',
require => File["${drush_cmd}"],
refreshonly => 'true',
}
}

file {"${drush_cmd}":
ensure => 'present',
mode => '+x',
require => Exec['drush-global-download'],
}

file {"/etc/drush":
ensure => 'directory',
owner => 'root',
group => 'root',
mode => '0755',
require => File["${drush_cmd}"],
}
-> exec {'drush_status_check':
command => 'drush status',
require => File["${drush_cmd}"],
refreshonly => 'true',
}

# Add global commands directory
file {"/etc/drush/commands":
Expand All @@ -65,16 +68,6 @@
require => File["/etc/drush"],
}

file {'/etc/bash_completion.d/drush.complete.sh':
ensure => 'link',
owner => 'root',
target => "${composer_home}/vendor/drush/drush/drush.complete.sh",
require => [
Package['bash-completion'],
Exec['drush_status_check'],
],
}

# Files for controlling requests during drush make operations
file {"drush-make-exist-curlrc":
ensure => 'present',
Expand Down
5 changes: 3 additions & 2 deletions manifests/make.pp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
file {"/tmp/drush_make_prep-${filehash}.sh":
ensure => 'present',
source => ["puppet:///modules/drush/drush_make_prep.sh"],
mode => 0755,
mode => '0755',
}

# If the make is from the github api...
Expand All @@ -153,6 +153,7 @@
drush::dl{"root-dropfort_update-${filehash}":
project_name => 'dropfort_update',
destination => "${::root_home}/.drush",
default_major => 7, #@todo make this pick the right version automatically
require => [File['drush-dir-exist'], File['drush-root-drushrc']],
before => Exec["drush-make-${filehash}"]
}
Expand Down Expand Up @@ -183,7 +184,7 @@
exec {"drush-make-${filehash}":
command => "drush make '$makefile' $build_path $cnc $cd $d $dm $fc $ic $lib $mudu $m5 $nca $ncl $ncl $nco $ngi $npt $pi $proj $src $tr $tst $trans $v $wc $durl $dut -y",
cwd => '/tmp',
require => [Exec['drush_status_check'], File["/tmp/drush_make_prep-${filehash}.sh"]],
require => [Exec['drush-global-download'], File["/tmp/drush_make_prep-${filehash}.sh"]],
timeout => 0, # Drush make can take a while. We disable timeouts for this reason
onlyif => ["/tmp/drush_make_prep-${filehash}.sh ${build_path}", "${onlyif}"]
}->
Expand Down
8 changes: 3 additions & 5 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
# Sample Usage:
#
class drush::params {
$drush_release_url = "https://github.com/drush-ops/drush/releases/download"

if $::operatingsystem == 'Ubuntu' or $::osfamily == 'Debian' {
if $::operatingsystem == 'Ubuntu' or $::osfamily == 'Debian' {
$drush_cmd = '/usr/bin/drush'
$composer_home = '/usr/local/share/composer'
} elsif $::osfamily == 'RedHat' {
$composer_home = '/usr/local/share/composer'
$drush_cmd = '/usr/bin/drush'
case $::operatingsystemmajrelease {
'7': {
Expand All @@ -31,6 +30,5 @@
}
} elsif $::osfamily == 'FreeBSD' {
$drush_cmd = '/usr/local/bin/drush'
$composer_home = '/usr/local/share/composer'
}
}
}
24 changes: 11 additions & 13 deletions manifests/si.pp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
if $db_url {
$dburl = "--db-url=${db_url}"

if $db_url =~ /^pgsql:/ {
$php_pgsql_package = hiera('php::pgsql_package', 'php-pgsql')
ensure_packages([$php_pgsql_package], {'ensure' => 'installed'})
$db_require = Php::Extension['pgsql']
} else {
$php_mysql_package = hiera('php::mysql_package', 'php-mysql')
ensure_packages([$php_mysql_package], {'ensure' => 'installed'})
$db_require = Php::Extension['mysql']
}
#if $db_url =~ /^pgsql:/ {
# $php_pgsql_package = hiera('php::pgsql_package', 'php-pgsql')
## ensure_packages([$php_pgsql_package], {'ensure' => 'installed'})
# $db_require = Php::Extension['pgsql']
#} else {
#$php_mysql_package = hiera('php::mysql_package', 'php-mysql')
# #ensure_packages([$php_mysql_package], {'ensure' => 'installed'})
#$db_require = Php::Extension['mysql']
#}
}

if $account_name {
Expand Down Expand Up @@ -89,14 +89,12 @@
timeout => 0,
require => [
#File["${$site_root}"],
Exec['drush_status_check'],
Exec['drush-global-download'],
Class['php::cli'],
Php::Extension['mbstring'],
Php::Extension['pdo'],
Php::Extension['process'],
Php::Extension['xml'],
Php::Extension['gd'],
$db_require,
#$db_require,
]
}
}
2 changes: 1 addition & 1 deletion manifests/sql_sync.pp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
onlyif => $onlyif,
timeout => 0,
require => [
Exec['drush_status_check'],
Exec['drush-global-download'],
]
}
}
2 changes: 1 addition & 1 deletion manifests/uninstall.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
->exec {"drush-uninstall-${name}":
command => "drush pm-uninstall ${name} -y",
cwd => $sitepath,
require => Exec['drush_status_check'],
require => Exec['drush-global-download'],
}
}
2 changes: 1 addition & 1 deletion manifests/up.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
->exec {"drush-up":
command => "drush pm-update -y",
cwd => $sitepath,
require => Exec['drush_status_check'],
require => Exec['drush-global-download'],
}
}
2 changes: 1 addition & 1 deletion manifests/updatedb.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
onlyif => $onlyif,
timeout => 0,
require => [
Exec['drush_status_check'],
Exec['drush-global-download'],
]
}
}
5 changes: 2 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
"project_page": "https://github.com/coldfrontlabs/coldfrontlabs-drush",
"issues_url": "https://github.com/coldfrontlabs/coldfrontlabs-drush/issues",
"dependencies": [
{"name":"puppetlabs/stdlib","version_requirement":">= 4.3.2"},
{"name":"tPl0ch/composer", "version_requirement":">= 2.0.0"},
{"name":"puppetlabs-stdlib","version_requirement":">= 4.3.2"},
{"name":"stahnma/epel", "version_requirement":">= 1.0.1"},
{"name":"puppetlabs/concat", "version_requirement":">= 1.0.4"},
{"name":"puppetlabs/git", "version_requirement":">= 0.2.0"},
{"name":"mayflower/php", "version_requirement":">= 3.2.2"}
{"name":"puppet/php", "version_requirement":">= 5.0.0"}
]
}

0 comments on commit c1e7fb0

Please sign in to comment.