diff --git a/smartgears/r_connector/files/check_ldap_users b/smartgears/r_connector/files/check_ldap_users new file mode 100644 index 00000000..d10ccd3a --- /dev/null +++ b/smartgears/r_connector/files/check_ldap_users @@ -0,0 +1,23 @@ +#!/bin/bash + +NSCD_SERVICE="nscd" +NSLCD_SERVICE="nslcd" +SERVICE_CMD="/usr/sbin/service" + +RETVAL= + +CHECK_USER=$( id pasquale.pagano ) +RETVAL=$? + +restart_ns_services() { + $SERVICE_CMD $NSCD_SERVICE restart > /dev/null 2>&1 + $SERVICE_CMD $NSLCD_SERVICE restart > /dev/null 2>&1 + logger "check_ldap_users: Restarted the $NSCD_SERVICE and $NSLCD_SERVICE services." +} + +if [ $RETVAL -ne 0 ] ; then + logger "check_ldap_users: The ldap connection is broken" + restart_ns_services +fi + +exit 0 diff --git a/smartgears/r_connector/tasks/main.yml b/smartgears/r_connector/tasks/main.yml index 474cff4b..e5e6d63b 100644 --- a/smartgears/r_connector/tasks/main.yml +++ b/smartgears/r_connector/tasks/main.yml @@ -123,6 +123,14 @@ - Restart the NSCD service tags: [ 'smartgears', 'r_connector', 'tomcat', 'r_connector_nslcd_conf' ] + - name: Install a script that checks if the ldap authentication is working, and if not it restarts the ns(l)cd daemons + copy: src=check_ldap_users dest=/usr/local/bin/check_ldap_users owner=root group=root mode=0555 + tags: [ 'smartgears', 'r_connector', 'tomcat', 'r_connector_check_ldap' ] + + - name: Add a cron job that runs the ldap users check script + cron: name="check ldap users" job="/usr/local/bin/check_ldap_users" state=present user=root + tags: [ 'smartgears', 'r_connector', 'tomcat', 'r_connector_check_ldap' ] + when: - r_connector_install - r_connector_ldap_enabled