From fe6d344f683f06e7af1564db1fbc12cf7940294e Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Wed, 3 Nov 2021 12:36:05 -0400 Subject: [PATCH 01/21] feat(install): add initial install for composer projects --- manifests/distro.pp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/manifests/distro.pp b/manifests/distro.pp index 672e305..780970d 100644 --- a/manifests/distro.pp +++ b/manifests/distro.pp @@ -20,6 +20,12 @@ if ($distro_build_type == 'composer' or $api_version == 8) { # Do nothing for now. # @todo run composer install or just leave it be? + exec {"composer-install-drush-${buildname}": + command => "composer create-project drupal/recommended-project ${name} -y", + cwd => $distro_root, + path => ['/usr/local/bin', '/usr/bin'], + creates => "${distro_root}/${name}", + } } elsif ($distro_build_type == 'get') { From 5cd139e7d3be11873b00c67dcc4ce555e5479ae3 Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Wed, 3 Nov 2021 12:57:49 -0400 Subject: [PATCH 02/21] refactor(distro): remove deprecated install methods Drop drush make Drop wget Drop archive restore --- manifests/distro.pp | 143 ++++---------------------------------------- 1 file changed, 12 insertions(+), 131 deletions(-) diff --git a/manifests/distro.pp b/manifests/distro.pp index 780970d..032dc02 100644 --- a/manifests/distro.pp +++ b/manifests/distro.pp @@ -1,14 +1,14 @@ # Defines a drupalsi::distro resource define drupalsi::distro ($distribution = 'drupal', - $api_version = 7, + $api_version = 8, $distro_root = '/var/www/html', - $distro_build_type = 'get', - $distro_build_location = 'https://updates.drupal.org/release-history', + $distro_build_type = 'composer', + $distro_build_location = 'https://updates.drupal.org/release-history', # deprecated. $distro_build_args = {}, $omit_files = {} ) { - include drush + include ::drush # Steps: # 1. Check if the distro is already there @@ -26,39 +26,23 @@ path => ['/usr/local/bin', '/usr/bin'], creates => "${distro_root}/${name}", } - } - elsif ($distro_build_type == 'get') { - - # Set some defaults for the GET build type - if !$distro_build_location { - $distro_build_location = '' - } - - drush::dl {"drush-dl-${buildname}": - source => $distro_build_location, - destination => $distro_root, - project_name => $distribution, - default_major => $api_version, - drupal_project_rename => $name, - onlyif => "test ! -f ${distro_root}/${name}/index.php", - } - $buildaction = "Drush::Dl[drush-dl-${buildname}]" - - file {"${distro_root}/${name}/sites/sites.php": - ensure => 'present', - require => Drush::Dl["drush-dl-${buildname}"], - content => template('drupalsi/sites.php.erb'), - mode => '0640', + exec {"composer-require-drush-${buildname}": + command => "composer require drush/drush", + cwd => "${distro_root}/${name}", + path => ['/usr/local/bin', '/usr/bin'], + subscribe => Exec["composer-install-drush-${buildname}"], + refreshonly => true, } } elsif ($distro_build_type == 'git') { - include git + include ::git if has_key($distro_build_args, 'git_branch') { $branch = join([ "-b ", '"', $distro_build_args['git_branch'], '"']) } else { $branch = "" } + # @todo change to use vcsrepo puppet module. exec {"git-clone-${buildname}": command => "git clone ${branch} ${distro_build_location} ${distro_root}/${name}", creates => "${distro_root}/${name}/index.php", @@ -77,109 +61,6 @@ mode => '0644', } } - elsif ($distro_build_type == 'make') { - if $distro_build_args['url'] { - if $distro_build_args['url_args'] { - $path = "${distro_build_args['url']}?${distro_build_args[url_args]}" - } - else { - $path = "${distro_build_args['url']}" - } - } - else { - $path = $distro_build_location - } - - drush::make {"drush-make-${buildname}": - makefile => "$path", - build_path => "${distro_root}/${name}", - concurrency => $distro_build_args[concurrency], - contrib_destination => $distro_build_args[contrib_destination], - dev => $distro_build_args[dev], - download_mechanism => $distro_build_args[download_mechanism], - force_complete => $distro_build_args[force_complete], - ignore_checksums => $distro_build_args[ignore_checksums], - libraries => $distro_build_args[libraries], - make_update_default_url => $distro_build_args[make_update_default_url], - md5 => $distro_build_args[md5], - no_cache => $distro_build_args[no_cache], - no_clean => $distro_build_args[no_clean], - no_core => $distro_build_args[no_core], - no_gitinfofile => $distro_build_args[no_gitinfofile], - no_patch_txt => $distro_build_args[no_patch_txt], - prepare_install => $distro_build_args[prepare_install], - projects => $distro_build_args[projects], - source => $distro_build_args[source], - tar => $distro_build_args[tar], - test => $distro_build_args[test], - translations => $distro_build_args[translations], - version => $distro_build_args[version], - working_copy => $distro_build_args[working_copy], - dropfort_userauth_token => $distro_build_args[dropfort_userauth_token], - dropfort_url => $distro_build_args[dropfort_url], - } - - # Generate the sites.php file for use with all sites installed on this distro - file {"${distro_root}/${name}/sites/sites.php": - ensure => 'present', - require => Drush::Make["drush-make-${buildname}"], - content => template('drupalsi/sites.php.erb'), - mode => '0640', - } - - $buildaction = "Drush::Make[drush-make-${buildname}]" - } - elsif ($distro_build_type == 'archive') { - # Ensure the hash is there and the proper length - validate_slength($distro_build_args[hash], 32) - - # Download the file - if $distro_build_args['url_args'] { - $path = "${distro_build_location}?${distro_build_args[url_args]}" - } - else { - $path = "${distro_build_location}" - } - - if $distro_build_args[validate_certificate] { - $validate = false - } - else { - $validate = true - } - - wget::fetch {"drupalsi-archive-wget-${buildname}": - timeout => 0, - source => $path, - destination => "/tmp/drush-archive-${buildname}", - verbose => false, - nocheckcertificate => $validate, - source_hash => $distro_build_args[hash], - user => $distro_build_args[dl_user], - password => $distro_build_args[dl_pass], - before => Drush::Arr["drush-arr-${buildname}"], - } - - drush::arr {"drush-arr-${buildname}": - filename => "/tmp/drush-archive-${buildname}", - destination => "${distro_root}/${name}", - db_prefix => $distro_build_args[db_prefix], - db_su => $distro_build_args[db_su], - db_su_pw => $distro_build_args[db_su_pw], - db_url => $distro_build_args[db_url], - #overwrite => $distro_build_args[overwrite], Overwrite is ignored on purpose. DrupalSi will not overwrite an existing site. - tar_options => $distro_build_args[tar_options], - } - - $buildaction = "Drush::Arr[drush-arr-${buildname}]" - - # Ensure the file is there even if it's blank. - file {"${distro_root}/${name}/sites/sites.php": - ensure => 'present', - require => Drush::Arr["drush-arr-${buildname}"], - mode => '0640', - } - } if !empty($omit_files) { # See below why we're doing this From f9429b810db57e7d4474dc6ed90553db2deebfb1 Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Wed, 3 Nov 2021 12:59:42 -0400 Subject: [PATCH 03/21] refactor(install): remove install profiles Git and composer take those into account automatically --- manifests/profile.pp | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 manifests/profile.pp diff --git a/manifests/profile.pp b/manifests/profile.pp deleted file mode 100644 index fbd9d78..0000000 --- a/manifests/profile.pp +++ /dev/null @@ -1,9 +0,0 @@ -# Defines a drupalsi::profile resource - -define drupalsi::profile ($profile) { - include drush - - - # @todo download the profiles based on their build-type - # @todo move the install profile into place -} From 2dbb8e4baceb7069dea94d2a7e4f097ddb6584ee Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Wed, 3 Nov 2021 13:00:10 -0400 Subject: [PATCH 04/21] refactor(install): remove install profiles Not required for composer or git installs --- manifests/init.pp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index a745eb3..d61ceba 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -4,7 +4,7 @@ include drush # Assume jq is available. If other modules want to fix deps go for it. - ensure_packages('jq', {'ensure' => 'present'}) + ensure_packages('jq', {'ensure' => 'latest'}) # Add the script to set the Drupal directory permissions. file {'drupal-fix-permissions-script': @@ -17,9 +17,6 @@ $distros = hiera_hash('drupalsi::distros', {}) create_resources(drupalsi::distro, $distros) - $profiles = hiera_hash('drupalsi::profiles', {}) - create_resources(drupalsi::profile, $profiles) - $sites = hiera_hash('drupalsi::sites', {}) create_resources(drupalsi::site, $sites) } From df8f4c2e6c6724f641abe6c87416f1d2e03b5616 Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Wed, 3 Nov 2021 13:00:49 -0400 Subject: [PATCH 05/21] Delete drush.make.erb --- templates/drush.make.erb | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 templates/drush.make.erb diff --git a/templates/drush.make.erb b/templates/drush.make.erb deleted file mode 100644 index 4dacd2b..0000000 --- a/templates/drush.make.erb +++ /dev/null @@ -1,4 +0,0 @@ -core = <%= @api_version %>.x -api = 2 - -includes[<%= @distribution %>] = '<%= @path %>'; \ No newline at end of file From cbf642771ea9c28a2e1f0b6741324dbc2729ba34 Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Wed, 3 Nov 2021 13:01:57 -0400 Subject: [PATCH 06/21] Update htaccess-public.erb --- templates/htaccess-public.erb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/templates/htaccess-public.erb b/templates/htaccess-public.erb index b3afe37..48dfb43 100644 --- a/templates/htaccess-public.erb +++ b/templates/htaccess-public.erb @@ -17,3 +17,13 @@ SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006 php_flag engine off + +# If we know how to do it safely, disable the PHP engine entirely. + + php_flag engine off + + +# If we know how to do it safely, disable the PHP engine entirely. + + php_flag engine off + From 9ef7d8aa600dfd4c5a8abc7e7a2bdabcd9a6916b Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Wed, 3 Nov 2021 13:02:32 -0400 Subject: [PATCH 07/21] Update htaccess-private.erb --- templates/htaccess-private.erb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/templates/htaccess-private.erb b/templates/htaccess-private.erb index 33926d9..87b0849 100644 --- a/templates/htaccess-private.erb +++ b/templates/htaccess-private.erb @@ -26,3 +26,13 @@ SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006 php_flag engine off + +# If we know how to do it safely, disable the PHP engine entirely. + + php_flag engine off + + +# If we know how to do it safely, disable the PHP engine entirely. + + php_flag engine off + From 8035a0501ad7984e5f96c5ef166f0ece84f9da29 Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Fri, 12 Nov 2021 16:16:30 -0500 Subject: [PATCH 08/21] Update distro.pp --- manifests/distro.pp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/manifests/distro.pp b/manifests/distro.pp index 032dc02..492d0af 100644 --- a/manifests/distro.pp +++ b/manifests/distro.pp @@ -20,17 +20,17 @@ if ($distro_build_type == 'composer' or $api_version == 8) { # Do nothing for now. # @todo run composer install or just leave it be? - exec {"composer-install-drush-${buildname}": + exec {"composer-install-drupal-${buildname}": command => "composer create-project drupal/recommended-project ${name} -y", cwd => $distro_root, path => ['/usr/local/bin', '/usr/bin'], - creates => "${distro_root}/${name}", + creates => "${distro_root}/${name}/index.php", } exec {"composer-require-drush-${buildname}": command => "composer require drush/drush", cwd => "${distro_root}/${name}", path => ['/usr/local/bin', '/usr/bin'], - subscribe => Exec["composer-install-drush-${buildname}"], + subscribe => Exec["composer-install-drupal-${buildname}"], refreshonly => true, } } From 759c4860c8438f69f548b049258c7f6f288e4379 Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Fri, 12 Nov 2021 16:21:45 -0500 Subject: [PATCH 09/21] Update distro.pp --- manifests/distro.pp | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/manifests/distro.pp b/manifests/distro.pp index 492d0af..d97bedf 100644 --- a/manifests/distro.pp +++ b/manifests/distro.pp @@ -1,11 +1,11 @@ # Defines a drupalsi::distro resource define drupalsi::distro ($distribution = 'drupal', $api_version = 8, - $distro_root = '/var/www/html', + $distro_root = '/var/www/html/drupal', $distro_build_type = 'composer', $distro_build_location = 'https://updates.drupal.org/release-history', # deprecated. $distro_build_args = {}, - $omit_files = {} + $omit_files = {} #deprecated. ) { include ::drush @@ -24,11 +24,11 @@ command => "composer create-project drupal/recommended-project ${name} -y", cwd => $distro_root, path => ['/usr/local/bin', '/usr/bin'], - creates => "${distro_root}/${name}/index.php", + creates => $distro_root, } exec {"composer-require-drush-${buildname}": command => "composer require drush/drush", - cwd => "${distro_root}/${name}", + cwd => $distro_root, path => ['/usr/local/bin', '/usr/bin'], subscribe => Exec["composer-install-drupal-${buildname}"], refreshonly => true, @@ -45,40 +45,20 @@ # @todo change to use vcsrepo puppet module. exec {"git-clone-${buildname}": command => "git clone ${branch} ${distro_build_location} ${distro_root}/${name}", - creates => "${distro_root}/${name}/index.php", + creates => $distro_root, path => ["/usr/bin", "/usr/sbin"], require => Class['git'], - onlyif => "test ! -d ${distro_root}/${name}", + onlyif => "test ! -d ${distro_root}", timeout => 1800, } $buildaction = "Exec[git-clone-${buildname}]" # Ensure the file is there even if it's blank. - file {"${distro_root}/${name}/sites/sites.php": + file {"${distro_root}/sites/sites.php": ensure => 'present', require => Exec["git-clone-${buildname}"], mode => '0644', } } - - if !empty($omit_files) { - # See below why we're doing this - $omitfiles = prefix($omit_files, "${buildaction}||${distro_root}/${name}/") - drupalsi::distro::omitfiles{$omitfiles:} - } -} - -# Remove files -define drupalsi::distro::omitfiles() { - # Since I can't loop or pass other arguments, we have to build data into the string - # Not ideal but it works. If anyone has a better idea please submit a patch - $parts = split($name, "\|\|") - - validate_absolute_path($parts[1]) - - file{$parts[1]: - ensure => 'absent', - require => $parts[0], - } } From 5eea23b5871dd0da6ed384ae9bce2cc51b6ae147 Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Fri, 12 Nov 2021 16:24:14 -0500 Subject: [PATCH 10/21] Update init.pp --- manifests/init.pp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index d61ceba..6d582c9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,11 +1,8 @@ # @todo Add documentation block here # @todo Add Drupal site installation verification (ex: onlyif to check the install profile used). class drupalsi () { - include drush + include ::drush - # Assume jq is available. If other modules want to fix deps go for it. - ensure_packages('jq', {'ensure' => 'latest'}) - # Add the script to set the Drupal directory permissions. file {'drupal-fix-permissions-script': content => template('drupalsi/drupal-fix-permissions.sh.erb'), From d385811ccc8ca52e6e360eb690af285b96a21cbb Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Fri, 12 Nov 2021 16:41:04 -0500 Subject: [PATCH 11/21] feat(composer): run as non-root --- manifests/distro.pp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manifests/distro.pp b/manifests/distro.pp index 9345675..30f01f6 100644 --- a/manifests/distro.pp +++ b/manifests/distro.pp @@ -7,7 +7,8 @@ $distro_build_type = 'composer', $distro_build_location = 'https://updates.drupal.org/release-history', # deprecated. $distro_build_args = {}, - $omit_files = {} #deprecated. + $omit_files = {}, #deprecated + $owner = 'apache', ) { include ::drush @@ -32,6 +33,7 @@ command => "composer create-project drupal/recommended-project ${distro_root} --remove-vcs -y", path => ['/usr/local/bin', '/usr/bin'], creates => $distro_root, + user => $owner, } exec {"composer-require-drush-${buildname}": @@ -40,6 +42,7 @@ path => ['/usr/local/bin', '/usr/bin'], subscribe => Exec["composer-install-drupal-${buildname}"], refreshonly => true, + user => $owner } } elsif ($distro_build_type == 'git') { From 03afcb705ea2085f51ed3a5e0946e3153afda6eb Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Fri, 12 Nov 2021 16:44:20 -0500 Subject: [PATCH 12/21] feat(composer): run as non-root --- manifests/distro.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/distro.pp b/manifests/distro.pp index 30f01f6..d9df05b 100644 --- a/manifests/distro.pp +++ b/manifests/distro.pp @@ -30,14 +30,14 @@ # Do nothing for now. # @todo run composer install or just leave it be? exec {"composer-install-drupal-${buildname}": - command => "composer create-project drupal/recommended-project ${distro_root} --remove-vcs -y", + command => "composer create-project drupal/recommended-project ${distro_root} --remove-vcs", path => ['/usr/local/bin', '/usr/bin'], creates => $distro_root, user => $owner, } exec {"composer-require-drush-${buildname}": - command => 'composer require drush/drush -y', + command => 'composer require drush/drush', cwd => $distro_root, path => ['/usr/local/bin', '/usr/bin'], subscribe => Exec["composer-install-drupal-${buildname}"], From a2bdd7020353eb17dcdfc0e5bfd66ffb7e32e6f4 Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Fri, 12 Nov 2021 16:48:03 -0500 Subject: [PATCH 13/21] feat(composer): run as non-root --- manifests/distro.pp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/manifests/distro.pp b/manifests/distro.pp index d9df05b..cbc6891 100644 --- a/manifests/distro.pp +++ b/manifests/distro.pp @@ -30,10 +30,11 @@ # Do nothing for now. # @todo run composer install or just leave it be? exec {"composer-install-drupal-${buildname}": - command => "composer create-project drupal/recommended-project ${distro_root} --remove-vcs", - path => ['/usr/local/bin', '/usr/bin'], - creates => $distro_root, - user => $owner, + command => "composer create-project drupal/recommended-project ${distro_root} --remove-vcs", + path => ['/usr/local/bin', '/usr/bin'], + creates => $distro_root, + user => $owner, + environment => ['HOME=/var/www'], } exec {"composer-require-drush-${buildname}": @@ -42,7 +43,8 @@ path => ['/usr/local/bin', '/usr/bin'], subscribe => Exec["composer-install-drupal-${buildname}"], refreshonly => true, - user => $owner + user => $owner, + environment => ['HOME=/var/www'], } } elsif ($distro_build_type == 'git') { From 93b261d0ee946e73062de96822813c2147bc2b74 Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Thu, 2 Dec 2021 09:34:43 -0500 Subject: [PATCH 14/21] refactor(puppet): use stdlib ensure_resources --- manifests/distros.pp | 2 +- manifests/site.pp | 4 ++-- manifests/sites.pp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/manifests/distros.pp b/manifests/distros.pp index da2a245..1b60d63 100644 --- a/manifests/distros.pp +++ b/manifests/distros.pp @@ -1,5 +1,5 @@ # Generate Drupal distro instances. class drupalsi::distros { $distros = lookup('drupalsi::distros', {default_value => {}}) - create_resources(drupalsi::distro, $distros) + ensure_resources(drupalsi::distro, $distros) } diff --git a/manifests/site.pp b/manifests/site.pp index bf93cd0..8e78b52 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -176,7 +176,7 @@ } } - create_resources(drupalsi::site::site_alias, $site_alias, $site_alias_defaults) - create_resources(drupalsi::site::setting, $trusted_host) + ensure_resources(drupalsi::site::site_alias, $site_alias, $site_alias_defaults) + ensure_resources(drupalsi::site::setting, $trusted_host) } } diff --git a/manifests/sites.pp b/manifests/sites.pp index b54b69d..3f4b1bc 100644 --- a/manifests/sites.pp +++ b/manifests/sites.pp @@ -1,5 +1,5 @@ # Generate Drupal sites. class drupalsi::sites { $sites = lookup('drupalsi::sites', {default_value => {}}) - create_resources(drupalsi::site, $sites) + ensure_resources(drupalsi::site, $sites) } From 4afdfe91dc74ae1ce8faa203c2568ed03d44761b Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Thu, 2 Dec 2021 09:49:11 -0500 Subject: [PATCH 15/21] fix(type): ensure integer comparison --- manifests/distro.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/distro.pp b/manifests/distro.pp index cbc6891..7396816 100644 --- a/manifests/distro.pp +++ b/manifests/distro.pp @@ -26,7 +26,7 @@ $buildname = md5("${distribution}-${api_version}-${distro_build_type}-${distro_root}-${distro_build_location}-${name}") # Drupal 8 always uses Composer. - if ($distro_build_type == 'composer' or $api_version >= 8) { + if ($distro_build_type == 'composer' or Integer($api_version) >= 8) { # Do nothing for now. # @todo run composer install or just leave it be? exec {"composer-install-drupal-${buildname}": From 7c3c0e0e64be4bb74d97d50c91127a30400054b2 Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Sat, 18 Dec 2021 14:18:42 -0500 Subject: [PATCH 16/21] feat(dotenv): manage a distro wide env file --- manifests/distro.pp | 9 +++++++++ metadata.json | 44 +++++--------------------------------------- 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/manifests/distro.pp b/manifests/distro.pp index 7396816..16d355d 100644 --- a/manifests/distro.pp +++ b/manifests/distro.pp @@ -1,6 +1,7 @@ # Defines a drupalsi::distro resource define drupalsi::distro ( $distribution = 'drupal', + $dotenv = {}, $api_version = 8, $distro_root = '/var/www/html/drupal', $distro_docroot = 'web', @@ -80,6 +81,7 @@ command => "/bin/cp ${distro_root}/${distro_docroot}/sites/example.sites.php ${distro_root}/${distro_docroot}/sites/sites.php" } + # Add an env file. concat {"${distro_root}/.env": ensure_newline => true, replace => false, @@ -88,6 +90,13 @@ group => $web_user, # @todo use def modififier collector to fix this to webserver user. } + # Add require env varialbes. + concat::fragment {"${distro_root}-envvars": + target => "${distro_root}/.env", + content => dotenv($dotenv), + order => '01' + } + concat {"${distro_root}/${distro_docroot}/sites.php": ensure => 'present', path => "${distro_root}/${distro_docroot}/sites/sites.php", diff --git a/metadata.json b/metadata.json index eeab1ca..0075be4 100644 --- a/metadata.json +++ b/metadata.json @@ -1,9 +1,9 @@ { "name": "coldfrontlabs-drupalsi", - "version": "0.5.5", + "version": "6.1.0", "author": "coldfrontlabs", "summary": "Define Drupal sites, installation profiles and distributions to be installed.", - "license": "GPL, Version 2.0", + "license": "GPL Version 2.0", "source": "https://github.com/coldfrontlabs/coldfrontlabs-drupalsi", "project_page": "https://github.com/coldfrontlabs/coldfrontlabs-drupalsi", "issues_url": "https://github.com/coldfrontlabs/coldfrontlabs-drupalsi/issues", @@ -17,42 +17,8 @@ "version_requirement": ">= 0.4.3" }, { - "name": "maestrodev/wget", - "version_requirement": ">= 1.7.0" - }, - { - "name": "stahnma/epel", - "version_requirement": ">= 1.3.1" - } - ], - "operatingsystem_support": [ - { - "operatingsystem": "CentOS", - "operatingsystemrelease": ["7"] - }, - { - "operatingsystem": "OracleLinux", - "operatingsystemrelease": ["7"] - }, - { - "operatingsystem": "RedHat", - "operatingsystemrelease": ["8"] - }, - { - "operatingsystem": "Scientific", - "operatingsystemrelease": ["7"] - }, - { - "operatingsystem": "Debian", - "operatingsystemrelease": ["9"] - }, - { - "operatingsystem": "Ubuntu", - "operatingsystemrelease": ["18.04"] - }, - { - "operatingsystem": "windows", - "operatingsystemrelease": ["2019", "10"] + "name": "spy/dotenv", + "version_requirement": ">= 1.0.1" } ], "requirements": [ @@ -64,4 +30,4 @@ "pdk-version": "1.17.0", "template-url": "pdk-default#1.17.0", "template-ref": "tags/1.17.0-0-gd3a4319" -} +} \ No newline at end of file From c2a6270ef635e0625e9704ae5d2ce55c340af81e Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Sat, 18 Dec 2021 14:23:36 -0500 Subject: [PATCH 17/21] feat(vars): add site specific env vars --- manifests/site.pp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/manifests/site.pp b/manifests/site.pp index 8e78b52..fe5f96f 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -13,6 +13,7 @@ String $tmp_dir = '', Hash $cron_schedule = {}, Hash $site_aliases = {}, + Hash $dotenv = {}, Boolean $auto_alias = true, Variant[Array[String], String] $local_settings = [], Array[String] $domain_names = [], @@ -30,11 +31,10 @@ include ::stdlib $distros = lookup('drupalsi::distros') + $distro_root = $distros[$distro]['distro_root'] # Build the site root based on the distro information if siteroot is not specified. if (empty($siteroot)) { - - $distro_root = $distros[$distro]['distro_root'] $distro_docroot = empty($distros[$distro]['distro_docroot']) ? { true => 'web', false => $distros[$distro]['distro_docroot'] @@ -155,6 +155,13 @@ 'target' => "${site_root}/sites/sites.php", } + # Add require env varialbes to the distro env file. + concat::fragment {"${name}-envvars": + target => "${distro_root}/.env", + content => dotenv($dotenv), + order => '05' + } + # Create the sites.php entries. $domain_names.each |$domain_name| { validate_domain_name($domain_name) From 44d639fbaed89701db9f6cbb4aad526c748a8135 Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Wed, 19 Jan 2022 10:54:33 -0500 Subject: [PATCH 18/21] fix(ownership): use web_user Maybe deprecate $owner variable? --- manifests/distro.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/distro.pp b/manifests/distro.pp index 16d355d..1a538a8 100644 --- a/manifests/distro.pp +++ b/manifests/distro.pp @@ -34,7 +34,7 @@ command => "composer create-project drupal/recommended-project ${distro_root} --remove-vcs", path => ['/usr/local/bin', '/usr/bin'], creates => $distro_root, - user => $owner, + user => $web_user, environment => ['HOME=/var/www'], } @@ -44,7 +44,7 @@ path => ['/usr/local/bin', '/usr/bin'], subscribe => Exec["composer-install-drupal-${buildname}"], refreshonly => true, - user => $owner, + user => $web_user, environment => ['HOME=/var/www'], } } From 70d35e137fd540b46a3771ea579602e12dd0c552 Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Tue, 8 Feb 2022 17:22:18 -0500 Subject: [PATCH 19/21] feat(settings): populate default settings Eventually we'll set to replace --- manifests/site.pp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/manifests/site.pp b/manifests/site.pp index fe5f96f..b4eebef 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -132,6 +132,20 @@ group => $webserver_user # @todo use def modififier collector to fix this to webserver user. } + # Populate the settings.php file with the default values. + concat::fragment {"drupalsi-${name}-default-settings-php": + target => "${site_root}/sites/${sitessubdir}/settings.php", + source => "${site_root}/sites/${sitessubdir}/default.settings.php", + order => '0' + } + + # Add reference to settings.local.php + concat::fragment {"drupalsi-${name}-settings-require}": + target => "${site_root}/sites/${sitessubdir}/settings.php", + content => "if (file_exists(__DIR__ . '/settings.local.php')) {include_once __DIR__ . '/settings.local.php';}", + order => '100', + } + concat {"${site_root}/sites/${sitessubdir}/settings.local.php": ensure => 'present', path => "${site_root}/sites/${sitessubdir}/settings.local.php", @@ -143,12 +157,6 @@ group => $webserver_user # @todo use def modififier collector to fix this to webserver user. } - concat::fragment {"drupalsi-${name}-settings-require}": - target => "${site_root}/sites/${sitessubdir}/settings.php", - content => "if (file_exists(__DIR__ . '/settings.local.php')) {include_once __DIR__ . '/settings.local.php';}", - order => '100', - } - # Add entries into sites.php $site_alias_defaults = { 'directory' => $sitessubdir, From b8ca37966e579c93a3b6f1f2936c42a86392db83 Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Tue, 8 Feb 2022 20:01:01 -0500 Subject: [PATCH 20/21] fix(composer): require the PHP class first --- manifests/distro.pp | 1 + 1 file changed, 1 insertion(+) diff --git a/manifests/distro.pp b/manifests/distro.pp index 1a538a8..e121456 100644 --- a/manifests/distro.pp +++ b/manifests/distro.pp @@ -36,6 +36,7 @@ creates => $distro_root, user => $web_user, environment => ['HOME=/var/www'], + require => Class['::php'], } exec {"composer-require-drush-${buildname}": From 244f1da56db24d501b511d823d4796dcb8904b56 Mon Sep 17 00:00:00 2001 From: Mathew Winstone Date: Tue, 8 Feb 2022 20:20:54 -0500 Subject: [PATCH 21/21] fix(composer): require the PHP class first --- manifests/distro.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/distro.pp b/manifests/distro.pp index e121456..11815a6 100644 --- a/manifests/distro.pp +++ b/manifests/distro.pp @@ -36,7 +36,7 @@ creates => $distro_root, user => $web_user, environment => ['HOME=/var/www'], - require => Class['::php'], + require => Class['::php'], } exec {"composer-require-drush-${buildname}":