diff --git a/modules/http_stack/manifests/apache.pp b/modules/http_stack/manifests/apache.pp index 4f98eb1..863a9b7 100644 --- a/modules/http_stack/manifests/apache.pp +++ b/modules/http_stack/manifests/apache.pp @@ -124,6 +124,13 @@ ensure => "directory", } + # Create home directories for the users that will be using Drush. + file { '/home/vagrant/.drush': + ensure => 'directory', + owner => 'vagrant', + group => 'vagrant', + } + # Find the sites. $site_names_string = generate('/usr/bin/find', '-L', '/vagrant_sites/' , '-type', 'd', '-printf', '%f\0', '-maxdepth', '1', '-mindepth', '1') $site_names = split($site_names_string, '\0') diff --git a/modules/http_stack/manifests/apache/site.pp b/modules/http_stack/manifests/apache/site.pp index 0ffbf9d..188c549 100644 --- a/modules/http_stack/manifests/apache/site.pp +++ b/modules/http_stack/manifests/apache/site.pp @@ -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. @@ -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" + } } } } @@ -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://', + } + } } diff --git a/modules/parrot_drush/manifests/components/php/drush_alias.pp b/modules/parrot_drush/manifests/components/php/drush_alias.pp new file mode 100644 index 0000000..5adddff --- /dev/null +++ b/modules/parrot_drush/manifests/components/php/drush_alias.pp @@ -0,0 +1,17 @@ +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 => 'vagrant', + group => 'vagrant', + content => template('parrot_drush/php/drush_alias.erb'), + require => File['/home/vagrant/.drush'], + } +} diff --git a/modules/parrot_drush/templates/php/drush_alias.erb b/modules/parrot_drush/templates/php/drush_alias.erb new file mode 100644 index 0000000..f6d0f13 --- /dev/null +++ b/modules/parrot_drush/templates/php/drush_alias.erb @@ -0,0 +1,10 @@ +'] = 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 +);