forked from ISTI-ansible-roles/ansible-roles
smartgears get-scopes: try to manage all the scenarios correctly.
This commit is contained in:
parent
72c260b3b4
commit
2d909ff031
|
@ -119,7 +119,6 @@
|
|||
become_user: '{{ smartgears_user }}'
|
||||
shell: /usr/local/bin/get-scopes {{ gcube_admin_token | default('') }}
|
||||
when: gcube_admin_token is defined or smartgears_upgrade
|
||||
ignore_errors: True
|
||||
notify: Restart smartgears
|
||||
tags: [ 'smartgears', 'smartgears_conf', 'tomcat' ]
|
||||
|
||||
|
|
|
@ -8,33 +8,39 @@ LOCAL_ETC=/usr/local/etc
|
|||
LOG_PREFIX="get-scopes: "
|
||||
GHN_ENV_FILE=/etc/default/tomcat-instance-{{ item.http_port }}.local
|
||||
SMARTGEARS_VO_AUTH={{ smartgears_authorized_on_all_scopes }}
|
||||
SMARTGEARS_UPGRADE={{ smartgears_upgrade }}
|
||||
SMARTGEARS_SAVED_STATE_F=saved_scopes_list.xml
|
||||
SMARTGEARS_SAVED_STATE_PATH={{ smartgears_user_home }}/SmartGears/$SMARTGEARS_SAVED_STATE_F
|
||||
SMARTGEARS_SCRIPTS_DIR={{ smartgears_user_home }}/SmartGears/scripts
|
||||
|
||||
SMARTGEARS_RUNNING_STATE_FILE={{ smartgears_user_home }}/state/ghn.xml
|
||||
|
||||
CONTAINER_XML_FILE={{ smartgears_install_path }}/container.xml
|
||||
|
||||
# 0: True, 1: False
|
||||
USE_SAVED_STATE=1
|
||||
|
||||
TOKEN=
|
||||
RETVAL=
|
||||
|
||||
# Scenario:
|
||||
# - First installation, no upgrade.
|
||||
# - The node must run on all VOs
|
||||
# In these cases we use our scopes list
|
||||
|
||||
if [ "$SMARTGEARS_VO_AUTH" == 'false' ] ; then
|
||||
if [ "$SMARTGEARS_UPGRADE" == 'True' ] ; then
|
||||
if [ $# -eq 0 ] ; then
|
||||
if [ -f $SMARTGEARS_RUNNING_STATE_FILE ] ; then
|
||||
if [ "$SMARTGEARS_VO_AUTH" == 'true' ] ; then
|
||||
# - The node must run on all VOs
|
||||
logger "$LOG_PREFIX When the node must run on all the VOs a valid token is mandatory, aborting"
|
||||
exit 1
|
||||
fi
|
||||
USE_SAVED_STATE=0
|
||||
logger "$LOG_PREFIX setting the correct variables so that we are going to use the local scopes"
|
||||
echo "No token, assuming that we can use the local state"
|
||||
logger "$LOG_PREFIX No token, assuming that we can use the local state"
|
||||
else
|
||||
logger "$LOG_PREFIX We are going to use our scopes list. A valid token is mandatory"
|
||||
# - First installation, no upgrade.
|
||||
logger "$LOG_PREFIX No token was passed and not working state available, aborting"
|
||||
exit 1
|
||||
fi
|
||||
elif [ $# -eq 1 ] ; then
|
||||
logger "$LOG_PREFIX We have an authorization token"
|
||||
TOKEN=$1
|
||||
else
|
||||
logger "$LOG_PREFIX We are going to use our scopes list. A valid token is mandatory"
|
||||
logger "$LOG_PREFIX More than one parameter was passed, aborting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SCOPES_LIST=""
|
||||
|
@ -45,16 +51,6 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ $# -ne 1 -a $USE_SAVED_STATE -ne 0 ] ; then
|
||||
echo "The token must be passed as the sole argument when we are not using the local state"
|
||||
logger "$LOG_PREFIX The token must be passed as the sole argument when we are not using the local state"
|
||||
exit 1
|
||||
elif [ $# -eq 1 ] ; then
|
||||
logger "$LOG_PREFIX We have an authorization token"
|
||||
TOKEN=$1
|
||||
fi
|
||||
|
||||
{%if setup_nginx %}
|
||||
HTTP_PORT={{ http_port }}
|
||||
{% else %}
|
||||
|
@ -94,13 +90,12 @@ cd $SMARTGEARS_SCRIPTS_DIR
|
|||
./clean-container-state -s $SMARTGEARS_SAVED_STATE_F
|
||||
RETVAL=$?
|
||||
if [ $RETVAL -ne 0 ] ; then
|
||||
# We were not able to get the running state from the IS. We get new ones
|
||||
logger "$LOG_PREFIX We were not able to get the running state from the IS. We get new ones from the authorization service"
|
||||
# We were not able to get the running state from the IS. Try to get new scope tokens
|
||||
logger "$LOG_PREFIX We were not able to get the running state from the IS. Try to get new scope tokens from the authorization service"
|
||||
SCOPES_FILE={{ smartgears_user_home }}/.containerxml/2-container.xml
|
||||
get_scopes_from_auth
|
||||
fi
|
||||
|
||||
|
||||
# Now that we have the tokens, we can assemble the container.xml file
|
||||
chmod 640 $CONTAINER_XML_FILE
|
||||
CREATE_CONTAINER_XML_RES=0
|
||||
|
|
Loading…
Reference in New Issue