diff --git a/manifests/distro.pp b/manifests/distro.pp
index 3524e96..11815a6 100644
--- a/manifests/distro.pp
+++ b/manifests/distro.pp
@@ -1,17 +1,17 @@
# Defines a drupalsi::distro resource
define drupalsi::distro (
$distribution = 'drupal',
- $api_version = 7,
- $distro_root = '/var/www/html',
+ $dotenv = {},
+ $api_version = 8,
+ $distro_root = '/var/www/html/drupal',
$distro_docroot = 'web',
- $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
+ $omit_files = {}, #deprecated
+ $owner = 'apache',
+) {
+ include ::drush
if $::osfamily == 'RedHat' {
$web_user = 'apache'
@@ -30,31 +30,84 @@
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}":
+ command => "composer create-project drupal/recommended-project ${distro_root} --remove-vcs",
+ path => ['/usr/local/bin', '/usr/bin'],
+ creates => $distro_root,
+ user => $web_user,
+ environment => ['HOME=/var/www'],
+ require => Class['::php'],
+ }
- exec {"create-${buildname}-sites.php":
- creates => "${distro_root}/${distro_docroot}/sites/sites.php",
- command => "/bin/cp ${distro_root}/${distro_docroot}/sites/example.sites.php ${distro_root}/${distro_docroot}/sites/sites.php"
+ exec {"composer-require-drush-${buildname}":
+ command => 'composer require drush/drush',
+ cwd => $distro_root,
+ path => ['/usr/local/bin', '/usr/bin'],
+ subscribe => Exec["composer-install-drupal-${buildname}"],
+ refreshonly => true,
+ user => $web_user,
+ environment => ['HOME=/var/www'],
+ }
+ }
+ elsif ($distro_build_type == 'git') {
+ include ::git
+ if has_key($distro_build_args, 'git_branch') {
+ $branch = join([ '-b ', '"', $distro_build_args['git_branch'], '"'])
+ } else {
+ $branch = ''
}
- concat {"${distro_root}/.env":
- ensure_newline => true,
- replace => false,
- backup => false,
- show_diff => false,
- group => $web_user, # @todo use def modififier collector to fix this to webserver user.
+ # @todo change to use vcsrepo puppet module.
+ exec {"git-clone-${buildname}":
+ command => "git clone ${branch} ${distro_build_location} ${distro_root}/${name}",
+ creates => $distro_root,
+ path => ['/usr/bin', '/usr/sbin'],
+ require => Class['git'],
+ onlyif => "test ! -d ${distro_root}",
+ timeout => 1800,
}
- concat {"${distro_root}/${distro_docroot}/sites.php":
- ensure => 'present',
- path => "${distro_root}/${distro_docroot}/sites/sites.php",
- mode => '0640',
- ensure_newline => true,
- replace => false,
- backup => false,
- show_diff => true,
- group => $web_user, # @todo use def modififier collector to fix this to webserver user.
- require => Exec["create-${buildname}-sites.php"],
+ $buildaction = "Exec[git-clone-${buildname}]"
+
+ # Ensure the file is there even if it's blank.
+ file {"${distro_root}/sites/sites.php":
+ ensure => 'present',
+ require => Exec["git-clone-${buildname}"],
+ mode => '0644',
}
}
+ exec {"create-${buildname}-sites.php":
+ creates => "${distro_root}/${distro_docroot}/sites/sites.php",
+ 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,
+ backup => false,
+ show_diff => false,
+ 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",
+ mode => '0640',
+ ensure_newline => true,
+ replace => false,
+ backup => false,
+ show_diff => true,
+ group => $web_user, # @todo use def modififier collector to fix this to webserver user.
+ require => Exec["create-${buildname}-sites.php"],
+ }
}
+
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/init.pp b/manifests/init.pp
index 69dddb8..5d82add 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -6,7 +6,7 @@
include ::drupalsi::distros
# Assume jq is available. If other modules want to fix deps go for it.
- ensure_packages('jq', {'ensure' => 'present'})
+ ensure_packages('jq')
# Add the script to set the Drupal directory permissions.
file {'drupal-fix-permissions-script':
diff --git a/manifests/site.pp b/manifests/site.pp
index bf93cd0..b4eebef 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']
@@ -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,18 +157,19 @@
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,
'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)
@@ -176,7 +191,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)
}
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
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
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
+
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
+