- name: download {{ software_gateway_gar }}
  get_url: url={{ software_gateway_url }} dest=/tmp force=yes

- name: deploy {{ software_gateway_gar  }}
  shell: export GLOBUS_LOCATION={{ globus_location }} ANT_HOME={{ ant_location }} && {{ globus_location }}/bin/gcore-deploy-service /tmp/{{ software_gateway_gar }}

- name: add GLOBUS_OPTIONS to the gcore startup script
  lineinfile: dest="{{ globus_location }}/gcore-start.sh" insertbefore="^nohup" state=present line='export GLOBUS_OPTIONS="-Xms512M -Xmx1024M"'

- name: copy updated GHNConfig.xml
  template: src=GHNConfig.xml dest={{ globus_location }}/config/

- name: copy settings.xml as per "https://gcube.wiki.gcube-system.org/gcube/Talk:Creating_gCube_Maven_components:_How-To#Repositories"
  copy: src=settings.xml dest={{ globus_location }}/etc/{{ software_gateway_artifact }}/

- name: set logicalhost parameter on {{ globus_location }}/etc/globus_wsrf_core/server-config.wsdd
  replace: dest="{{ globus_location }}/etc/globus_wsrf_core/server-config.wsdd" regexp='localhost' replace="{{ software_gateway_hostname }}"

- name: restore ownership
  file: dest={{ globus_location }} owner={{ ghn_user }}  group={{ ghn_user }} recurse=yes

- name: start gCore
  become: yes
  become_user: "{{ ghn_user }}"
  shell: "{{ globus_location }}/gcore-start.sh"