rsinfo - keeping hosts and ssh config files accurate in a virtual server environment

At &yet we primarily use Rackspace for our servers and it is very handy to be able to create/destroy servers from the command line.

It is so handy that often I will find that i’ve created two or three servers without updating my hosts or ~/.ssh/config file which then makes me have to go look up the info and make the change manually. Another issue is with some of the automation scripts, i’m having to keep a hosts.json file updated so the tools know IP addresses and the like.

This is doable when you have servers that number in the low single digits, but it quickly gets out of hand. It is also for folks who are not using any of the larger and more formal, configuration management tools.

The solution, why automation of course ;)

rsinfo.py uses Rackspace's pyrax Python library to do all of the heavy lifting and then gathers up the appropriate information and writes out files.

Generate a /etc/hosts file

''' python rsinfo.py —datacenter DFW hosts '''

will scan the list of servers in the DFW datacenter and add this to your /etc/hosts file

'''

auto-generated for rsinfo

192.168.1.1 server1

auto-generated for rsinfo

'''

The tool has options for server info, ssh config and some other features. I’ll be adding to it as I go along.

You can find it on GitHub and please do let me know if it helps or if there is something you would like to see it do.


Mentions