diff --git a/smartgears/sdi_service/defaults/main.yml b/smartgears/sdi_service/defaults/main.yml index cc4ce1f..1edb77c 100644 --- a/smartgears/sdi_service/defaults/main.yml +++ b/smartgears/sdi_service/defaults/main.yml @@ -1,7 +1,7 @@ --- sdi_service_install: False sdi_service_upgrade: False -sdi_service_version: 1.1.0-4.6.1-153203 +sdi_service_version: latest sdi_service_name: sdi-service sdi_group_id: org.gcube.spatial.data diff --git a/smartgears/sdi_service/tasks/main.yml b/smartgears/sdi_service/tasks/main.yml index a09f124..8723e1e 100644 --- a/smartgears/sdi_service/tasks/main.yml +++ b/smartgears/sdi_service/tasks/main.yml @@ -1,18 +1,27 @@ --- - block: - name: Remove the old sdi files - file: path={{ smartgears_instance_path }}/webapps/{{ sdi_service_name }} state=absent - when: sdi_service_upgrade + file: path={{ item }} state=absent + with_items: + - '{{ smartgears_instance_path }}/webapps/{{ sdi_service_name }}' + - '{{ smartgears_instance_path }}/webapps/{{ sdi_service_name }}.{{ sdi_extension }}' - # NOTE: Install as the smartgears user so we do not mess with the permissions + become: True + become_user: '{{ d4science_user }}' + when: not sdi_service_install + tags: [ 'smartgears', 'sdi_service', 'tomcat' ] + +- block: - name: Get the sdi-service - maven_artifact: artifact_id={{ sdi_service_name }} version={{ sdi_service_version | default(omit) }} group_id={{ sdi_group_id }} extension={{ sdi_extension | default('war') }} repository_url={{ smartgears_global_base_url }} dest={{ smartgears_user_home }}/{{ sdi_service_file }} + maven_artifact: artifact_id={{ sdi_service_name }} version={{ sdi_service_version | default('latest') }} group_id={{ sdi_group_id }} extension={{ sdi_extension | default('war') }} repository_url={{ smartgears_global_base_url }} dest={{ smartgears_downloads_dir }}/{{ sdi_service_file }} + register: sdi_service_download - - name: Create the sdi working directory - file: path={{ smartgears_instance_path }}/webapps/{{ sdi_service_name }} state=directory owner={{ smartgears_user }} group={{ smartgears_user }} - - - name: Unarchive the sdi war - unarchive: copy=no src={{ smartgears_user_home }}/{{ sdi_service_file }} dest={{ smartgears_instance_path }}/webapps/{{ sdi_service_name }} creates={{ smartgears_instance_path }}/webapps/{{ sdi_service_name }}/WEB-INF/lib + - name: Remove the old sdi files + file: path={{ smartgears_instance_path }}/webapps/{{ sdi_service_name }} state=absent + when: ( sdi_service_download | changed ) + + - name: Copy the sdi service war file into the webapps directory + copy: src={{ smartgears_downloads_dir }}/{{ sdi_service_file }} dest={{ smartgears_instance_path }}/webapps/{{ sdi_service_name }}.{{ sdi_extension }} remote_src=yes force=yes notify: Restart smartgears become: True @@ -20,11 +29,3 @@ when: sdi_service_install tags: [ 'smartgears', 'sdi_service', 'tomcat' ] -- block: - - name: Remove the old sdi files - file: path={{ smartgears_instance_path }}/webapps/{{ sdi_service_name }} state=absent - - become: True - become_user: '{{ d4science_user }}' - when: not sdi_service_install - tags: [ 'smartgears', 'sdi_service', 'tomcat' ]