From 55cdf9feb1562bcfb87a572c4d42adeca2bfcf61 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 4 Nov 2016 19:42:36 +0100 Subject: [PATCH] library/roles/smartgears/smartgears: Put the list of scopes into a separate file. --- smartgears/smartgears/tasks/smartgears-app.yml | 4 ++++ smartgears/smartgears/templates/get-scopes.j2 | 12 ++++++++++-- smartgears/smartgears/templates/scopes.list.j2 | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 smartgears/smartgears/templates/scopes.list.j2 diff --git a/smartgears/smartgears/tasks/smartgears-app.yml b/smartgears/smartgears/tasks/smartgears-app.yml index dbb1ae26..596deebd 100644 --- a/smartgears/smartgears/tasks/smartgears-app.yml +++ b/smartgears/smartgears/tasks/smartgears-app.yml @@ -58,6 +58,10 @@ with_items: '{{ tomcat_m_instances }}' tags: [ 'smartgears', 'smartgears_conf', 'tomcat' ] +- name: Install the file containing the scopes list + template: src=scopes.list.j2 dest=/usr/local/etc/scopes.list owner=root group={{ smartgears_user }} mode=0444 + tags: [ 'smartgears', 'smartgears_conf', 'tomcat' ] + - name: Get the scope tokens from the authorization service become: True become_user: '{{ smartgears_user }}' diff --git a/smartgears/smartgears/templates/get-scopes.j2 b/smartgears/smartgears/templates/get-scopes.j2 index b9ca8930..d2c297c0 100644 --- a/smartgears/smartgears/templates/get-scopes.j2 +++ b/smartgears/smartgears/templates/get-scopes.j2 @@ -1,6 +1,14 @@ #!/bin/bash DESTFILE={{ smartgears_user_home }}/.containerxml/2-container.xml +LOCAL_LIB=/usr/local/lib +LOCAL_ETC=/usr/local/etc + +SCOPES_LIST="" +if [ -f $LOCAL_ETC/scopes.list ] ; then + . $LOCAL_ETC/scopes.list +fi + if [ $# -ne 1 ] ; then echo "The token must be passed as the sole argument" @@ -28,8 +36,8 @@ for jar in $( ls -1 /home/gcube/tomcat/lib/ ) ; do export CLASSPATH="/home/gcube/SmartGears/lib/${jar}:$CLASSPATH" done -cd /usr/local/lib +cd $LOCAL_LIB -java TokenGenerator {{ smartgears_hostname }} $TOKEN $HTTP_PORT $DESTFILE {% for scope in smartgears_scopes %}{{ scope }} {% endfor %} +java TokenGenerator {{ smartgears_hostname }} $TOKEN $HTTP_PORT $DESTFILE $SCOPES_LIST exit 0 diff --git a/smartgears/smartgears/templates/scopes.list.j2 b/smartgears/smartgears/templates/scopes.list.j2 new file mode 100644 index 00000000..7ed4e0d7 --- /dev/null +++ b/smartgears/smartgears/templates/scopes.list.j2 @@ -0,0 +1 @@ +SCOPES_LIST="{% for scope in smartgears_scopes %}{{ scope }} {% endfor %}"