Recently I was working on a project that was using RightScale to manage RackSpace cloud nodes. One of the requirements of the project was to have application nodes scale automatically thus they were required to automatically install software, configure settings, and start services automatically on the RackSpace CentOS nodes being used. Most everything was fairly straight forward however some of the services we were using would not start properly and initially because of the lack of logging from the services we were unable to figure out what the problem was. Below I describe the problem in more detail along with the solution which involved updating a configuration file on the CentOS Linux servers and then restarting the services.
How To Restart Services On CentOS Linux Nodes Managed By RightScale:
The services we were attempting to start using RightScripts only provided the output of “failed” when digging through the log files in an attempt to locate the issue. After walking through the service restart scripts I realized that the service required sudo access to be able to start the service as a specific user and while RightScale allows sudo access the way that it logs into the servers to download files, configure stuff, and start services it does not have a TTY. Some time ago the sudoers configuration file was modified to not allow sudo access to users that did not have TTY access so in this case to make the service restart scripts work properly I simply commented out the sudoers file configuration line that requires a TTY to access sudo. The below RightScript is an example of how you could modify the /etc/sudoers configuration file and then start the services that require sudo access to work properly.
Example RightScript For Linux Services That Require sudo Access:
#!/bin/bash -e # # modify sudoers file to allow sudo without a tty /bin/sed -ie "s/Defaults requiretty/#Defaults requiretty/g" /etc/sudoers # Cleanspeak CMS Service Restart /sbin/service webservice restart /sbin/service search-engine restart /sbin/service management-interface restart
Above we use restart for the services just in case they are already running for one reason or another. Also note that you can add code around the commands issued in this script to check for to see if this is a reboot of a RightScale managed node, etc. so some of the commands can be skipped if they are not necessary such as modifying the sudoers configuration file on reboot since this has already been accomplished at boot. This example RightScript to be run at boot for a specific ServerTemplate was used on RackSpace CentOS Linux cloud nodes managed by RightScale.