IAC - Infrastructure as Code

IAC - Infrastructure as code: 

Write and execute code to define, deply and update your infrastructure, including servers, databases, networks, log files, application configuration, documentation, automated tests, deployment processes, and so on.

Four categories of IAC tools: 

Ad hoc scripts:

scripts that will convert manual process into automation by breaking it down into discrete steps using scripting languages such as Bash, Ruby, Python or PowerShell. 

Adhoc scripts are designed to run on a single machine.  There are ways to run them for remote machine but it gets very complicated. 

Running an adhoc script is easy job and will produce expected results, however running the same script multiple times may cause errors. For example, if adhoc script create a folder, then next time, we need to check if folder already exist or not. Another example is running/starting an app or DB.  We may need to add multiple if then statements to check remote state before implementing desire state. 

The code/script that works correctly no matter how many times you run it is called idempotent code. Config tools used by configuration management tools such as Ansible are idempotent code.  

Configuration Management Tools:

Chef, Puppet, Ansible and SaltStack are all configuration management tools. The are designed to install and manage software on existing servers. For example, Ansible use YAML files for playbook. 

Ansible enforce a consistent, predictable structure including documentation, file layout, clearly named parameters, secret management and so on. It can managed large number of remote servers. 

Server Templating Tools:

 An alternative to configuration mangement that has been growing in popularity recently are server templating tools such as Docker, Packer and Vagrant.  Instant of launching a bunch of servers and configuring them by running the same code on each one, the idea behind server templating tools is to create an image of a server that captures a fully self-contained "snapshot" of the operating system, the software, the files, and all other relevant detail.  You can then use some other iAC tool to install that image on all of your servers. 

Packer:  Packer is typically used to create images that you run directly on top of production servers. 

Vagrant: Vagrant is typically used to create images that you run on your development computers.  

Docker: Docker is typically used to create images of individual applications. You can run the Docker Images on production or development computers.  (Docker Engine is needed). 

Server templating is a key component of the shift to immutable infrastructure.  Once you have deployed a server, you never makes changes to it again. If you need to update something such as deploy a new version of your code, you create a new image from your server template and you deploy it on a new servers.   

Server Provisioning Tools:

 

Ref:  Terraform up and Running by Yevgeniy Brikman

 

Add comment


Security code
Refresh

Category: