Compare commits
No commits in common. "next" and "master" have entirely different histories.
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +0,0 @@
|
||||||
/molecule/default/tests/__pycache__/
|
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
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.
|
74
README.md
74
README.md
|
@ -1,48 +1,32 @@
|
||||||
Role Name
|
# Ansible Role: Drupal settings
|
||||||
=========
|
|
||||||
|
|
||||||
A brief description of the role goes here.
|
A role for automatically generating `settings.php` files for Drupal 7 and 8 applications.
|
||||||
|
|
||||||
Requirements
|
## Example
|
||||||
------------
|
|
||||||
|
|
||||||
Any pre-requisites that may not be covered by Ansible itself or the role should
|
```yaml
|
||||||
be mentioned here. For instance, if the role uses the EC2 module, it may be a
|
drupal_settings:
|
||||||
good idea to mention in this section that the boto package is required.
|
- drupal_root: /var/www/web
|
||||||
|
sites:
|
||||||
Role Variables
|
- name: default
|
||||||
--------------
|
filename: settings.php # Optional, defaults to 'settings.php'
|
||||||
|
settings:
|
||||||
A description of the settable variables for this role should go here, including
|
base_url: https://www.example.com # Optional, Drupal 7
|
||||||
any variables that are in defaults/main.yml, vars/main.yml, and any variables
|
hash_salt: '' # Optional
|
||||||
that can/should be set via parameters to the role. Any variables that are read
|
databases:
|
||||||
from other roles and/or the global scope (ie. hostvars, group vars, etc.) should
|
default: # The database key
|
||||||
be mentioned here as well.
|
default: # The database target
|
||||||
|
driver: mysql # Optional, defaults to 'mysql'
|
||||||
Dependencies
|
host: localhost # Optional, defaults to 'localhost'
|
||||||
------------
|
port: 3306 # Optional
|
||||||
|
database: mydatabase
|
||||||
A list of other roles hosted on Galaxy should go here, plus any details in
|
username: user
|
||||||
regards to parameters that may need to be set for other roles, or variables that
|
password: secret
|
||||||
are used from other roles.
|
config_directories: # Optional, Drupal 8
|
||||||
|
sync: path/to/config
|
||||||
Example Playbook
|
trusted_hosts: # Optional, Drupal 8
|
||||||
----------------
|
- '^example\.com$'
|
||||||
|
- '^.+\.example\.com$'
|
||||||
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:
|
- '^.+\.example\.org$'
|
||||||
|
```
|
||||||
- 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).
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
---
|
|
||||||
# handlers file for opdavies.drupal-settings
|
|
|
@ -1,21 +1,16 @@
|
||||||
---
|
---
|
||||||
galaxy_info:
|
galaxy_info:
|
||||||
author: Oliver Davies
|
role_name: drupal-settings-files
|
||||||
description: Automatically generate Drupal settings files.
|
author: opdavies
|
||||||
|
description: Automatically generates settings files for Drupal applications
|
||||||
license: MIT
|
license: MIT
|
||||||
min_ansible_version: 1.2
|
|
||||||
platforms:
|
platforms:
|
||||||
- name: GenericUNIX
|
- name: EL
|
||||||
versions:
|
versions: [all]
|
||||||
- all
|
- name: Debian
|
||||||
- any
|
versions: [all]
|
||||||
- name: GenericBSD
|
- name: Ubuntu
|
||||||
versions:
|
versions: [all]
|
||||||
- all
|
galaxy_tags: [drupal, php, cms, web, development]
|
||||||
- any
|
|
||||||
- name: GenericLinux
|
dependencies: []
|
||||||
versions:
|
|
||||||
- all
|
|
||||||
- any
|
|
||||||
galaxy_tags:
|
|
||||||
- drupal
|
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
---
|
---
|
||||||
- name: Ensure that Drupal site directories are present
|
- name: Ensure directory exists
|
||||||
file:
|
file:
|
||||||
state: directory
|
state: directory
|
||||||
path: '{{ item.0.root }}/sites/{{ item.1.name|default("default") }}'
|
path: '{{ item.0.drupal_root }}/sites/{{ item.1.name|default("default") }}'
|
||||||
with_subelements:
|
with_subelements:
|
||||||
- '{{ drupal_settings }}'
|
- '{{ drupal_settings }}'
|
||||||
- sites
|
- sites
|
||||||
|
no_log: true
|
||||||
|
|
||||||
- name: Ensure that Drupal settings files are present
|
- name: Create settings files
|
||||||
template:
|
template:
|
||||||
src: settings.php.j2
|
src: settings.php.j2
|
||||||
dest: '{{ item.0.root }}/sites/{{ item.1.name|default("default") }}/{{ item.1.filename|default("settings.php") }}'
|
dest: '{{ item.0.drupal_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
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?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 %}
|
|
@ -1,2 +0,0 @@
|
||||||
---
|
|
||||||
# vars file for opdavies.drupal-settings
|
|
Reference in a new issue