Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
Issue #140: Drush aliases inside parrot.
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherjames committed Aug 9, 2018
1 parent 4d8381a commit 3081cd3
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
33 changes: 28 additions & 5 deletions modules/http_stack/manifests/apache/site.pp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
define http_stack::apache::site () {
define http_stack::apache::site (
$ensure = 'present',
$drush_alias = true,
) {

# Special handling for a 'webroot' subdirectory.
# We pretend like it's the root.
Expand All @@ -14,22 +17,34 @@
$f2 = "/vagrant_sites/$name/.parrot-php7"
$_exists2 = inline_template("<%= File.exists?('$f2') %>")
case $_exists2 {
"true": { $fpm_port = "9997" } # PHP 7.1
"true": { # PHP 7.1
$fpm_port = "9997"
$php = "/usr/bin/php7.1"
}
"false": {

# Test for PHP 7.1
$f3 = "/vagrant_sites/$name/.parrot-php7.1"
$_exists3 = inline_template("<%= File.exists?('$f3') %>")
case $_exists3 {
"true": { $fpm_port = "9997" } # PHP 7.1
"true": { # PHP 7.1
$fpm_port = "9997"
$php = "/usr/bin/php7.1"
}
"false": {

# Test for PHP 7.0
$f4 = "/vagrant_sites/$name/.parrot-php7.0"
$_exists4 = inline_template("<%= File.exists?('$f4') %>")
case $_exists4 {
"true": { $fpm_port = "9998" } # PHP 7.0
"false": { $fpm_port = "9999" } # PHP 5.6
"true": { # PHP 7.0
$fpm_port = "9998"
$php = "/usr/bin/php7.0"
}
"false": { # PHP 5.6
$fpm_port = "9999"
$php = "/usr/bin/php5.6"
}
}
}
}
Expand Down Expand Up @@ -73,4 +88,12 @@
group => 'root',
}

if $drush_alias {
parrot_drush::components::php::drush_alias { $name:
root => "/vagrant_sites/$name$webroot_subdir",
ensure => $ensure,
php_executable => $php,
protocol => 'https://',
}
}
}
25 changes: 25 additions & 0 deletions modules/parrot_drush/manifests/components/php/drush_alias.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
define parrot_drush::components::php::drush_alias (
$root,
$ensure = 'present',
$uri = $name,
$php_executable = undef,
$protocol = '',
)
{

file {"/home/vagrant/.drush/$name.aliases.drushrc.php":
ensure => $ensure,
owner => 'root',
group => 'root',
content => template('parrot_drush/php/drush_alias.erb'),
#require => File['/home/vagrant/.drush'],
}

file {"/root/.drush/$name.aliases.drushrc.php":
ensure => $ensure,
owner => 'www-data',
group => 'www-data',
content => template('parrot_drush/php/drush_alias.erb'),
#require => File['/root/.drush'],
}
}
10 changes: 10 additions & 0 deletions modules/parrot_drush/templates/php/drush_alias.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

$aliases['<%= @name %>'] = array(
'uri' => '<%= @protocol %><%= @uri %>',
'root' => '<%= @root %>',
<%- if @php_executable -%>
'php' => '<%= @php_executable %>',
<%- end -%>
'local' => TRUE, // Required to avoid double-calling, see https://github.com/drush-ops/drush/issues/1870
);

0 comments on commit 3081cd3

Please sign in to comment.