Skip to content
Snippets Groups Projects
Commit 69ba927e authored by jurgenhaas's avatar jurgenhaas
Browse files

Improve Drupal installation

parent 4aaee0ac
Branches
No related tags found
No related merge requests found
......@@ -3,30 +3,36 @@
- name: "Apache configuration file for our site(s)"
template:
src='etc_apache2_sites_available_vhost'
dest='/etc/apache2/sites-available/{{ item.apache_site|default(item.jail.name) }}{{ apache_conf_ext }}'
src='vhost.conf'
dest='/etc/apache2/sites-available/{{ drupal.apache_site|default(drupal.jail.name) }}{{ apache_conf_ext }}'
owner='root'
group='root'
mode='664'
with_items: drupal_settings
when: item.jail is defined or item.apache_site
when: drupal.jail is defined or drupal.apache_site
notify:
- "Apache | Restart Apache"
- name: "Apache enable our new site(s)"
command: a2ensite {{ item.apache_site|default(item.jail.name) }} creates=/etc/apache2/sites-enabled/{{ item.apache_site|default(item.jail.name) }}{{ apache_conf_ext }}
with_items: drupal_settings
when: item.jail is defined or item.apache_site
command: a2ensite {{ drupal.apache_site|default(drupal.jail.name) }} creates=/etc/apache2/sites-enabled/{{ drupal.apache_site|default(drupal.jail.name) }}{{ apache_conf_ext }}
when: drupal.jail is defined or drupal.apache_site
notify:
- "Apache | Restart Apache"
- name: "Ensure Password Directory"
file:
path='{{ webRoot }}/passwords'
state='directory'
owner='www-data'
group='www-data'
mode=755
when: drupal.apache_auth is defined
- name: "Setup AuthType Basic"
htpasswd:
path='/var/www/passwords/{{ item.apache_auth.user }}'
name='{{ item.apache_auth.user }}'
password='{{ item.apache_auth.password }}'
path='{{ webRoot }}/passwords/{{ drupal.apache_auth.user }}'
name='{{ drupal.apache_auth.user }}'
password='{{ drupal.apache_auth.password }}'
owner='www-data'
group='www-data'
mode='640'
with_items: drupal_settings
when: item.apache_auth is defined
when: drupal.apache_auth is defined
---
# file: roles/drupal/tasks/drupal.yml
# file: roles/drupal/tasks/configure.yml
- name: "Drupal | Create the sites/sites.php file"
- name: "Configuration file"
template:
src={{ item.1.src }}
dest={{ item.1.dest }}
owner=www-data
group=www-data
mode=0664
with_subelements:
- drupal_settings
- templates
src='{{ item.src }}'
dest='{{ drupalRoot }}/{{ item.dest }}'
owner='www-data'
group='www-data'
mode='664'
with_items: drupal.templates
- name: "Drupal | Create the sites sub-directories"
- name: "Create the sites sub-directories"
file:
dest=/var/www/{{ item.0.root }}/sites/{{ item.1.shortname }}
state=directory
owner=www-data
group=www-data
mode=555
with_subelements:
- drupal_settings
- domains
dest='{{ drupalRoot }}/sites/{{ item.0.shortname }}/{{ item.1 }}'
state='directory'
owner='www-data'
group='www-data'
mode='755'
with_nested:
- drupal.domains
- [ 'files', 'private' ]
# TODO: How can we loop over two nested lists?
#- name: "Drupal | Create script to create sub-directory-links"
......@@ -44,35 +42,11 @@
# notify:
# - "Drupal | Execute script to create sub-directory-links"
- name: "Drupal | Create the sites file directories"
file:
dest=/var/www/{{ item.0.root }}/sites/{{ item.1.shortname }}/files
state=directory
owner=www-data
group=www-data
mode=775
with_subelements:
- drupal_settings
- domains
- name: "Drupal | Create the sites private directories"
file:
dest=/var/www/{{ item.0.root }}/sites/{{ item.1.shortname }}/private
state=directory
owner=www-data
group=www-data
mode=775
with_subelements:
- drupal_settings
- domains
- name: "Drupal | Create the settings.php files"
- name: "Create the settings.php files"
template:
src={{ item.0.template_dir|default('') }}{{ item.0.version }}_settings.php
dest=/var/www/{{ item.0.root }}/sites/{{ item.1.shortname }}/settings.php
owner=www-data
group=www-data
mode=0444
with_subelements:
- drupal_settings
- domains
src='{{ drupal.template_dir|default('') }}{{ drupal.version }}_settings.php'
dest='{{ drupalRoot }}/sites/{{ item.shortname }}/settings.php'
owner='www-data'
group='www-data'
mode='444'
with_items: drupal.domains
---
# file: roles/drupal/tasks/install.drush.yml
- name: "Copy Drush Make Files"
copy:
src='{{ inventory_dir }}/files/drush/{{ item.src.makefile }}.make'
dest='{{ webRoot }}/drush/{{ item.src.makefile }}.make'
owner='www-data'
group='www-data'
mode='664'
- name: "Drush Make"
shell: drush make --force-complete '{{ webRoot }}/drush/{{ item.src.makefile }}.make' . chdir='{{ drupalRoot }}'
become: no
---
# file: roles/drupal/tasks/install.gitscript.yml
- name: "Clone Git Repository"
git:
accept_hostkey: "yes"
repo: "{{ drupal.src.git.repository }}"
dest: "{{ webRoot }}/{{ drupal.src.git.target }}"
force: "yes"
version: "{{ drupal.src.git.branch|default(omit) }}"
become: false
- name: "Run Script"
shell: "{{ webRoot }}/{{ drupal.src.git.target }}/{{ drupal.src.script }}"
---
# file: roles/drupal/tasks/install.svn.yml
- name: "Install and update Drupal trees from SVN"
subversion:
repo='{{ drupal.src.url }}'
dest='{{ drupalRoot }}'
force=yes
become: no
---
# file: roles/drupal/tasks/install.yml
- name: 'Drupal | Change mode for web server files'
file:
path=/var/www
mode=g+w
recurse=yes
- set_fact: drupal='{{ item }}'
- set_fact: webRoot='/var/www'
- set_fact: webRoot='{{ jailroot }}{{ drupal.jail.name }}/var/www'
when: drupal.jail is defined
- set_fact: drupalRoot='{{ webRoot }}/{{ drupal.root }}'
- name: "Drupal | Create script to determine which trees do not yet exist"
template:
src=find_missing_repos
dest=/tmp/find_missing_repos
owner=root
group=root
mode=700
- name: "Configure Apache"
include: apache.yml
- name: "Drupal | Execute script to determine which trees do not yet exist"
shell: /tmp/find_missing_repos
register: drupal_missing_repos
- name: "Drupal | Prepare Drupal Directories"
- name: "Ensure Drupal Root Directory"
file:
path=/var/www/{{ item.src.target }}
state=directory
recurse=yes
owner=www-data
group=www-data
path='{{ drupalRoot }}'
state='directory'
owner='{{ drupal.jail.name|default("www-data") }}'
group='www-data'
mode=775
with_items: drupal_settings
when: item.root in drupal_missing_repos.stdout_lines
- name: "Drupal | SVN | Install and update Drupal trees from SVN"
subversion:
repo={{ item.src.url }}
dest=/var/www/{{ item.src.target }}
force=yes
become: no
with_items: drupal_settings
when: item.root in drupal_missing_repos.stdout_lines and item.src.mode == 'svn'
notify:
- "Apache | Change ownership for web server files"
- "Apache | Change mode for web server files"
- name: "Drupal | Drush | Copy Drush Make files to the server"
copy:
src={{ inventory_dir }}/files/drush/{{ item.src.makefile }}.make
dest=/var/www/drush/{{ item.src.makefile }}.make
owner=www-data
group=www-data
mode=664
with_items: drupal_settings
when: item.src.mode == 'drush'
- name: "Drupal | Drush | Install and update Drupal trees from Drush Make"
shell: drush make --force-complete '/var/www/drush/{{ item.src.makefile }}.make' . chdir='/var/www/{{ item.root }}'
become: no
with_items: drupal_settings
when: item.root in drupal_missing_repos.stdout_lines and item.src.mode == 'drush'
notify:
- "Apache | Change ownership for web server files"
- "Apache | Change mode for web server files"
- name: "File Modes and Ownership"
file:
path='{{ drupalRoot }}'
owner='{{ drupal.jail.name|default("www-data") }}'
group='www-data'
mode='g+w'
recurse=yes
- name: "Drupal | GitScript | Clone repository"
git:
accept_hostkey: "yes"
repo: "{{ item.src.git.repository }}"
dest: "{{ item.src.git.target }}"
force: "yes"
version: "{{ item.src.git.branch|default(omit) }}"
become: false
with_items: drupal_settings
when: item.root in drupal_missing_repos.stdout_lines and item.src.mode == 'gitscript'
- name: "Check Installation Requirement"
shell: ls {{ drupalRoot }}/index.php
register: drupal_available
failed_when: false
- name: "Drupal | GitScript | Run script"
shell: "{{ item.src.git.target }}/{{ item.src.script }}"
with_items: drupal_settings
when: item.root in drupal_missing_repos.stdout_lines and item.src.mode == 'gitscript'
- include: install.{{ drupal.src.mode }}.yml
when: drupal_install_drupal and drupal_available is defined and drupal_available.stdout != '{{ drupalRoot }}/index.php'
- include: configure.yml
when: drupal_configure_drupal
- name: 'Drupal | Change mode for web server root directory'
- name: "File Modes and Ownership"
file:
path=/var/www
mode=755
path='{{ drupalRoot }}/{{ item.dir }}'
owner='{{ drupal.jail.name|default("www-data") }}'
group='www-data'
mode='{{ item.mode }}'
recurse={{ item.recurse|default(yes) }}
with_items:
- { dir: '', mode: 'a-w' }
- { dir: 'sites', mode: 'u+w' }
- { dir: 'sites/all', mode: 'u-w' }
- { dir: 'sites/*', mode: 'u-w', recurse: no }
---
# file: roles/drupal/tasks/main.yml
- name: "Drupal | Configure Apache"
include: apache.yml
- name: "Drupal | Install Drupal"
include: install.yml
with_items: drupal_settings
when: drupal_install_drupal
- name: "Drupal | Configure Drupal"
include: drupal.yml
when: drupal_configure_drupal
- name: "Drupal | Update Drupal"
include: update.yml
when: drupal_update_drupal
---
# file: roles/drupal/tasks/update.yml
- debug: msg="Updating Drupal trees is not yet implemented"
<VirtualHost *:80>
ServerAdmin {{ apache_server_admin }}
ServerName {{ item.domains.0.domain }}
ServerAlias{% for domain in item.domains %} {{ domain.domain }}{% for alias in domain.aliases %} {{ alias }}{% endfor %}{% endfor %}
ServerName {{ drupal.domains.0.domain }}
ServerAlias{% for domain in drupal.domains %} {{ domain.domain }}{% for alias in domain.aliases %} {{ alias }}{% endfor %}{% endfor %}
{% if item.jail is defined %}
{% if drupal.jail is defined %}
<ifmodule mpm_itk_module>
AssignUserID {{ item.jail.name }} {{ item.jail.name }}
AssignUserID {{ drupal.jail.name }} {{ drupal.jail.name }}
</ifmodule>
DocumentRoot {{ jailroot }}/{{ item.jail.name }}/var/www
<Directory {{ jailroot }}/{{ item.jail.name }}/var/www/>
{% else %}
DocumentRoot /var/www/{{ item.root }}
<Directory /var/www/{{ item.root }}/>
{% endif %}
DocumentRoot {{ drupalRoot }}
<Directory {{ drupalRoot }}/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
{% if item.apache_auth is defined %}
AuthType {{ item.apache_auth.type }}
AuthName "{{ item.apache_auth.name }}"
AuthUserFile /var/www/passwords/{{ item.apache_auth.user }}
Require user {{ item.apache_auth.user }}
{% if drupal.apache_auth is defined %}
AuthType {{ drupal.apache_auth.type }}
AuthName "{{ drupal.apache_auth.name }}"
AuthUserFile {{ webRoot }}/passwords/{{ drupal.apache_auth.user }}
Require user {{ drupal.apache_auth.user }}
{% else %}
Order allow,deny
allow from all
{% endif %}
</Directory>
{% if item.jail is defined %}
ErrorLog ${APACHE_LOG_DIR}/{{ item.jail.name }}-error.log
{% if drupal.jail is defined %}
ErrorLog ${APACHE_LOG_DIR}/{{ drupal.jail.name }}-error.log
{% else %}
ErrorLog ${APACHE_LOG_DIR}/error.log
{% endif %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment