From e175b90a3e17256efd4a1ea560b4822152a3bb1c Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 7 Feb 2017 17:04:08 +0100 Subject: [PATCH] library/roles/smartgears/smartgears_egi_image: Configure the dataminer's wps_config.xml too. library/roles/smartgears/dataminer_app/templates/wps-config-fixer.j2: Use smartgears_hostname so that we can change it later when configuring the EGI images. --- .../templates/wps-config-fixer.j2 | 2 +- .../templates/smartgears-setup.sh.j2 | 24 +++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/smartgears/dataminer_app/templates/wps-config-fixer.j2 b/smartgears/dataminer_app/templates/wps-config-fixer.j2 index d0d4a00f..dabfaaea 100644 --- a/smartgears/dataminer_app/templates/wps-config-fixer.j2 +++ b/smartgears/dataminer_app/templates/wps-config-fixer.j2 @@ -4,7 +4,7 @@ WPS_CONFIG_FILE='{{ smartgears_instance_path }}/webapps/{{ dataminer_52north_webapp_name }}/config/wps_config.xml' # Fix the hostname -sed -Ei 's/hostname=\".*\"\ hostport/hostname="{{ ansible_fqdn }}" hostport/' $WPS_CONFIG_FILE +sed -Ei 's/hostname=\".*\"\ hostport/hostname="{{ smartgears_hostname }}" hostport/' $WPS_CONFIG_FILE # Fix the port {%if setup_nginx %} diff --git a/smartgears/smartgears_egi_image/templates/smartgears-setup.sh.j2 b/smartgears/smartgears_egi_image/templates/smartgears-setup.sh.j2 index 701e8413..6505f224 100755 --- a/smartgears/smartgears_egi_image/templates/smartgears-setup.sh.j2 +++ b/smartgears/smartgears_egi_image/templates/smartgears-setup.sh.j2 @@ -23,6 +23,9 @@ CLOUD_INSTANCE_DIR=/var/lib/cloud/instance MEM=$( free -m | egrep ^Mem | awk '{ print $2 }' ) JAVA_MAX_HEAP=$( expr $MEM - 2048 ) +# WPS configuration data +WPS_CONFIG_FIXER=/usr/local/bin/wps-config-fixer + # Init some variables that should be passed if [ -z "${SMARTGEARS_SCOPES}" ] ; then SMARTGEARS_SCOPES= @@ -71,15 +74,19 @@ function find_public_ip() { function modify_hosts_file() { echo "-- modify_hosts_file" >> $LOG_FILE - # Set the hosts file with the new data + # Set the hosts file with the new data. Set /etc/hostname too grep -v $HOST $HOSTS_FILE > $HOSTS_FILE.tmp if [ "${FQDN_HOST}" == "${HOST}" ] ; then FQDN_HOST=${HOST}.localhost fi - echo "${PUBLIC_IP} ${FQDN_HOST} ${PUB_FQDN_HOST} ${HOST}" >> $HOSTS_FILE.tmp + SHORT_HOSTNAME=$( echo ${PUB_FQDN_HOST} | cut -d . -f 1 - ) + echo "${PUBLIC_IP} ${FQDN_HOST} ${PUB_FQDN_HOST} ${SHORT_HOSTNAME} ${HOST}" >> $HOSTS_FILE.tmp mv $HOSTS_FILE.tmp $HOSTS_FILE chmod 644 $HOSTS_FILE chown root:root $HOSTS_FILE + if [ ! -z ${SHORT_HOSTNAME} ] ; then + echo "${SHORT_HOSTNAME}" > /etc/hostname + fi } function smartgears_config_parameters_check() { @@ -115,6 +122,18 @@ function populate_head_containerxml() { sed -i -e "s#@SMARTGEARS_LOCATION@#${LOCATION}#g" $SM_CONF_F } +function fix_wps_configuration() { + echo "-- fix_wps_configuration" >> $LOG_FILE + if [ -f $WPS_CONFIG_FIXER ] ; then + echo "This is a dataminer node" >> $LOG_FILE + sed -i -e "s#@SMARTGEARS_HOSTNAME@#${PUB_FQDN_HOST}#g" $WPS_CONFIG_FIXER + # Run the command to fix the dataminer configuration + $WPS_CONFIG_FIXER + else + echo "This is not a dataminer node, doing nothing here" >> $LOG_FILE + fi +} + {% endraw %} function set_scopes_list() { @@ -203,6 +222,7 @@ modify_hosts_file smartgears_config_parameters_check set_scopes_list populate_head_containerxml +fix_wps_configuration fix_get_scopes get_smartgears_scope_tokens merge_container_xml