Compare commits

...

No commits in common. "master" and "next" have entirely different histories.
master ... next

8 changed files with 71 additions and 111 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/molecule/default/tests/__pycache__/

21
LICENSE
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,32 +1,48 @@
# Ansible Role: Drupal settings Role Name
=========
A role for automatically generating `settings.php` files for Drupal 7 and 8 applications. A brief description of the role goes here.
## Example Requirements
------------
```yaml Any pre-requisites that may not be covered by Ansible itself or the role should
drupal_settings: be mentioned here. For instance, if the role uses the EC2 module, it may be a
- drupal_root: /var/www/web good idea to mention in this section that the boto package is required.
sites:
- name: default Role Variables
filename: settings.php # Optional, defaults to 'settings.php' --------------
settings:
base_url: https://www.example.com # Optional, Drupal 7 A description of the settable variables for this role should go here, including
hash_salt: '' # Optional any variables that are in defaults/main.yml, vars/main.yml, and any variables
databases: that can/should be set via parameters to the role. Any variables that are read
default: # The database key from other roles and/or the global scope (ie. hostvars, group vars, etc.) should
default: # The database target be mentioned here as well.
driver: mysql # Optional, defaults to 'mysql'
host: localhost # Optional, defaults to 'localhost' Dependencies
port: 3306 # Optional ------------
database: mydatabase
username: user A list of other roles hosted on Galaxy should go here, plus any details in
password: secret regards to parameters that may need to be set for other roles, or variables that
config_directories: # Optional, Drupal 8 are used from other roles.
sync: path/to/config
trusted_hosts: # Optional, Drupal 8 Example Playbook
- '^example\.com$' ----------------
- '^.+\.example\.com$'
- '^example\.org$' Including an example of how to use your role (for instance, with variables
- '^.+\.example\.org$' passed in as parameters) is always nice for users too:
```
- hosts: servers
roles:
- { role: opdavies.drupal-settings, x: 42 }
License
-------
BSD
Author Information
------------------
An optional section for the role authors to include contact information, or a
website (HTML is not allowed).

2
handlers/main.yml Normal file
View file

@ -0,0 +1,2 @@
---
# handlers file for opdavies.drupal-settings

View file

@ -1,16 +1,21 @@
--- ---
galaxy_info: galaxy_info:
role_name: drupal-settings-files author: Oliver Davies
author: opdavies description: Automatically generate Drupal settings files.
description: Automatically generates settings files for Drupal applications
license: MIT license: MIT
min_ansible_version: 1.2
platforms: platforms:
- name: EL - name: GenericUNIX
versions: [all] versions:
- name: Debian - all
versions: [all] - any
- name: Ubuntu - name: GenericBSD
versions: [all] versions:
galaxy_tags: [drupal, php, cms, web, development] - all
- any
dependencies: [] - name: GenericLinux
versions:
- all
- any
galaxy_tags:
- drupal

View file

@ -1,18 +1,16 @@
--- ---
- name: Ensure directory exists - name: Ensure that Drupal site directories are present
file: file:
state: directory state: directory
path: '{{ item.0.drupal_root }}/sites/{{ item.1.name|default("default") }}' path: '{{ item.0.root }}/sites/{{ item.1.name|default("default") }}'
with_subelements: with_subelements:
- '{{ drupal_settings }}' - '{{ drupal_settings }}'
- sites - sites
no_log: true
- name: Create settings files - name: Ensure that Drupal settings files are present
template: template:
src: settings.php.j2 src: settings.php.j2
dest: '{{ item.0.drupal_root }}/sites/{{ item.1.name|default("default") }}/{{ item.1.filename|default("settings.php") }}' dest: '{{ item.0.root }}/sites/{{ item.1.name|default("default") }}/{{ item.1.filename|default("settings.php") }}'
with_subelements: with_subelements:
- '{{ drupal_settings }}' - '{{ drupal_settings }}'
- sites - sites
no_log: true

View file

@ -1,43 +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') }}',
'port' => '{{ values.port|default('3306') }}',
'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 %}

2
vars/main.yml Normal file
View file

@ -0,0 +1,2 @@
---
# vars file for opdavies.drupal-settings