From 3d701dd46e8685a45f1e2078aafc86edabfa44e9 Mon Sep 17 00:00:00 2001
From: Andrea Dell'Amico <adellam@isti.cnr.it>
Date: Sun, 25 Mar 2018 18:58:31 +0200
Subject: [PATCH] CKAN: fix the tasks that use pip with github.

---
 ckan/ckan/tasks/ckan-plugins.yml | 27 +++++++++++++--------------
 ckan/ckan/tasks/ckan.yml         |  2 +-
 ckan/ckan/tasks/main.yml         | 10 +++++-----
 3 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/ckan/ckan/tasks/ckan-plugins.yml b/ckan/ckan/tasks/ckan-plugins.yml
index 0566b85..45dba24 100644
--- a/ckan/ckan/tasks/ckan-plugins.yml
+++ b/ckan/ckan/tasks/ckan-plugins.yml
@@ -17,7 +17,7 @@
       tags: [ 'ckan', 'geonetwork', 'ckan_plugins', 'ckan_pip_deps' ]
 
     - name: Download the CKAN ckanext-harvest plugin
-      pip: name='{{ ckan_ckanext_harvester_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }}
+      pip: name='{{ ckan_ckanext_harvester_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} editable=True
       notify: Restart CKAN
       when: ckan_geonetwork_harvester
       register: ckanext_harvest_install
@@ -36,13 +36,12 @@
       tags: [ 'ckan', 'geonetwork', 'ckan_plugins' ]
 
     - name: Download the CKAN ckanext-spatial plugin
-      pip: name='{{ ckan_ckanext_spatial_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }}
+      pip: name='{{ ckan_ckanext_spatial_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} editable=True
       notify: Restart CKAN
       when: ckan_geonetwork_harvester
       register: ckanext_spatial_install
       tags: [ 'ckan', 'ckan_spatial', 'ckan_plugins' ]
 
-    # SQL alchemy cannot be too new. Otherwise it will not work against VDM
     - name: Download the CKAN ckanext-spatial requirements
       pip: requirements={{ ckan_virtenv }}/src/ckanext-spatial/pip-requirements.txt virtualenv={{ ckan_virtenv }} state=present
       when: ckan_geonetwork_harvester
@@ -56,13 +55,13 @@
       tags: [ 'ckan', 'ckan_spatial', 'ckan_plugins' ]
 
     - name: Download the CKAN ckanext-geoview plugin
-      pip: name='{{ ckan_geoview_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }}
+      pip: name='{{ ckan_geoview_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} editable=True
       notify: Restart CKAN
       when: ckan_geoview
       tags: [ 'ckan', 'ckan_geoview', 'ckan_plugins' ]
 
     - name: Download the CKAN ckanext-dcat plugin code
-      pip: name={{ ckan_dcat_url }} virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }}
+      pip: name={{ ckan_dcat_url }} virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} editable=True
       when: ckan_dcat
       notify: Restart CKAN
       tags: [ 'ckan', 'ckan_dcat', 'ckan_plugins' ]
@@ -108,43 +107,43 @@
       tags: [ 'ckan', 'ckan_privdatasets', 'ckan_plugins' ]
   
     - name: Download the CKAN hierarchy plugin code
-      pip: name='{{ ckan_hierarchy_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }}
+      pip: name='{{ ckan_hierarchy_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} editable=True
       when: ckan_hierarchy
       notify: Restart CKAN 
       tags: [ 'ckan', 'ckan_hierarchy', 'ckan_plugins' ]
   
     - name: Download the CKAN pages plugin code
-      pip: name='{{ ckan_pages_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }}
+      pip: name='{{ ckan_pages_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} editable=True
       when: ckan_pages
       notify: Restart CKAN 
       tags: [ 'ckan', 'ckan_pages', 'ckan_plugins' ]
 
     - name: Download the CKAN LDAP plugin code
-      git: repo={{ ckan_ldap_url }} dest=/usr/lib/ckan/default/src/ckanext-ldap force=yes update={{ ckan_git_plugins_state }}
+      git: repo={{ ckan_ldap_url }} dest=/usr/lib/ckan/default/src/ckanext-ldap force=yes update={{ ckan_git_plugins_state }} editable=True
       when: ckan_ldap
       register: install_ldap_plugin
       tags: [ 'ckan', 'ckan_ldap', 'ckan_plugins' ]
 
-    - name: Install the CKAN Geonetwork plugin code
+    - name: Enable the CKAN ldap plugin code
       shell: . /usr/lib/ckan/default/bin/activate ; cd /usr/lib/ckan/default/src/ckanext-ldap ; python setup.py develop
       when: ( install_ldap_plugin | changed )
       notify: Restart CKAN
       tags: [ 'ckan', 'ckan_ldap', 'ckan_plugins' ]
 
     - name: Download the CKAN LIRE plugin code
-      git: repo={{ ckan_ckanext_lire_url }} dest={{ ckan_virtenv }}/src/ckanext-lire force=yes update={{ ckan_git_plugins_state }}
+      git: repo={{ ckan_ckanext_lire_url }} dest={{ ckan_virtenv }}/src/ckanext-lire force=yes update={{ ckan_git_plugins_state }} editable=True
       when: ckan_ckanext_lire
       register: install_lire_plugin
       tags: [ 'ckan', 'ckan_lire', 'ckan_plugins' ]
 
-    - name: Install the CKAN Geonetwork plugin code
+    - name: Activate the CKAN Lire plugin code
       shell: . /usr/lib/ckan/default/bin/activate ; cd {{ ckan_virtenv }}/src/ckanext-lire ; pip install -e ./
       when: ( install_lire_plugin | changed ) 
       notify: Restart CKAN 
       tags: [ 'ckan', 'ckan_lire', 'ckan_plugins' ]
 
     - name: Download the CKAN OAI-PMH plugin
-      pip: name='{{ ckan_oai_pmh_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }}
+      pip: name='{{ ckan_oai_pmh_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} editable=True
       when: ckan_oai_pmh
       notify: Restart CKAN 
       tags: [ 'ckan', 'ckan_oai_pmh', 'ckan_plugins' ]
@@ -174,7 +173,7 @@
       tags: [ 'ckan', 'ckan_google_analytics', 'ckan_plugins' ]
 
     - name: Download the CKAN google analytics reports plugin
-      pip: name='{{ ckan_ga_reports_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }}
+      pip: name='{{ ckan_ga_reports_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }}  editable=True
       when: ckan_ga_reports
       register: install_ckan_ga_reports
       tags: [ 'ckan', 'ckan_google_analytics', 'ckan_ga_reports', 'ckan_plugins' ]
@@ -188,7 +187,7 @@
       tags: [ 'ckan', 'ckan_google_analytics', 'ckan_ga_reports', 'ckan_plugins' ]
 
     - name: Install the CKAN profiler plugin
-      pip: name='{{ ckan_profiler_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }}
+      pip: name='{{ ckan_profiler_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }}  editable=True
       when: ckan_profiler
       notify: Restart CKAN
       tags: [ 'ckan', 'ckan_profiler', 'ckan_plugins' ]
diff --git a/ckan/ckan/tasks/ckan.yml b/ckan/ckan/tasks/ckan.yml
index 7eb1026..4f9952b 100644
--- a/ckan/ckan/tasks/ckan.yml
+++ b/ckan/ckan/tasks/ckan.yml
@@ -28,7 +28,7 @@
   tags: ckan
 
 - name: authorization file for the psql command, if the database is on a remote server
-  template: src=pgpass.j2 dest={{ pg_backup_pass_file }} owner=root mode=0600
+  template: src=pgpass.j2 dest=/root/.pgpass owner=root mode=0600
   when: "'{{ psql_db_host }}' != 'localhost'"
   tags: [ 'pg_backup', 'postgresql', 'postgres' ]
 
diff --git a/ckan/ckan/tasks/main.yml b/ckan/ckan/tasks/main.yml
index c922927..97c5acd 100644
--- a/ckan/ckan/tasks/main.yml
+++ b/ckan/ckan/tasks/main.yml
@@ -1,6 +1,6 @@
 ---
-- include: ckan.yml
-- include: ckan-plugins.yml
-- include: ckan-config.yml
-- include: enable-ckan.yml
-- include: supervisor.yml 
+- import_tasks: ckan.yml
+- import_tasks: ckan-plugins.yml
+- import_tasks: ckan-config.yml
+- import_tasks: enable-ckan.yml
+- import_tasks: supervisor.yml