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
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'
port: 3306 # Optional
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$'
```
Any pre-requisites that may not be covered by Ansible itself or the role should
be mentioned here. For instance, if the role uses the EC2 module, it may be a
good idea to mention in this section that the boto package is required.
Role Variables
--------------
A description of the settable variables for this role should go here, including
any variables that are in defaults/main.yml, vars/main.yml, and any variables
that can/should be set via parameters to the role. Any variables that are read
from other roles and/or the global scope (ie. hostvars, group vars, etc.) should
be mentioned here as well.
Dependencies
------------
A list of other roles hosted on Galaxy should go here, plus any details in
regards to parameters that may need to be set for other roles, or variables that
are used from other roles.
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables
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:
role_name: drupal-settings-files
author: opdavies
description: Automatically generates settings files for Drupal applications
author: Oliver Davies
description: Automatically generate Drupal settings files.
license: MIT
min_ansible_version: 1.2
platforms:
- name: EL
versions: [all]
- name: Debian
versions: [all]
- name: Ubuntu
versions: [all]
galaxy_tags: [drupal, php, cms, web, development]
dependencies: []
- name: GenericUNIX
versions:
- all
- any
- name: GenericBSD
versions:
- all
- any
- 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:
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:
- '{{ drupal_settings }}'
- sites
no_log: true
- name: Create settings files
- name: Ensure that Drupal settings files are present
template:
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:
- '{{ drupal_settings }}'
- 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