From 882d486451e201704f3d8eb7f0c9c43937d41418 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Thu, 19 Oct 2017 18:06:33 +0200 Subject: [PATCH] resource_registry: refactor to make a better use of resource_registry. --- smartgears/resource_registry/tasks/main.yml | 29 +++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/smartgears/resource_registry/tasks/main.yml b/smartgears/resource_registry/tasks/main.yml index f8e6ead4..5cd7bf62 100644 --- a/smartgears/resource_registry/tasks/main.yml +++ b/smartgears/resource_registry/tasks/main.yml @@ -1,17 +1,36 @@ --- - block: - name: Remove the old resource-registry files - file: path={{ smartgears_instance_path }}/webapps/{{ resource_registry_name }} state=absent + file: path={{ item }} state=absent + with_items: + - '{{ smartgears_instance_path }}/webapps/{{ resource_registry_name }}' + - '{{ smartgears_instance_path }}/webapps/{{ resource_registry_name }}.{{ resource_registry_extension }}' when: resource_registry_upgrade + become: True + become_user: '{{ d4science_user }}' + tags: [ 'smartgears', 'resource_registry', 'tomcat' ] + when: not resource_registry_install + +- block: + - name: Get the resource_registry war + maven_artifact: artifact_id={{ resource_registry_name }} version={{ resource_registry_version | default('latest') }} group_id={{ resource_registry_group_id }} extension={{ resource_registry_extension | default('war') }} repository_url={{ smartgears_global_base_url }} dest={{ smartgears_downloads_directory }}/{{ resource_registry_file }} + register: resource_registry_download + + - name: Remove the old resource-registry files + file: path={{ smartgears_instance_path }}/webapps/{{ resource_registry_name }} state=absent + when: ( resource_registry_download | changed ) + - name: Create the resource-registry working directory file: path={{ smartgears_instance_path }}/webapps/{{ resource_registry_name }} state=directory owner={{ smartgears_user }} group={{ smartgears_user }} - - - name: Get the resource_registry war - maven_artifact: artifact_id={{ resource_registry_name }} version={{ resource_registry_version | default('latest') }} group_id={{ resource_registry_group_id }} extension={{ resource_registry_extension | default('war') }} repository_url={{ smartgears_global_base_url }} dest={{ smartgears_user_home }}/{{ resource_registry_file }} + when: ( resource_registry_download | changed ) + + - name: Copy the resource registry war file into the webapps directory + copy: src={{ smartgears_downloads_dir }}/{{ resource_registry_file }} dest={{ smartgears_instance_path }}/webapps/{{ resource_registry_name }}.{{ resource_registry_extension }} remote_src=yes force=yes + notify: Restart smartgears - name: Unarchive the resource registry war - unarchive: copy=no src={{ smartgears_user_home }}/{{ resource_registry_file }} dest={{ smartgears_instance_path }}/webapps/{{ resource_registry_name }} creates={{ smartgears_instance_path }}/webapps/{{ resource_registry_name }}/WEB-INF/lib + unarchive: copy=no src={{ smartgears_downloads_dir }}/{{ resource_registry_file }} dest={{ smartgears_instance_path }}/webapps/{{ resource_registry_name }} creates={{ smartgears_instance_path }}/webapps/{{ resource_registry_name }}/WEB-INF/lib notify: Restart smartgears - name: Install the resource registry configuration