I think every sysadmin can relate to this, you’re in the kitchen getting a cup of coffee and your boss happens to walk in. You spend a couple of minutes having small talk but as soon as you’re done he drops the bomb. “Hey, could you send me a list of all the servers we have in our datacenter? Finance wants a list for insurance purposes, but I have an old copy … think you could update it and get it to me by the end of the day?” If you’re on top of your game you probably have it in a wiki or a fancy excel spreadsheet with bright color coded cells. Nope, not I, I totally forgot to add the last 20 servers I provisioned. I moved on to the next task, and that spreadsheet he was referring to has a timestamp that’s two months old.
Honestly, we’ve tried using both methods but it quickly gets outdated. Lack of time, lack of interest, you name it and our list includes servers that are no longer in production. It wouldn’t be an issue if we have 20 servers but our lab has over 80 hosts, both physical and virtual machines. Maintaining a list could get out of hand if our spreadsheet (or wiki) isn’t updated routinely when a new host is added or remove from our lab. The next time my boss asks me for an updated inventory list, I’ll send him the URL to our newly built dashboard. Here’s how I made it happen …
Gremlins, I found a family of gremlins who wanted to work as long as I didn’t call the exterminator on them. Nah, seriously I decided to re-do our Puppet environment in order to take advantage of “stored configuration.” With stored configuration, Puppet is able to save data into a database of your choice (SQLite, PostgreSQL or MySQL). “Inventory-ing” the server is possible by using a Ruby library called “Facter.” Since Facter is required by Puppet, I decided to take advantage of the information it obtains from the host after each run. Facter returns valuable information such as hostname, amount of memory, IP address and whether the host is a virtual or physical. All of this information and then some is stored inside a MySQL database.
Ok, so Puppet/Facter does the heavy lifting but how do I get this into a spreadsheet? I dont, I hate spreadsheets and I refuse to update cells and play with columns and rows. Instead, I used my PHP skills and created a customize dashboard that displays everything from hostname, IP, memory usage and rack location. If a server received an additional 2G of RAM, Puppet will update the value the next time it’s scheduled to run. It’s a win-win situation for everyone, I no longer have to worry about updating a wiki page and my boss doesn’t have to nag me for an updated list.