---
- block:
    - name: Remove the old grsf-publisher-ws files
      file: path={{ smartgears_instance_path }}/webapps/{{ grsf_publisher_ws_name }} state=absent
      when: grsf_publisher_ws_upgrade

    - name: Create the grsf-publisher-ws working directory
      file: path={{ smartgears_instance_path }}/webapps/{{ grsf_publisher_ws_name }} state=directory owner={{ smartgears_user }} group={{ smartgears_user }}
  
    - name: Unarchive the grsf_publisher_ws war
      unarchive: copy=no src={{ grsf_publisher_ws_url }} dest={{ smartgears_instance_path }}/webapps/{{ grsf_publisher_ws_name }} creates={{ smartgears_instance_path }}/webapps/{{ grsf_publisher_ws_name }}/WEB-INF/lib
      notify: Restart smartgears

  become: True
  become_user: '{{ d4science_user }}'
  tags: [ 'smartgears', 'grsf_publisher_ws', 'tomcat' ]
  when: grsf_publisher_ws_install