From c787b44fc4cdeff174b28c827204ed6c2fa8213b Mon Sep 17 00:00:00 2001 From: Roberto Cirillo Date: Fri, 8 Jul 2016 17:23:49 +0200 Subject: [PATCH] ../library/roles/smartgears/smartgears/tasks/smartgears-app.yml fix change loglevel --- smartgears/smartgears/tasks/smartgears-app.yml | 8 ++++++-- .../templates/change-logback-loglevel.sh.j2 | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 smartgears/smartgears/templates/change-logback-loglevel.sh.j2 diff --git a/smartgears/smartgears/tasks/smartgears-app.yml b/smartgears/smartgears/tasks/smartgears-app.yml index 9d463285..aa0184fd 100644 --- a/smartgears/smartgears/tasks/smartgears-app.yml +++ b/smartgears/smartgears/tasks/smartgears-app.yml @@ -61,11 +61,15 @@ notify: Restart smartgears tags: [ 'smartgears', 'smartgears_conf', 'tomcat' ] +- name: Install the script that manages the smartgears loglevel + template: src=change-logback-loglevel.sh.j2 dest=/usr/local/bin/change-logback-loglevel owner=root group=root mode=0755 + with_items: '{{ tomcat_m_instances }}' + tags: [ 'smartgears', 'smartgears_loglevel', 'tomcat' ] + - name: Change the smartgears log level become: True become_user: '{{ d4science_user }}' - shell: LOGLEVEL=$( xmlstarlet sel -t -v "/configuration/logger/@level" {{ item.user_home }}/tomcat/lib/logback.xml | grep {{ smartgears_loglevel }} ) ; [ $? -ne 0 ] && xmlstarlet ed -u "/configuration/logger[@level]/@level" -v {{ smartgears_loglevel }} {{ item.user_home }}/tomcat/lib/logback.xml > {{ item.user_home }}/tomcat/lib/logback.xml.new ; [ -f {{ item.user_home }}/tomcat/lib/logback.xml.new ] && mv {{ item.user_home }}/tomcat/lib/logback.xml.new {{ item.user_home }}/tomcat/lib/logback.xml - with_items: '{{ tomcat_m_instances }}' + shell: /usr/local/bin/change-logback-loglevel notify: Restart smartgears tags: [ 'smartgears', 'tomcat', 'smartgears_loglevel' ] diff --git a/smartgears/smartgears/templates/change-logback-loglevel.sh.j2 b/smartgears/smartgears/templates/change-logback-loglevel.sh.j2 new file mode 100644 index 00000000..2ddebe2c --- /dev/null +++ b/smartgears/smartgears/templates/change-logback-loglevel.sh.j2 @@ -0,0 +1,13 @@ +#!/bin/bash + +RETVAL= +LOGLEVEL=$( xmlstarlet sel -t -v "/configuration/logger/@level" {{ item.user_home }}/tomcat/lib/logback.xml | grep {{ smartgears_loglevel }} ) +RETVAL=$? + +if [ $RETVAL -ne 0 ] ; then + xmlstarlet ed -u "/configuration/logger[@level]/@level" -v {{ smartgears_loglevel }} {{ item.user_home }}/tomcat/lib/logback.xml > {{ item.user_home }}/tomcat/lib/logback.xml.new + /bin/mv {{ item.user_home }}/tomcat/lib/logback.xml.new {{ item.user_home }}/tomcat/lib/logback.xml +fi + +exit 0 +