From c6891126e5ffe47233ef5e798d7ac7e6abed4f22 Mon Sep 17 00:00:00 2001
From: Andrea Dell'Amico <adellam@isti.cnr.it>
Date: Wed, 7 Jun 2017 17:24:42 +0200
Subject: [PATCH] library/roles/ckan/ckan/tasks/ckan-plugins.yml: Do not init
 the db when installing certaing plugins, if the DB is already configured.

---
 ckan/ckan/tasks/ckan-plugins.yml | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/ckan/ckan/tasks/ckan-plugins.yml b/ckan/ckan/tasks/ckan-plugins.yml
index b73e6563..0c326d01 100644
--- a/ckan/ckan/tasks/ckan-plugins.yml
+++ b/ckan/ckan/tasks/ckan-plugins.yml
@@ -30,7 +30,9 @@
 
     - name: Initialize the CKAN ckanext-harvest plugin
       shell: . /usr/lib/ckan/default/bin/activate ; paster --plugin=ckanext-harvest harvester initdb --config={{ ckan_config_file }}
-      when: ( ckanext_harvest_install | changed )
+      when:
+        - ( ckanext_harvest_install | changed )
+        - ckan_init_db_and_solr
       tags: [ 'ckan', 'geonetwork', 'ckan_plugins' ]
 
     - name: Download the CKAN ckanext-spatial plugin
@@ -48,7 +50,9 @@
 
     - name: Initialize the CKAN ckanext-spatial plugin
       shell: . /usr/lib/ckan/default/bin/activate ; paster --plugin=ckanext-spatial spatial initdb --config={{ ckan_config_file }}
-      when: ( ckanext_spatial_install | changed )
+      when:
+        - ( ckanext_spatial_install | changed )
+        - ckan_init_db_and_solr
       tags: [ 'ckan', 'ckan_spatial', 'ckan_plugins' ]
 
     - name: Download the CKAN ckanext-geoview plugin
@@ -182,7 +186,9 @@
 
     - name: Setup the CKAN google analytics reports plugin
       shell: . /usr/lib/ckan/default/bin/activate ; cd /usr/lib/ckan/default/src/ckanext-ga-report ; paster initdb --config={{ ckan_config_file }}
-      when: ( install_ckan_ga_reports | changed )
+      when:
+        - ( install_ckan_ga_reports | changed )
+        - ckan_init_db_and_solr
       notify: Restart CKAN
       tags: [ 'ckan', 'ckan_google_analytics', 'ckan_ga_reports', 'ckan_plugins' ]