From b5e2f43bd78db469db9cc7686b12d478c3dd8653 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 27 Sep 2016 18:06:31 +0200 Subject: [PATCH] library/roles/smartgears/smart_executor: Fix the upgrade scenario. library/roles/smartgears/smartgears: Fix the new token management. d4science-ghn-cluster/group_vars/smart_genericworker_dev_devnext: The new token management needs a different scopes handling. And a new variable: smartgears_scopes. --- smartgears/smart_executor/defaults/main.yml | 1 + smartgears/smart_executor/tasks/main.yml | 15 ++++++++------- smartgears/smartgears/defaults/main.yml | 3 +++ smartgears/smartgears/tasks/smartgears-app.yml | 8 +++++--- smartgears/smartgears/templates/get-scopes.j2 | 6 +++++- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/smartgears/smart_executor/defaults/main.yml b/smartgears/smart_executor/defaults/main.yml index fccdbbcd..12fff038 100644 --- a/smartgears/smart_executor/defaults/main.yml +++ b/smartgears/smart_executor/defaults/main.yml @@ -1,5 +1,6 @@ --- smart_executor_install: False +remove_smart_executor_install: False smart_executor_version: 1.3.0-4.0.0-128844 smart_executor_name: smart-executor diff --git a/smartgears/smart_executor/tasks/main.yml b/smartgears/smart_executor/tasks/main.yml index 99d359aa..9611f579 100644 --- a/smartgears/smart_executor/tasks/main.yml +++ b/smartgears/smart_executor/tasks/main.yml @@ -1,24 +1,25 @@ --- - block: - - - name: Remove the old smart executor files + - name: Remove the old smart executor files if an upgrade is planned file: path={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }} state=absent - when: ( not smart_executor_install ) or ( smartgears_upgrade ) + when: smartgears_upgrade + + - name: Remove the smart executor files if we want to remove it + file: path={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }} state=absent + when: not smart_executor_install # NOTE: Install as the smartgears user so we do not mess with the permissions - name: Get the smart executor plugin get_url: url={{ smart_executor_url }} dest={{ smartgears_user_home }}/{{ smart_executor_file }} - when: smart_executor_install - name: Create the smart executor working directory file: path={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }} state=directory owner={{ smartgears_user }} group={{ smartgears_user }} - when: smart_executor_install - name: Unarchive the smartexecutor distribution unarchive: copy=no src={{ smartgears_user_home }}/{{ smart_executor_file }} dest={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }} creates={{ smartgears_instance_path }}/webapps/{{ smart_executor_name }}/WEB-INF/lib - when: smart_executor_install notify: Restart smartgears become: True - become_user: '{{ d4science_user }}' + become_user: '{{ smartgears_user }}' + when: smart_executor_install tags: [ 'smartgears', 'smart_executor', 'tomcat' ] diff --git a/smartgears/smartgears/defaults/main.yml b/smartgears/smartgears/defaults/main.yml index 36ccb2f2..34625d8b 100644 --- a/smartgears/smartgears/defaults/main.yml +++ b/smartgears/smartgears/defaults/main.yml @@ -47,6 +47,9 @@ smartgears_context: - '/BiOnym' - '/ScalableDataMining' +smartgears_scopes: + - '{{ smartgears_infrastructure_name }}' + # The iptables rules use this http_port: '{{ smartgears_http_port }}' diff --git a/smartgears/smartgears/tasks/smartgears-app.yml b/smartgears/smartgears/tasks/smartgears-app.yml index ec0eb05a..5b252160 100644 --- a/smartgears/smartgears/tasks/smartgears-app.yml +++ b/smartgears/smartgears/tasks/smartgears-app.yml @@ -50,11 +50,13 @@ - name: Create the directory where we put the smartgears configuration snippets become: True become_user: '{{ smartgears_user }}' - file: dest={{ smartgears_user_home }}/.containerxml + file: dest={{ smartgears_user_home }}/.containerxml state=directory tags: [ 'smartgears', 'smartgears_conf', 'tomcat' ] - name: Install the token generator class - file: src=TokenGeneartor.class dest=/usr/local/lib/TokenGenerator.class owner=root group=root mode=0644 + copy: src=TokenGenerator.class dest=/usr/local/lib/TokenGenerator.class owner=root group=root mode=0644 + when: gcube_admin_token is defined + tags: [ 'smartgears', 'smartgears_conf', 'tomcat' ] - name: Install the script that fetches the scope tokens template: src=get-scopes.j2 dest=/usr/local/bin/get-scopes owner=root group={{ smartgears_user }} mode=0750 @@ -64,7 +66,7 @@ - name: Get the scope tokens from the authorization service become: True become_user: '{{ smartgears_user }}' - shell: + shell: /usr/local/bin/get-scopes when: gcube_admin_token is defined tags: [ 'smartgears', 'smartgears_conf', 'tomcat' ] diff --git a/smartgears/smartgears/templates/get-scopes.j2 b/smartgears/smartgears/templates/get-scopes.j2 index cd149d2a..463ee8e7 100644 --- a/smartgears/smartgears/templates/get-scopes.j2 +++ b/smartgears/smartgears/templates/get-scopes.j2 @@ -13,7 +13,11 @@ HTTP_PORT={{ http_port }} HTTP_PORT={{ item.http_port }} {% endif %} -export CLASSPATH="/usr/local/lib:{{ smartgears_install_path }}/lib:$CLASSPATH" +for jar in $( ls -1 /home/gcube/tomcat/lib/ ) ; do + export CLASSPATH="/home/gcube/SmartGears/lib/${jar}:$CLASSPATH" +done + +cd /usr/local/lib java TokenGenerator {{ gcube_admin_token }} {{ smartgears_hostname }} $HTTP_PORT $DESTFILE {% for scope in smartgears_scopes %}{{ scope }} {% endfor %}