After my last post, I received several questions about how one could get started with infrastructure as code. While I can’t provide a thorough step-by-step guide that will cover all possible situations and nuances, I thought I’d post a very brief generic outline.
The end goal of infrastructure as code is to perform as many infrastructure tasks as possible programmatically. Key word is "automation."
To accomplish this goal, you will most likely first focus on two major areas - monitoring and deployment (when in doubt whether to focus on monitoring or deployment first, I recommend monitoring).
All levels below indicate a given activity is performed programmatically. Essentially, you should read each level as “to complete this level, I must be able to do this programmatically.” Just as in a computer game, you will want to move up from level to level for each individual piece of infrastructure that you have.
Several words on terminology. Whenever I say “infrastructure” below, I mean your systems, applications, services and data. Whenever I say “store” below, I mean store the information and be able to query, search and filter it programmatically.
Level 1 - Obtain runtime information about your infrastructure
Level 2 - Store historical runtime information somewhere (when in doubt, I recommend Graphite)
Level 3 - Generate mashup metrics and store them (by mashup metric I mean a metric that is not directly observable but one that is generated from various direct observations or other mashup metrics, potentially over a period of time)
Level 4 - Detect, generate and store events (points in time when something significant happened)
Level 5 - Generate alarms (notifications about particularly important series of events, meant to be analyzed by humans, usually in near real-time)
Level 6 - Detect, generate and store complex events (events that comprise events from different parts of your infrastructure)
Level 7 - Predict events (this is the highest level in monitoring; ability to predict the future requires level 6 plus ability to establish causality in addition to correlation plus potentially some amount of statistics)
Level 1 - Deploy a machine (reminder - need to do it programmatically)
Level 2 - Install OS on a machine (in IaaS, levels 1 and 2 are combined)
Level 3 - Machine boots up with network access and naming services (DNS) configured, network security enabled, user accounts can login
Level 5 - Applications are automatically added to correct resource pools and automatically start responding to real requests
Once you achieve high levels in monitoring and deployment (not necessarily highest though), you can start doing things like self-healing, autoscale, testing through fault injection and other cool things that are also parts of infrastructure as code but go beyond the scope of this blog post.