{"id":1658,"date":"2010-07-29T10:04:07","date_gmt":"2010-07-29T09:04:07","guid":{"rendered":"http:\/\/www.devco.net\/?p=1658"},"modified":"2010-08-07T18:25:27","modified_gmt":"2010-08-07T17:25:27","slug":"making_machine_meta_data_visible","status":"publish","type":"post","link":"https:\/\/www.devco.net\/archives\/2010\/07\/29\/making_machine_meta_data_visible.php","title":{"rendered":"Making machine metadata visible"},"content":{"rendered":"
I’m quite the fan of data, metadata and querying these to interact with my infrastructure rather than interacting by hostnames and wanted to show how far I am down this route. <\/p>\n
This is more an iterative ongoing process than a fully baked idea at this point since the concept of hostnames is so heavily embedded in our Sysadmin culture. Today I can’t yet fully break away from it due to tools like nagios etc still relying heavily on the hostname as the index but these are things that will improve in time.<\/p>\n
The background is that in the old days we attempted to capture a lot of metadata in hostnames, domain names and so forth. This was kind of OK since we had static networks with relatively small amounts of hosts. Today we do ever more complex work on our servers and we have more and more servers. The advent of cloud computing has also brought with it a whole new pain of unpredictable hostnames, rapidly changing infrastructures a much bigger emphasis on role based computing.<\/p>\n
My metadata about my machines comes from 3 main sources:<\/p>\n
When setting up machines I keep some data like database master hostnames in extlookup but in many cases I am now moving to a search based approach to finding resources. Here’s a sample manifest that will find the master database for a customers development machines:<\/p>\n
<\/code><\/p>\n This is MongoDB query against my infrastructure database, it will find for a given node the name of a node that has the class mysql::master<\/em> on it, by convention there should be only one per customer in my case. When using it in a template I can get back full objects with all the meta data for a node. Hopefully with Puppet 2.6 I can get full hashes into puppet too!<\/p>\n With machines doing a lot of work, filling a lot of roles etc and with more and more machines you need to be able to tell immediately what machine you are on.<\/p>\n I do this in several places, first my MOTD can look something like this:<\/p>\n<\/p>\n
\r\n$masterdb = search_nodes(\"{'facts.customer': '${customer}', 'facts.environment':${environment}, classes: 'mysql::master'}\")\r\n<\/pre>\n
Making Metadata Visible<\/h2>\n