From cafa075542b5ccbaee4bf89d584e4534247e3e1b Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 11 May 2021 16:26:50 +0200 Subject: [PATCH] Fixes 21386. Fix the ckan 2.6 python version. --- tasks/ckan-plugins.yml | 34 +++++++++++++++++----------------- tasks/ckan.yml | 28 ++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/tasks/ckan-plugins.yml b/tasks/ckan-plugins.yml index 3a1a9d4..a51dd3a 100644 --- a/tasks/ckan-plugins.yml +++ b/tasks/ckan-plugins.yml @@ -40,7 +40,7 @@ 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 }} editable=True + pip: name='{{ ckan_ckanext_spatial_url }}' virtualenv={{ ckan_virtenv }} state=present editable=True notify: Restart CKAN when: ckan_geonetwork_harvester | bool register: ckanext_spatial_install @@ -59,13 +59,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=present notify: Restart CKAN when: ckan_geoview | bool tags: [ 'ckan', 'ckan_geoview', 'ckan_plugins' ] - name: Download the latest version of the CKAN ckanext-dcat plugin code on CKAN version >= 2.8 - pip: name={{ ckan_dcat_url }} virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} editable=True + pip: name={{ ckan_dcat_url }} virtualenv={{ ckan_virtenv }} state=present editable=True when: - ckan_dcat | bool - ckan_version is version_compare('2.8', '>=') @@ -73,7 +73,7 @@ tags: [ 'ckan', 'ckan_dcat', 'ckan_plugins' ] - name: Download the CKAN ckanext-dcat plugin code. Stick to version 1.0.0 on CKAN < 2.8 - pip: name={{ ckan_dcat_1_0_0_url }} virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} editable=True + pip: name={{ ckan_dcat_1_0_0_url }} virtualenv={{ ckan_virtenv }} state=present editable=True when: - ckan_dcat | bool - ckan_version is version_compare('2.8', '<') @@ -109,13 +109,13 @@ tags: [ 'ckan', 'ckan_geonetwork', 'ckan_plugins', 'tracker' ] - name: Download the CKAN PDF viewer plugin - pip: name='{{ ckan_ckanext_pdfview_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} + pip: name='{{ ckan_ckanext_pdfview_url }}' virtualenv={{ ckan_virtenv }} state=present when: ckan_pdfview | bool notify: Restart CKAN tags: [ 'ckan', 'ckan_pdfview', 'ckan_plugins' ] - name: Download the CKAN Privatedatasets extension for CKAN 2.8 - pip: name='{{ ckan_privatedatasets_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} + pip: name='{{ ckan_privatedatasets_url }}' virtualenv={{ ckan_virtenv }} state=present when: - ckan_privatedatasets | bool - ckan_version is version_compare('2.8', '>=') @@ -123,7 +123,7 @@ tags: [ 'ckan', 'ckan_privdatasets', 'ckan_plugins' ] - name: Download the CKAN Privatedatasets extension for CKAN 2.6 - pip: name='{{ ckan_privatedatasets_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} version=0.2.19 + pip: name='{{ ckan_privatedatasets_url }}' virtualenv={{ ckan_virtenv }} state=present version=0.2.19 when: - ckan_privatedatasets | bool - ckan_version is version_compare('2.8', '<') @@ -131,13 +131,13 @@ 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 }} editable=True + pip: name='{{ ckan_hierarchy_url }}' virtualenv={{ ckan_virtenv }} state=present editable=True when: ckan_hierarchy | bool 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 }} editable=True + pip: name='{{ ckan_pages_url }}' virtualenv={{ ckan_virtenv }} state=present editable=True when: ckan_pages | bool notify: Restart CKAN tags: [ 'ckan', 'ckan_pages', 'ckan_plugins' ] @@ -167,37 +167,37 @@ tags: [ 'ckan', 'ckan_lire', 'ckan_plugins' ] - name: Download the KATA CKAN OAI-PMH plugin - pip: name='{{ ckan_oai_pmh_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} editable=True + pip: name='{{ ckan_oai_pmh_url }}' virtualenv={{ ckan_virtenv }} state=present editable=True when: ckan_kata_oai_pmh | bool notify: Restart CKAN tags: [ 'ckan', 'ckan_oai_pmh', 'ckan_plugins' ] - name: Download the KATA CKAN ckanext-oaiphm requirements - pip: requirements={{ ckan_virtenv }}/src/ckanext-oaipmh/requirements.txt virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} + pip: requirements={{ ckan_virtenv }}/src/ckanext-oaipmh/requirements.txt virtualenv={{ ckan_virtenv }} state=present when: ckan_kata_oai_pmh | bool notify: Restart CKAN tags: [ 'ckan', 'ckan_oai_pmh', 'ckan_plugins' ] - name: Download the KATA CKAN plugin - pip: name='{{ ckan_oai_pmh_kata_plugin_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} editable=True + pip: name='{{ ckan_oai_pmh_kata_plugin_url }}' virtualenv={{ ckan_virtenv }} state=present editable=True when: ckan_kata_oai_pmh | bool notify: Restart CKAN tags: [ 'ckan', 'ckan_oai_pmh', 'ckan_plugins' ] - name: Download the KATA CKAN requirements - pip: requirements={{ ckan_virtenv }}/src/ckanext-kata/requirements.txt virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} + pip: requirements={{ ckan_virtenv }}/src/ckanext-kata/requirements.txt virtualenv={{ ckan_virtenv }} state=present when: ckan_kata_oai_pmh | bool notify: Restart CKAN tags: [ 'ckan', 'ckan_oai_pmh', 'ckan_plugins' ] - name: Download the opendatasoft CKAN OAI-PMH plugin - pip: name='{{ ckan_oai_pm_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} editable=True + pip: name='{{ ckan_oai_pm_url }}' virtualenv={{ ckan_virtenv }} state=present editable=True when: ckan_oai_pm | bool notify: Restart CKAN tags: [ 'ckan', 'ckan_oai_pm', 'ckan_plugins' ] - name: Download the CKAN google analytics plugin python requirements - pip: name='genshi' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} + pip: name='genshi' virtualenv={{ ckan_virtenv }} state=present when: ckan_google_analytics | bool notify: Restart CKAN tags: [ 'ckan', 'ckan_google_analytics', 'ckan_plugins' ] @@ -216,7 +216,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 }} editable=True + pip: name='{{ ckan_ga_reports_url }}' virtualenv={{ ckan_virtenv }} state=present editable=True when: ckan_ga_reports | bool register: install_ckan_ga_reports tags: [ 'ckan', 'ckan_google_analytics', 'ckan_ga_reports', 'ckan_plugins' ] @@ -245,7 +245,7 @@ tags: [ 'ckan', 'ckan_star_ratings', 'ckan_plugins' ] - name: Install the CKAN profiler plugin - pip: name='{{ ckan_profiler_url }}' virtualenv={{ ckan_virtenv }} state={{ ckan_plugins_state }} editable=True + pip: name='{{ ckan_profiler_url }}' virtualenv={{ ckan_virtenv }} state=present editable=True when: ckan_profiler | bool notify: Restart CKAN tags: [ 'ckan', 'ckan_profiler', 'ckan_plugins' ] diff --git a/tasks/ckan.yml b/tasks/ckan.yml index dc6d99e..80ca0e5 100644 --- a/tasks/ckan.yml +++ b/tasks/ckan.yml @@ -1,4 +1,7 @@ --- +- name: Create the CKAN user + user: name={{ ckan_shell_user }} home={{ ckan_libdir }} createhome=no shell=/usr/sbin/nologin system=yes + - name: Download the CKAN distribution get_url: url='{{ ckan_package_url }}' dest=/srv/{{ ckan_deb_file }} force=yes tags: [ 'ckan', 'ckan_pkg' ] @@ -8,8 +11,12 @@ register: ckan_install tags: [ 'ckan', 'ckan_pkg' ] -- name: Create the CKAN user - user: name={{ ckan_shell_user }} home={{ ckan_libdir }} createhome=no shell=/usr/sbin/nologin system=yes +- name: Fix the python version in the CKAN virtualenv + unarchive: + src: 'https://ftp.d4science.org/ubuntu-misc-binaries/ckan-default-python-2.7.14.tar.gz' + dest: '{{ ckan_libdir }}' + remote_src: yes + creates: '{{ ckan_virtenv }}/bin/get-pip.py' - name: Configure the CKAN production configuration file excluding the plugins list ini_file: dest={{ ckan_config_file }} section={{ item.section }} option={{ item.option }} value={{ item.value }} state={{ item.state }} backup=yes @@ -23,12 +30,17 @@ tags: [ 'ckan', 'apache', 'ckan_pkg' ] - name: Create the base directory for the CKAN file storage - file: dest={{ ckan_file_storage_dir }} state=directory owner={{ apache_user }} group={{ ckan_shell_user }} mode=2770 - tags: ckan + file: + dest: '{{ ckan_file_storage_dir }}' + state: directory + owner: '{{ apache_user }}' + group: '{{ ckan_shell_user }}' + mode: '2770' + tags: [ 'ckan' ] - name: Fix the CKAN harvesting storage permissions - file: dest={{ ckan_file_harvesting_dir }} state=directory owner={{ apache_user }} group={{ ckan_shell_user }} mode=2770 recurse=yes - tags: ckan + file: dest={{ ckan_file_harvesting_dir }} state=directory owner={{ apache_user }} group={{ ckan_shell_user }} mode='2770' recurse=yes + tags: [ 'ckan' ] - name: authorization file for the psql command, if the database is on a remote server template: src=pgpass.j2 dest=/root/.pgpass owner=root mode=0600 @@ -40,14 +52,14 @@ args: creates: '{{ ckan_libdir }}/.ckan_db_initialized' when: ckan_init_db_and_solr - tags: ckan + tags: [ 'ckan' ] - name: Initialize the CKAN datastore database shell: ckan datastore set-permissions | psql --set ON_ERROR_STOP=1 -h {{ psql_db_host }} -U {{ ckan_db_user }} -w {{ ckan_datastore_db_name }} && touch {{ ckan_libdir }}/.ckan_datastore_db_initialized args: creates: '{{ ckan_libdir }}/.ckan_datastore_db_initialized' when: ckan_init_db_and_solr - tags: ckan + tags: [ 'ckan' ] - name: Create the pip cache directory with the right permissions file: dest={{ ckan_libdir }}/.cache owner={{ ckan_shell_user }} group={{ ckan_shell_user }} state=directory