From 3ff3cdfddbcd23c1c388ccb5af24332d7f491904 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Mon, 4 Jul 2016 11:55:36 +0200
Subject: [PATCH] ansible-roles/drupal#10 Implement execution of post deploy
 tasks

---
 defaults/main.yml            | 12 +++---------
 tasks/deploy/gitcomposer.yml | 16 ++++++++++++++++
 tasks/install.yml            |  7 +++++++
 3 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/defaults/main.yml b/defaults/main.yml
index 1a63fd1..d52203c 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -8,28 +8,22 @@ drupal_config_directories:
 
 drupal_post_deploy_tasks:
   d6:
-    - 'pull-data'
-    - 'pre-processing'
     - 'registry-rebuild'
-    - 'dev-modules {{ (drupal.dev_mode|default("False"))|ternary("on","off") }}'
     - 'updatedb'
     - 'cache-clear all'
+    - 'dev-modules {{ (drupal.dev_mode|default(false))|ternary("on","off") }}'
   d7:
-    - 'pull-data'
-    - 'pre-processing'
     - 'registry-rebuild'
-    - 'dev-modules {{ (drupal.dev_mode|default("False"))|ternary("on","off") }}'
     - 'features-revert-all'
     - 'updatedb'
     - 'cache-clear all'
+    - 'dev-modules {{ (drupal.dev_mode|default(false))|ternary("on","off") }}'
   d8:
-    - 'pull-data'
-    - 'pre-processing'
     - 'cache-rebuild all'
-    - 'dev-modules {{ (drupal.dev_mode|default("False"))|ternary("on","off") }}'
     - 'config-import sync'
     - 'updatedb'
     - 'entity-updates'
+    - 'dev-modules {{ (drupal.dev_mode|default(false))|ternary("on","off") }}'
 
 letsencrypt_pause_services:
   - 'apache2'
diff --git a/tasks/deploy/gitcomposer.yml b/tasks/deploy/gitcomposer.yml
index a83dfe2..6132dcd 100644
--- a/tasks/deploy/gitcomposer.yml
+++ b/tasks/deploy/gitcomposer.yml
@@ -23,3 +23,19 @@
   composer:
     command='update'
     working_dir='{{ webRoot }}'
+
+# The following is a workaround until Drupal's packaging supports libraries, see https://www.drupal.org/node/2474007
+
+- name: "Ensure Drush Contrib Directory"
+  file:
+    path: '{{ webRoot }}/drush/contrib'
+    state: 'directory'
+    owner: 'root'
+    group: 'root'
+
+- name: "Link all global Drush commands"
+  file:
+    src='{{ composer_home_path }}/vendor/drush/drush/commands/{{ item|regex_replace("(.*)(\-\d\.x\-\d\.x)", "\\1") }}'
+    dest='{{ webRoot }}/drush/contrib/{{ item|regex_replace("(.*)(\-\d\.x\-\d\.x)", "\\1") }}'
+    state='link'
+  with_items: '{{ drush_extra_commands }}'
diff --git a/tasks/install.yml b/tasks/install.yml
index 13c8600..c3ed9b6 100644
--- a/tasks/install.yml
+++ b/tasks/install.yml
@@ -7,12 +7,14 @@
       cronUser='root'
       apacheUser='www-data'
       apacheLogDir='/var/log/apache2'
+      drushSubkey='{{ drupal.drush_subkey|default("") }}'
     when: drupal.jail is not defined
   - set_fact:
       webRoot='{{ jailroot }}/{{ drupal.jail.name }}/var/www{{ drupal.webRoot|default("") }}'
       cronUser='{{ drupal.jail.name }}'
       apacheUser='{{ drupal.jail.name }}'
       apacheLogDir='{{ jailroot }}/{{ drupal.jail.name }}/var/log/apache2'
+      drushSubkey='.{{ drupal.jail.name }}'
     when: drupal.jail is defined
   - set_fact:
       installSource={{ drupal.src|default([]) }}
@@ -195,3 +197,8 @@
   with_items: '{{ drupal.domains }}'
   loop_control:
     loop_var: drupal_domain
+
+- name: "Run Post Deploy Tasks"
+  shell: drush -y @{{ inventory_hostname }}{{ drushSubkey }} {{ item }}
+  with_items: '{{ drupal_post_deploy_tasks[drupal.version|default("d7")] }}'
+  tags: 'deploy'
-- 
GitLab