Skip to content
Snippets Groups Projects
Commit 33531e50 authored by jurgenhaas's avatar jurgenhaas
Browse files

Further optimisation

parent ffa4d2d1
No related branches found
No related tags found
No related merge requests found
drupal_default_settings: []
drupal_install_drupal: true drupal_install_drupal: true
drupal_configure_drupal: true drupal_configure_drupal: true
drupal_update_drupal: true
drupal_contrib_subdir: '' drupal_contrib_subdir: ''
drupal_settings: drupal_settings:
- root: '{{ apache_server_default_root }}' - root: '{{ apache_server_default_root }}'
version: 'd7' version: 'd7'
templates: [] templates: []
drush_subkey: '' drush_subkey: ''
create_drush_aliases: false create_drush_aliases: true
apache_site: false
src: src:
mode: 'svn' mode: 'svn'
url: '{{ apache_server_default_svn_target }}' url: '{{ apache_server_default_svn_target }}'
...@@ -18,9 +15,12 @@ drupal_settings: ...@@ -18,9 +15,12 @@ drupal_settings:
- domain: '{{ inventory_hostname }}.{{ internal_domain }}' - domain: '{{ inventory_hostname }}.{{ internal_domain }}'
aliases: [] aliases: []
shortname: '{{ inventory_hostname }}.{{ internal_domain }}' shortname: '{{ inventory_hostname }}.{{ internal_domain }}'
dbname: '{{ inventory_hostname }}' db:
dbprefix: '' name: '{{ inventory_hostname }}'
dbhost: '{{ drupal_default_settings.dbhost }}' prefix: ''
protocol: 'http' host: '127.0.0.1'
extra: []
protocol: 'https'
multidomain: false multidomain: false
extra_settings: [] extra_settings: []
conf: []
--- ---
# file: roles/drupal/tasks/apache.yml # file: roles/drupal/tasks/apache.yml
- name: "Apache configuration file for our site(s)" - name: "Apache Configuration File"
template: template:
src='vhost.conf' src='vhost.conf'
dest='/etc/apache2/sites-available/{{ drupal.apache_site|default(drupal.jail.name) }}{{ apache_conf_ext }}' dest='/etc/apache2/sites-available/{{ item.domain }}{{ apache_conf_ext }}'
owner='root' owner='root'
group='root' group='root'
mode='664' mode='664'
when: drupal.jail is defined or drupal.apache_site with_items: drupal.domains
notify: notify:
- "Apache | Restart Apache" - "Apache | Restart Apache"
- name: "Apache enable our new site(s)" - name: "Apache enable our new site(s)"
command: a2ensite {{ drupal.apache_site|default(drupal.jail.name) }} creates=/etc/apache2/sites-enabled/{{ drupal.apache_site|default(drupal.jail.name) }}{{ apache_conf_ext }} command: a2ensite {{ item.domain }} creates=/etc/apache2/sites-enabled/{{ item.domain }}{{ apache_conf_ext }}
when: drupal.jail is defined or drupal.apache_site with_items: drupal.domains
notify: notify:
- "Apache | Restart Apache" - "Apache | Restart Apache"
...@@ -25,14 +25,16 @@ ...@@ -25,14 +25,16 @@
owner='www-data' owner='www-data'
group='www-data' group='www-data'
mode=755 mode=755
when: drupal.apache_auth is defined with_items: drupal.domains
when: item.apache_auth is defined
- name: "Setup AuthType Basic" - name: "Setup AuthType Basic"
htpasswd: htpasswd:
path='{{ webRoot }}/passwords/{{ drupal.apache_auth.user }}' path='{{ webRoot }}/passwords/{{ item.apache_auth.user }}'
name='{{ drupal.apache_auth.user }}' name='{{ item.apache_auth.user }}'
password='{{ drupal.apache_auth.password }}' password='{{ item.apache_auth.password }}'
owner='www-data' owner='www-data'
group='www-data' group='www-data'
mode='640' mode='640'
when: drupal.apache_auth is defined with_items: drupal.domains
when: item.apache_auth is defined
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
- name: "Configuration file" - name: "Configuration file"
template: template:
src='{{ item.src }}' src='{{ item.src }}'
dest='{{ drupalRoot }}/{{ item.dest }}' dest='{{ drupalRoot }}{{ item.dest }}'
owner='www-data' owner='www-data'
group='www-data' group='www-data'
mode='664' mode='664'
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
- name: "Create the sites sub-directories" - name: "Create the sites sub-directories"
file: file:
dest='{{ drupalRoot }}/sites/{{ item.0.shortname }}/{{ item.1 }}' dest='{{ drupalRoot }}/sites/{{ item.0.shortname|default("default") }}/{{ item.1 }}'
state='directory' state='directory'
owner='www-data' owner='www-data'
group='www-data' group='www-data'
...@@ -23,18 +23,18 @@ ...@@ -23,18 +23,18 @@
- name: "Create symbolic links" - name: "Create symbolic links"
file: file:
src='{{ item.0.shortname }}' src='{{ item.0.shortname|default("default") }}'
path='{{ drupalRoot }}/sites/{{ item.1 }}' path='{{ drupalRoot }}/sites/{{ item.1 }}'
state=link state=link
with_subelements: with_subelements:
- drupal.domains - drupal.domains
- aliases - aliases
when: drupal.version == 'd6' when: drupal.version|default("d7") == "d6"
- name: "Create the settings.php files" - name: "Create the settings.php files"
template: template:
src='{{ drupal.template_dir|default('') }}{{ drupal.version }}_settings.php' src='{{ drupal.template_dir|default('') }}{{ drupal.version|default("d7") }}_settings.php'
dest='{{ drupalRoot }}/sites/{{ item.shortname }}/settings.php' dest='{{ drupalRoot }}/sites/{{ item.shortname|default("default") }}/settings.php'
owner='www-data' owner='www-data'
group='www-data' group='www-data'
mode='444' mode='444'
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
git: git:
accept_hostkey: "yes" accept_hostkey: "yes"
repo: "{{ drupal.src.git.repository }}" repo: "{{ drupal.src.git.repository }}"
dest: "{{ webRoot }}/{{ drupal.src.git.target }}" dest: "{{ webRoot }}{{ drupal.src.git.target }}"
force: "yes" force: "yes"
version: "{{ drupal.src.git.branch|default(omit) }}" version: "{{ drupal.src.git.branch|default(omit) }}"
become: false become: false
- name: "Run Script" - name: "Run Script"
shell: "{{ webRoot }}/{{ drupal.src.git.target }}/{{ drupal.src.script }}" shell: "{{ webRoot }}{{ drupal.src.git.target }}{{ drupal.src.script }}"
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
- set_fact: webRoot='/var/www' - set_fact: webRoot='/var/www'
- set_fact: webRoot='{{ jailroot }}/{{ drupal.jail.name }}/var/www' - set_fact: webRoot='{{ jailroot }}/{{ drupal.jail.name }}/var/www'
when: drupal.jail is defined when: drupal.jail is defined
- set_fact: drupalRoot='{{ webRoot }}/{{ drupal.root }}' - set_fact: drupalRoot='{{ webRoot }}{{ drupal.root|default("") }}'
- name: "Configure Apache" - name: "Configure Apache"
include: apache.yml include: apache.yml
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
register: drupal_available register: drupal_available
failed_when: false failed_when: false
- include: install.{{ drupal.src.mode }}.yml - include: install.{{ drupal.src.mode|default("none") }}.yml
when: drupal_install_drupal and drupal_available is defined and drupal_available.stdout != '{{ drupalRoot }}/index.php' when: drupal_install_drupal and drupal_available is defined and drupal_available.stdout != '{{ drupalRoot }}/index.php'
- include: configure.yml - include: configure.yml
when: drupal_configure_drupal when: drupal_configure_drupal
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
- name: "Make site directories writeable" - name: "Make site directories writeable"
file: file:
path='{{ drupalRoot }}/sites/{{ item.0.shortname }}/{{ item.1 }}' path='{{ drupalRoot }}/sites/{{ item.0.shortname|default("default") }}/{{ item.1 }}'
mode='ug+w' mode='ug+w'
recurse=yes recurse=yes
with_nested: with_nested:
......
#!/bin/bash
cd {{ drupalRoot }}/sites
{% for domain in drupal.domains %}
{% for alias in domain.aliases %}
ln -s {{ domain.shortname }} {{ alias }}
{% endfor %}
{% endfor %}
<?php <?php
$db_url = 'mysql://root:{{ mysql_root_password }}@127.0.0.1/{{ item.dbname }}'; $db_url = 'mysql://root:{{ mysql_root_password }}@127.0.0.1/{{ item.db.name }}';
$db_prefix = '{{ item.dbprefix }}'; $db_prefix = '{{ item.db.prefix|default("") }}';
$update_free_access = FALSE; $update_free_access = FALSE;
$base_url = '{{ item.protocol }}://{{ item.domain }}'; $base_url = '{{ item.protocol|default("https") }}://{{ item.domain }}';
$cookie_domain = '{{ item.domain }}'; $cookie_domain = '{{ item.domain }}';
ini_set('arg_separator.output', '&amp;'); ini_set('arg_separator.output', '&amp;');
...@@ -22,6 +22,10 @@ ini_set('url_rewriter.tags', ''); ...@@ -22,6 +22,10 @@ ini_set('url_rewriter.tags', '');
$conf['clean_url'] = 1; $conf['clean_url'] = 1;
{% for line in item.extra_settings %} {% for line in item.extra_settings|default([]) %}
{{line}} {{line}}
{% endfor %} {% endfor %}
{% for config in item.conf|default([]) %}
$conf['{{ config.key }}'] = {{ config.value }};
{% endfor %}
...@@ -3,33 +3,33 @@ ...@@ -3,33 +3,33 @@
$databases = array ( $databases = array (
'default' => array ( 'default' => array (
'default' => array ( 'default' => array (
'driver' => 'mysql', 'driver' => '{{ item.db.driver|default("mysql") }}',
'database' => '{{ item.dbname }}', 'database' => '{{ item.db.name }}',
'username' => 'root', 'username' => 'root',
'password' => '{{ mysql_root_password }}', 'password' => '{{ mysql_root_password }}',
'host' => '127.0.0.1', 'host' => '{{ item.db.host|default("127.0.0.1") }}',
'port' => '{{ hostvars[item.dbhost]['ssh_tunnel_ports'][0]['local'] }}', 'port' => '{{ hostvars[item.db.host|default(inventory_hostname)]['ssh_tunnel_ports'][0]['local'] }}',
), ),
), ),
{% for db in item.db_extra|default([]) %} {% for db in item.db.extra|default([]) %}
'{{ db.key }}' => array ( '{{ db.key }}' => array (
'default' => array ( 'default' => array (
'driver' => 'mysql', 'driver' => '{{ db.driver|default("mysql") }}',
'database' => '{{ db.dbname }}', 'database' => '{{ db.name }}',
'username' => 'root', 'username' => 'root',
'password' => '{{ mysql_root_password }}', 'password' => '{{ mysql_root_password }}',
'host' => '127.0.0.1', 'host' => '{{ item.db.host|default("127.0.0.1") }}',
'port' => '{{ hostvars[item.dbhost]['ssh_tunnel_ports'][0]['local'] }}', 'port' => '{{ hostvars[item.db.host|default(inventory_hostname)]['ssh_tunnel_ports'][0]['local'] }}',
), ),
), ),
{% endfor %} {% endfor %}
); );
$db_prefix = '{{ item.dbprefix }}'; $db_prefix = '{{ item.db.prefix|default("") }}';
$update_free_access = FALSE; $update_free_access = FALSE;
{% if not item.multidomain %} {% if not item.multidomain|default("FALSE") %}
$base_url = '{{ item.protocol }}://{{ item.domain }}'; $base_url = '{{ item.protocol|default("https") }}://{{ item.domain }}';
$cookie_domain = '{{ item.domain }}'; $cookie_domain = '{{ item.domain }}';
{% endif %} {% endif %}
...@@ -38,24 +38,25 @@ ini_set('session.gc_divisor', 100); ...@@ -38,24 +38,25 @@ ini_set('session.gc_divisor', 100);
ini_set('session.gc_maxlifetime', 200000); ini_set('session.gc_maxlifetime', 200000);
ini_set('session.cookie_lifetime', 2000000); ini_set('session.cookie_lifetime', 2000000);
$conf['{{ item.protocol }}'] = TRUE; $conf['{{ item.protocol|default("https") }}'] = TRUE;
if (file_exists('sites/all/modules{{ drupal_contrib_subdir }}/redis/redis.autoload.inc')) { if (file_exists('sites/all/modules{{ drupal_contrib_subdir }}/redis/redis.autoload.inc')) {
$conf['cache_backends'][] = 'sites/all/modules{{ drupal_contrib_subdir }}/redis/redis.autoload.inc'; $conf['cache_backends'][] = 'sites/all/modules{{ drupal_contrib_subdir }}/redis/redis.autoload.inc';
$conf['cache_default_class'] = 'Redis_Cache'; $conf['cache_default_class'] = 'Redis_Cache';
$conf['cache_prefix'] = '{{ item.shortname }}_'; $conf['cache_prefix'] = '{{ item.shortname|default("default") }}_';
$conf['lock_inc'] = 'sites/all/modules{{ drupal_contrib_subdir }}/redis/redis.lock.inc'; $conf['lock_inc'] = 'sites/all/modules{{ drupal_contrib_subdir }}/redis/redis.lock.inc';
$conf['path_inc'] = 'sites/all/modules{{ drupal_contrib_subdir }}/redis/redis.path.inc'; $conf['path_inc'] = 'sites/all/modules{{ drupal_contrib_subdir }}/redis/redis.path.inc';
$conf['redis_client_interface'] = 'PhpRedis'; $conf['redis_client_interface'] = 'PhpRedis';
} }
{% for line in item.extra_settings %} {% for line in item.extra_settings|default([]) %}
{{line}} {{line}}
{% endfor %} {% endfor %}
{% for config in item.conf|default([]) %} {% for config in item.conf|default([]) %}
$conf['{{ config.key }}'] = {{ config.value }}; $conf['{{ config.key }}'] = {{ config.value }};
{% endfor %} {% endfor %}
{% if item.multidomain %} {% if item.multidomain|default("FALSE") %}
include DRUPAL_ROOT . '/sites/all/modules{{ drupal_contrib_subdir }}/domain/settings.inc'; include DRUPAL_ROOT . '/sites/all/modules{{ drupal_contrib_subdir }}/domain/settings.inc';
{% endif %} {% endif %}
...@@ -2,18 +2,16 @@ ...@@ -2,18 +2,16 @@
$sites = array( $sites = array(
{% for drupaldomain in drupal.domains %} {% for drupaldomain in drupal.domains %}
'{{ drupaldomain.domain }}' => '{{ drupaldomain.shortname }}', '{{ drupaldomain.domain }}' => '{{ drupaldomain.shortname|default("default") }}',
{% for alias in drupaldomain.aliases %} {% for alias in drupaldomain.aliases|default([]) %}
'{{ alias }}' => '{{ drupaldomain.shortname }}', '{{ alias }}' => '{{ drupaldomain.shortname|default("default") }}',
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{% if drupal.sites_extra_domain is defined %} {% for drupaldomain in drupal.sites_extra_domain|default([]) %}
{% for drupaldomain in drupal.sites_extra_domain %} '{{ drupaldomain.domain }}' => '{{ drupaldomain.shortname|default("default") }}',
'{{ drupaldomain.domain }}' => '{{ drupaldomain.shortname }}', {% for alias in drupaldomain.aliases|default([]) %}
{% for alias in drupaldomain.aliases %} '{{ alias }}' => '{{ drupaldomain.shortname|default("default") }}',
'{{ alias }}' => '{{ drupaldomain.shortname }}',
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{% endif %}
//[NEXT] //[NEXT]
); );
<VirtualHost *:80> <VirtualHost *:80>
ServerAdmin {{ apache_server_admin }} ServerAdmin {{ apache_server_admin }}
ServerName {{ drupal.domains.0.domain }} ServerName {{ item.domain }}
ServerAlias{% for domain in drupal.domains %} {{ domain.domain }}{% for alias in domain.aliases %} {{ alias }}{% endfor %}{% endfor %} ServerAlias{% for alias in item.aliases|default([]) %} {{ alias }}{% endfor %}
{% if drupal.jail is defined %} {% if drupal.jail is defined %}
...@@ -14,22 +14,18 @@ ...@@ -14,22 +14,18 @@
<Directory {{ drupalRoot }}/> <Directory {{ drupalRoot }}/>
Options Indexes FollowSymLinks MultiViews Options Indexes FollowSymLinks MultiViews
AllowOverride All AllowOverride All
{% if drupal.apache_auth is defined %} {% if item.apache_auth is defined %}
AuthType {{ drupal.apache_auth.type }} AuthType {{ item.apache_auth.type }}
AuthName "{{ drupal.apache_auth.name }}" AuthName "{{ item.apache_auth.name }}"
AuthUserFile {{ webRoot }}/passwords/{{ drupal.apache_auth.user }} AuthUserFile {{ webRoot }}/passwords/{{ item.apache_auth.user }}
Require user {{ drupal.apache_auth.user }} Require user {{ item.apache_auth.user }}
{% else %} {% else %}
Order allow,deny Order allow,deny
allow from all allow from all
{% endif %} {% endif %}
</Directory> </Directory>
{% if drupal.jail is defined %} ErrorLog ${APACHE_LOG_DIR}/{{ item.domain }}-error.log
ErrorLog ${APACHE_LOG_DIR}/{{ drupal.jail.name }}-error.log
{% else %}
ErrorLog ${APACHE_LOG_DIR}/error.log
{% endif %}
LogLevel warn LogLevel warn
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment