diff --git a/tools/ansible/deploy/after-update-code.yml b/tools/ansible/deploy/after-update-code.yml index 1237e42..64c32b2 100644 --- a/tools/ansible/deploy/after-update-code.yml +++ b/tools/ansible/deploy/after-update-code.yml @@ -6,7 +6,7 @@ - name: Generate settings.php file include_role: - name: './roles/drupal-settings' + name: opdavies.drupal_settings_files - name: Import configuration command: '{{ release_drush_path }} config-import -y chdir={{ release_web_path }}' diff --git a/tools/ansible/requirements.yml b/tools/ansible/requirements.yml index b3a7785..880c990 100644 --- a/tools/ansible/requirements.yml +++ b/tools/ansible/requirements.yml @@ -17,3 +17,5 @@ version: 4.0.2 - name: geerlingguy.security version: 1.9.0 +- name: opdavies.drupal_settings_files + version: 0.1.0 diff --git a/tools/ansible/roles/drupal-settings/LICENSE b/tools/ansible/roles/drupal-settings/LICENSE deleted file mode 100644 index 53f4980..0000000 --- a/tools/ansible/roles/drupal-settings/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019 Oliver Davies - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/tools/ansible/roles/drupal-settings/README.md b/tools/ansible/roles/drupal-settings/README.md deleted file mode 100644 index f3cd913..0000000 --- a/tools/ansible/roles/drupal-settings/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Ansible Role: Drupal settings - -```yaml -drupal_settings: - - drupal_root: /var/www/web - sites: - - name: default - filename: settings.php # Optional, defaults to 'settings.php' - settings: - base_url: https://www.example.com # Optional, Drupal 7 - hash_salt: '' # Optional - databases: - default: # The database key - default: # The database target - driver: mysql # Optional, defaults to 'mysql' - host: localhost # Optional, defaults to 'localhost' - database: mydatabase - username: user - password: secret - config_directories: # Optional, Drupal 8 - sync: path/to/config - trusted_hosts: # Optional, Drupal 8 - - '^example\.com$' - - '^.+\.example\.com$' - - '^example\.org$' - - '^.+\.example\.org$' -``` diff --git a/tools/ansible/roles/drupal-settings/defaults/main.yml b/tools/ansible/roles/drupal-settings/defaults/main.yml deleted file mode 100644 index cfd76d5..0000000 --- a/tools/ansible/roles/drupal-settings/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -drupal_settings: [] diff --git a/tools/ansible/roles/drupal-settings/tasks/main.yml b/tools/ansible/roles/drupal-settings/tasks/main.yml deleted file mode 100644 index 71ebba5..0000000 --- a/tools/ansible/roles/drupal-settings/tasks/main.yml +++ /dev/null @@ -1,18 +0,0 @@ ---- -- name: Ensure directory exists - file: - state: directory - path: '{{ item.0.drupal_root }}/sites/{{ item.1.name|default("default") }}' - with_subelements: - - '{{ drupal_settings }}' - - sites - no_log: true - -- name: Create settings files - template: - src: settings.php.j2 - dest: '{{ item.0.drupal_root }}/sites/{{ item.1.name|default("default") }}/{{ item.1.filename|default("settings.php") }}' - with_subelements: - - '{{ drupal_settings }}' - - sites - no_log: true diff --git a/tools/ansible/roles/drupal-settings/templates/settings.php.j2 b/tools/ansible/roles/drupal-settings/templates/settings.php.j2 deleted file mode 100644 index 22c4344..0000000 --- a/tools/ansible/roles/drupal-settings/templates/settings.php.j2 +++ /dev/null @@ -1,42 +0,0 @@ - '{{ values.driver|default('mysql') }}', - 'host' => '{{ values.host|default('localhost') }}', - 'database' => '{{ values.database }}', - 'username' => '{{ values.username }}', - 'password' => '{{ values.password }}', -); - -{% endfor %} -{% endfor %} - -{% if item.1.settings.base_url is defined %} -$base_url = '{{ item.1.settings.base_url }}'; -{% endif %} - -{% if item.1.settings.hash_salt is defined %} -$settings['hash_salt'] = '{{ item.1.settings.hash_salt }}'; -{% endif %} - -{% if item.1.settings.config_directories is defined %} -{% for name, value in item.1.settings.config_directories.items() %} -$config_directories['{{ name }}'] = '{{ value }}'; -{% endfor %} -{% endif %} - -{% if item.1.settings.trusted_hosts is defined %} -$settings['trusted_host_patterns'] = array( -{% for host in item.1.settings.trusted_hosts %} - '{{ host }}', -{% endfor %} -); -{% endif %} - -{% if item.1.settings.extra_parameters is defined %} - {{ item.1.settings.extra_parameters|indent(0) }} -{% endif %}