From 3081cd318474582fc1e160148b1bdb6297e73a72 Mon Sep 17 00:00:00 2001 From: James Williams Date: Thu, 9 Aug 2018 16:47:19 +0100 Subject: [PATCH 1/3] Issue #140: Drush aliases inside parrot. --- modules/http_stack/manifests/apache/site.pp | 33 ++++++++++++++++--- .../manifests/components/php/drush_alias.pp | 25 ++++++++++++++ .../templates/php/drush_alias.erb | 10 ++++++ 3 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 modules/parrot_drush/manifests/components/php/drush_alias.pp create mode 100644 modules/parrot_drush/templates/php/drush_alias.erb 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..0725553 --- /dev/null +++ b/modules/parrot_drush/manifests/components/php/drush_alias.pp @@ -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'], + } +} 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 +); From 04d3fd8b46c9d1e8a06dcc4e76fcc2831d7d904f Mon Sep 17 00:00:00 2001 From: James Williams Date: Fri, 10 Aug 2018 11:19:20 +0100 Subject: [PATCH 2/3] Issue #140: Ensure home drush dir. No need for root aliases. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix owner & group of vagrant user’s alias file too. --- .../manifests/components/php/drush_alias.pp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/modules/parrot_drush/manifests/components/php/drush_alias.pp b/modules/parrot_drush/manifests/components/php/drush_alias.pp index 0725553..8e2f857 100644 --- a/modules/parrot_drush/manifests/components/php/drush_alias.pp +++ b/modules/parrot_drush/manifests/components/php/drush_alias.pp @@ -7,19 +7,18 @@ ) { - 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'], + # Create home directories for the users that will be using Drush. + file { '/home/vagrant/.drush': + ensure => 'directory', + owner => 'vagrant', + group => 'vagrant', } - file {"/root/.drush/$name.aliases.drushrc.php": + file {"/home/vagrant/.drush/$name.aliases.drushrc.php": ensure => $ensure, - owner => 'www-data', - group => 'www-data', + owner => 'vagrant', + group => 'vagrant', content => template('parrot_drush/php/drush_alias.erb'), - #require => File['/root/.drush'], + require => File['/home/vagrant/.drush'], } } From 83acb3c058e5d863cb92505a0d3881e037375007 Mon Sep 17 00:00:00 2001 From: James Williams Date: Fri, 10 Aug 2018 14:09:14 +0100 Subject: [PATCH 3/3] Issue #140: Fix ensuring home drush dir. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Oops, totally hadn’t tested the previous commit. --- modules/http_stack/manifests/apache.pp | 7 +++++++ .../parrot_drush/manifests/components/php/drush_alias.pp | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) 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/parrot_drush/manifests/components/php/drush_alias.pp b/modules/parrot_drush/manifests/components/php/drush_alias.pp index 8e2f857..5adddff 100644 --- a/modules/parrot_drush/manifests/components/php/drush_alias.pp +++ b/modules/parrot_drush/manifests/components/php/drush_alias.pp @@ -7,13 +7,6 @@ ) { - # Create home directories for the users that will be using Drush. - file { '/home/vagrant/.drush': - ensure => 'directory', - owner => 'vagrant', - group => 'vagrant', - } - file {"/home/vagrant/.drush/$name.aliases.drushrc.php": ensure => $ensure, owner => 'vagrant',