Background
I want to make my site code open source, for reasons of:
- collaboration
- developing an open source Drupal distribution or module (yes I know distributions might be superseded by recipes but that is still a work in progress)
- (other reasons not applicable to me, but good reasons): public sector / government requirement
Problem
In wanting to open source my code, I notice that my config export as code (yaml) contains personal email addresses. I want to stop this happening but for my working site to still function. So I want to store them outside of git-version controlled config.
Specific examples of personal emails being stored in config export which will be committed to git:
- Site
mail
address insystem.site.yml
- Webform email addresses - in
webform.webform.contact.yml
:
e.g.
handlers:
email_confirmation:
settings:
to_mail: [email protected]
My question
How can I store specific config items such as email addresses, api keys and hashes outside of git-version controlled config export but still read by Drupal as config?
My research to solve the problem:
I have been unsuccessful, hence asking this question, but here is what I tried.
I tried to apply the following to my own example:
- Override specific configuration keys in settings.local.php
- Configuration override system
out of date (even though it says April 2024) because
drush config-list
is not available in my version of Drush - 12.5 and I've seen an issue/bug to port this into the newer versions of Drush
Here's what I tried to apply - I have my system.site.yml
which contains the personal email address which I want to take out of git version controlled config and control in the environment:
_core:
default_config_hash: (a hash value)
langcode: en
uuid: (a long dash separated hex number)
name: 'My site'
mail: [email protected]
slogan: ''
page:
403: ''
404: ''
front: /node/1
admin_compact_mode: false
weight_select_max: 100
default_langcode: en
mail_notification: ''
Based on the above 2 links to references above, here's my attempt at equivalent config in settings.local.php
not stored in git (.gitignore
-d), but called from git controlled settings.php
# config/sync/system.site.yml
# mail: [email protected]
$config['system.site']['mail'] = '[email protected]';
(this file also stores my database credentials).
So to try this out, I:
- commented out
mail: [email protected]
insystem.site.yml
- added the config as above to my
settings.local.php
- ran
drush cim
to remove the email from active config, hoping that Drupal would now take it from mysettings.local.php
- ran
drush cr
to clear the cache
Then I visited the Basic site settings page (that uses system.site.yml
config): admin/config/system/site-information
, but saw that the mail field was empty!
So Drupal wasn't taking the config defined in my settings.local.php
.
Further research
From looking at the below links, I'm unclear if general full support is available to override any / all of the configurations in Drupal:
- Allow configuring the environment via an environment variable
- given that this is an open issue, this seems to contradict the above links I used which had suggested it is already possible
- Set Drupal Configuration with Environment Variables
- Allow configuration via environment variables
- Config Split - I don't think this is relevant to me - Config Split seems to be about - what it say - splitting up config, i.e. a separate place for platform specific config - like enabling the Devel module settings. But in my case, I don't even want email to be in config in the first place. And even if this module was supposed to do what they want, why have this, as well as the other options above?
- Config Ignore - I don't want to ignore yaml files to be imported to prevent overwriting, that's not my problem
- Configuration Management for a Multi-Environment Drupal 8 Development Workflow
Other items (not sure if relevant)
- Environment Variables - not sure if this relates to what I need
- Environment Config
- Drupal 8 Environment Specific Configurations
Research to do - how do distro-makers do it?
I would imagine in their development, they test real sites, with personal settings, but then want to release their work to the public with this data removed, so how do they do it?