The advantage of RightScale is it allows us to manage our servers at a further abstracted layer than AWS itself – through the use of “RightScripts” we can script our way through the managing of low level resources.
Things started to get a bit hairy when our scripts needed to talk to Drupal, in particular, registering each new server as it comes online with our Drupal stack, thereby whitelisting its IP address as trustworthy.
I did some googling and couldn’t find a good, efficient way to automate this, except for a post with a handy command.
With a little bit of tweaking, I arrived at a working solution that was even easier than thought.
First step is to prepare your settings.php or similar configuration file that holds your $conf for Drupal. We use IP address for a number of internal variables, but below are two Drupal specific variables used in ip_address():
'reverse_proxy' => true, 'reverse_proxy_addresses' => array( // load balancer IPs '220.127.116.11', // elastic ip address from AWS ),
The above code lives in our custom file that holds our Drupal $conf settings. We have a RightScript that copies this files to the proper location and after the file is copied over, I added this command:
sed -i "/load balancer IPs/ a\'$(hostname -i)'," db.inc
What this basically does is opens up our db.inc file which holds our Drupal $conf, it searches for that specific “@load balancer IPs@” string (see above code snippet for where it was defined), than it appends a new line, adding in the IP address of that machine. If you have multiple machines registering themselves, this works quite nicely, as they keep growing the list.
Hope this helps someone else from banging their head around for a few hours!