Use Ansible Galaxy for settings role

Now that the Drupal settings role is on Ansible Galaxy, it can be added as a requirement and installed from there rather than having a local copy in the codebase.

Fixes #15
This commit is contained in:
Oliver Davies 2020-02-19 00:55:32 +00:00
parent 49d691b6c0
commit e9baad51d8
7 changed files with 3 additions and 111 deletions

View file

@ -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 }}'

View file

@ -17,3 +17,5 @@
version: 4.0.2
- name: geerlingguy.security
version: 1.9.0
- name: opdavies.drupal_settings_files
version: 0.1.0

View file

@ -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.

View file

@ -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$'
```

View file

@ -1,2 +0,0 @@
---
drupal_settings: []

View file

@ -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

View file

@ -1,42 +0,0 @@
<?php
// {{ ansible_managed }}
{% for key, values in item.1.settings.databases.items() %}
{% for target, values in values.items() %}
$databases['{{ key }}']['{{ target }}'] = array(
'driver' => '{{ 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 %}