From b8f7bc795a202651f647420e7ee36b5464d6db4b Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 24 Nov 2017 16:45:20 +0100 Subject: [PATCH] ckan_connector: convert to maven_artifact. --- smartgears/ckan_connector/defaults/main.yml | 9 ++--- smartgears/ckan_connector/tasks/main.yml | 37 ++++++++++++++++----- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/smartgears/ckan_connector/defaults/main.yml b/smartgears/ckan_connector/defaults/main.yml index 54518aac..d4aa4b33 100644 --- a/smartgears/ckan_connector/defaults/main.yml +++ b/smartgears/ckan_connector/defaults/main.yml @@ -1,9 +1,10 @@ --- ckan_connector_gcube_repository: 'gcube-staging' ckan_connector_plugin_install: False -ckan_connector_ver: 1.1.2-4.3.0-142056 +ckan_connector_ver: latest ckan_connector_name: ckan-connector -ckan_connector_filename: '{{ ckan_connector_name }}-{{ ckan_connector_ver }}.war' -ckan_connector_url: 'http://maven.research-infrastructures.eu/nexus/content/repositories/{{ ckan_connector_gcube_repository }}/org/gcube/data/access/{{ ckan_connector_name }}/{{ ckan_connector_ver}}/{{ ckan_connector_filename }}' -ckan_connector_war_file: '{{ ckan_connector_name }}.war' +ckan_connector_extension: war +ckan_connector_group_id: org.gcube.data.access +ckan_connector_filename: '{{ ckan_connector_name }}-{{ ckan_connector_ver }}.{{ ckan_connector_extension }}' + ckan_connector_user: ckan_connector diff --git a/smartgears/ckan_connector/tasks/main.yml b/smartgears/ckan_connector/tasks/main.yml index d61093a5..caec64bc 100644 --- a/smartgears/ckan_connector/tasks/main.yml +++ b/smartgears/ckan_connector/tasks/main.yml @@ -1,29 +1,48 @@ --- - block: - - name: Remove the installed CKAN connector before upgrading + - name: Remove the installed CKAN connector file: dest={{ item }} state=absent with_items: - - '{{ smartgears_instance_path }}/webapps/ckan-connector' - - '{{ smartgears_instance_path }}/webapps/ckan-connector.war' + - '{{ smartgears_instance_path }}/webapps/{{ ckan_connector_name }}' + - '{{ smartgears_instance_path }}/webapps/{{ ckan_connector_name }}.{{ ckan_connector_extension }}' when: smartgears_upgrade + - name: Remove the CKAN connector fixer script + become_user: root + file: dest=/usr/local/bin/ckan-connector-fixer state=absent + + become: True + become_user: '{{ smartgears_user }}' + when: not ckan_connector_plugin_install + tags: [ 'smartgears', 'ckan', 'ckan_connector', 'tomcat' ] + +- block: - name: Get the CKAN connector war file - get_url: url={{ ckan_connector_url }} dest={{ smartgears_instance_path }}/webapps/{{ ckan_connector_war_file }} + maven_artifact: artifact_id={{ ckan_connector_name }} version={{ ckan_connector_ver }} group_id={{ ckan_connector_group_id }} extension={{ ckan_connector_extension }} repository_url={{ smartgears_global_base_url }} dest={{ smartgears_downloads_dir }}/{{ ckan_connector_filename }} + register: ckan_connector_download + + - name: Remove the installed CKAN connector before upgrading + file: dest={{ smartgears_instance_path }}/webapps/{{ ckan_connector_name }} state=absent + when: ( ckan_connector_download | changed ) + + - name: Create the CKAN connector webapp directory + file: dest={{ smartgears_instance_path }}/webapps/{{ ckan_connector_name }} state=directory + when: ( ckan_connector_download | changed ) - - name: Unpack the CKAN connector war file - shell: mkdir {{ smartgears_instance_path }}/webapps/ckan-connector ; cd {{ smartgears_instance_path }}/webapps/ckan-connector ; jar xf {{ smartgears_instance_path }}/webapps/{{ ckan_connector_war_file }} + - name: Unarchive the CKAN connector war file + unarchive: copy=no src={{ smartgears_downloads_dir }}/{{ ckan_connector_filename }} dest={{ smartgears_instance_path }}/webapps/{{ ckan_connector_name }} args: - creates: '{{ smartgears_instance_path }}/webapps/ckan-connector/WEB-INF/web.xml' + creates: '{{ smartgears_instance_path }}/webapps/{{ ckan_connector_name }}/WEB-INF/web.xml' - name: Install the CKAN connector web.xml template template: src=ckan-web.xml.j2 dest={{ smartgears_instance_path }}/webapps/ckan-connector/WEB-INF/.web.xml.tpl mode=0440 - name: Install the CKAN connector fixer script - become: False + become_user: root template: src=ckan-connector-fixer.sh.j2 dest=/usr/local/bin/ckan-connector-fixer owner=root group=root mode=0550 - name: Fix the CKAN connector web.xml - become: False + become_user: root shell: /usr/local/bin/ckan-connector-fixer init args: creates: '{{ smartgears_instance_path }}/webapps/ckan-connector/WEB-INF/.web.xml.configured'