Infrastructure as Code
From idempotent playbooks and declared state to Terraform, Pulumi, Vagrant, testing, AWX and GitOps, infrastructure as code as told through the free samples of the Leanpub books about it.
Created from the free samples of 10 Leanpub books and the descriptions and tables of contents of 38 more, with every source cited.
Infrastructure as code is the practice of describing servers, networks and the software on them in text files that a tool carries out, instead of configuring each machine by hand. One of the library's books puts the essentials in a paragraph: the infrastructure is modelled in files, the files are committed to version control, and from there a complex environment can be built and changed in an organised way, where the manual alternative, a person clicking through a provider's dashboard, is prone to mistakes such as changing one environment and forgetting another.[8] Another states the ambition in a single sentence, written about networks and true of everything else: make the description of the system the thing that configures the system.[2]
The property that makes this safe is idempotence, the ability to run an operation once or many times with the same result. A shell script run twice often does damage; a configuration management tool applies the same configuration to a server again and again and changes nothing after the first time.[1] Around that idea two families of tool have grown: those that configure what is on a machine, of which Ansible dominates the library's shelf, and those that create the machines, networks and services themselves, such as Terraform, Pulumi and the cloud providers' own template languages.
This article follows the subject through its tools and then its practices: where to begin, the history, configuration management with Ansible, provisioning with Terraform and its rivals, local environments and whole-system approaches, testing and review, and pipelines, GitOps and platforms. Its sources are the free samples of the Leanpub books listed at the end, with the descriptions and tables of contents of the books whose samples were not available, and every claim that rests on a source is cited to it. The shelf is lopsided. About half of its books are on Ansible, one of them among the best-selling titles in the whole library, and the article is weighted accordingly.
Where to start
For Ansible the usual first book is Ansible for DevOps, written for developers and system administrators who are comfortable on the command line and manage anything from one server to thousands.[1] become Ansible (2020) is a shorter route that also covers bringing the tool into a team,[5] Automated Configuration Management using Ansible (2019) begins by building the practice machines themselves,[11] and DevOps For PHP Developers (2020) is for a developer who wants to stop setting up a web server by hand.[12] Network engineers have a book of their own, Ansible for Network Engineers, which assumes networking and nothing else, not Python, YAML, Git or what a playbook is.[2]
For provisioning, Terraform Quickstart: The Beginner's Guide to Infrastructure as Code (2026) teaches Terraform with free tools so that its exercises cost nothing to run;[35] Introduction to Terraform goes from first principles to pipelines in one short book;[34] and Modern Cloud Infrastructure-as-Code for Developers is addressed to application developers with little experience of the cloud.[8] Pulumi in action is the entry point for those who would rather write Python.[38] A developer who only wants a reproducible environment on a laptop should start with Vagrant CookBook (2017).[3]
Readers who already write infrastructure code are served by the books on doing it well: Test in Infrastructure as Code and Testing Ansible on testing,[6][7] Mastering Ansible Best Practices and Troubleshooting on lint rules and common errors,[33] AWX in Action on running automation for a whole organisation,[29] and Infrastructure as Code for Security Engineers, which teaches security staff to read and audit Terraform without learning to write it.[42]
History
System administrators managed servers by hand for as long as there were few of them. Virtualisation, and then the cloud, multiplied the number of machines one person was expected to look after, and tools that hold a description of the desired configuration and enforce it became the normal way to work. Declarative tools for creating infrastructure, as distinct from configuring it, followed in the 2010s, Terraform in 2014 among them, and the same decade produced the practice now called GitOps, in which a repository is the authority for what a cluster should be running.
The books tell the first half of this from the inside. As data centres grew, one recalls, administrators found they could not scale manual work as fast as the applications they supported; virtualisation raised the number of servers in one person's care by an order of magnitude, and in the largest environments provisioning, configuration and decommissioning are now fully automated. The same years brought developers and operators together under the name DevOps, which the book's foreword glosses as shortening the distance between those who write the code and those who run it, something a new team placed between the two does not achieve.[1] Configuration management as a field begins, in one account, with CFEngine in 1993, followed by Puppet and Chef, which aimed at completeness and configurability, and then by Ansible, which aimed at simplicity and a gentle learning curve.[4] Ansible was released in 2012 by Michael DeHaan, who had found organisations running one tool for configuration, another for deployment and a third for ad-hoc commands and wanted one that did all three; its company was founded the following year and bought by Red Hat in 2015.[1] The author of that account describes his own path, comfortable at the command line and never proficient in the earlier tools, which required some Ruby or a language of their own before anything could be done.[1] Another author built his own configuration management system first, found that maintaining it had become a full-time job, and joined the team that brought Ansible to his organisation instead.[5]
Configuration management with Ansible
Ansible describes the desired state of machines in YAML files called playbooks and applies them over SSH. It needs no agent on the machines it manages, which its advocates count as its chief distinction: nothing extra to install, no extra memory in use, no extra daemon to secure. Its stated aims are to be clear, with a syntax anyone in an organisation can read; fast to learn and set up; complete, covering configuration, deployment and ad-hoc commands in one package; efficient; and secure, since it opens no ports beyond SSH. Its only real dependency on the controlling machine is Python.[1] The foreword to Ansible for DevOps, by one of the company's founders, lists the uses the tool was meant for, enforcing declared state, deploying applications step by step, and orchestrating systems of many parts, and argues that a tool both developers and operators can read is one of the first steps towards their working together.[1]
Learning the tool
Ansible for DevOps opens with the problem Ansible replaces, the snowflake server configured by hand and by shell script over years, and proceeds through inventories and ad-hoc commands to playbooks, roles, dynamic inventories, deployments, security, testing and containers, teaching throughout with complete playbooks for real server setups, often run on local virtual machines.[1] become Ansible runs Ansible itself from a container, connects it to a cloud account, and ends with a release pipeline; it is distilled from one engineering team's experience of introducing the tool, whose aim was more stable and reliable environments and whose motive, the author says, was that the pain of staying the same had come to exceed the pain of changing;[5] DevOps For PHP Developers sets a web server up by hand and then rebuilds the same setup as a set of roles;[12] and The Ansible Workshop (2024) carries on to writing custom modules and filters.[13] Ansible Cookbook and Ansible Tips and Tricks are collections of practices and small everyday answers,[14][15] and The ProLUG Big Book of Labs, a book of Linux administration labs, closes with a part on inventories, playbooks, templates and roles.[16]
A second group, by one author, is organised as reference rather than narrative: one short lesson for each module or task, with its parameters and a playbook. Ansible by Examples has more than two hundred such lessons,[17] and the others narrow the same form to a platform or a job: Ansible For Linux by Examples,[18] Ansible For Windows By Examples,[19] Ansible For Security by Examples,[20] Ansible Linux Filesystem By Examples,[21] Ansible Linux Users & Groups By Examples[22] and Ansible For PostgreSQL by Examples.[23] Each opens with the same introduction and installation chapters, which make up a large share of the shorter volumes.
Clouds, clusters and networks
Ansible is also used to create infrastructure, not only to configure it. Ansible for AWS (2016) goes through Amazon's services one by one with the matching modules and builds first a single website and then a highly available one;[4] Manage AWS Resources Using Ansible (2019) pairs Ansible with a tool for building machine images;[24] and Ansible For Amazon Web Services AWS By Examples adds chapters on tearing infrastructure down again.[25] Ansible for Kubernetes (2020) uses the one tool to build container images, create clusters locally and on two clouds, and manage what runs on them.[26]
Ansible for Network Engineers (2026) argues that networks need the discipline most, because the configuration lives on the devices while the account of what it should be lives in an out-of-date design document, a spreadsheet and somebody's memory. Its early parts are deliberately not about networks, since inventory, playbooks, variables and roles are the same for a switch and a web server; the chapter it calls its most important is on the modules that manage one kind of resource and the states they can enforce, including the destructive ones; and it orders the whole book so that read-only, risk-free work comes before anything that can break a device, which it says is also the right order for an organisation adopting automation. Its later parts turn the technique into a practice: a single source of truth for the network, templates that generate a whole device's configuration, the detection of drift, backups, upgrades and validation, three complete projects, and then the work of a team, version control, testing, pipelines, credentials and how a practice survives the person who started it. There are no quizzes; each exercise gives a task, a full solution and the command that verifies it.[2] At the other end of the scale, Self-Healing Infrastructure: A Homelab Guide to Ansible Automation (2026) runs a home laboratory from playbooks, with a bridge that turns a monitoring alert into the playbook that fixes it,[27] and Cyber Range Essentials builds a security laboratory spanning physical hardware and cloud accounts with Ansible and Terraform together.[28]
Running Ansible for an organisation
Once many people run playbooks, they need a shared place to run them from. AWX in Action (2026) covers AWX, the web interface for Ansible, from installation on Kubernetes through organisations and access control to job templates and workflows, and explains what happens inside it when a job is launched.[29] Ansible AWX By Examples covers the same interface and its programming interface by example,[30] and Ansible Automation Platform By Example the commercial product built on it, including automation triggered by events.[31] For teams arriving from another tool, Salt To Ansible Migration Guide (2026) maps the constructs of Salt to their Ansible equivalents.[32]
Provisioning with Terraform, Pulumi and cloud templates
Terraform describes cloud resources in its own declarative language and keeps a record, the state, of what it has created. Introduction to Terraform (2023) covers the language, state and modules and goes on to multiple providers, pipelines, secrets and the use of Terraform with Ansible,[34] and Terraform Quickstart: The Beginner's Guide to Infrastructure as Code adds workspaces, importing existing resources, testing and debugging.[35] Modern Cloud Infrastructure-as-Code for Developers builds three architectures on AWS with it and observes that the boundary between the developer and the infrastructure engineer is dissolving, since developers are now expected to create and manage the infrastructure their applications run on; among the advantages it claims for the approach is that infrastructure defined in code can grow and shrink with traffic by itself.[8] Architecting and Implementing DevOps for Infrastructure Management in Azure (2025) makes the organisational argument: a team that delivers working software every fortnight delivers no value if the infrastructure it needs arrives more slowly, so infrastructure has to move at the speed of code.[9] Terraform Authoring and Operations Professional Study Guide prepares for the tool's professional exam,[36] and The Journey to DevOps gives Terraform one of its seven parts.[37]
The alternatives are represented more thinly. Pulumi in action (2025) uses Pulumi, which describes infrastructure in a general-purpose language, building one thing on AWS in each chapter in Python.[38] Stratospheric shows the path inside one cloud, from hand-written CloudFormation templates, files that list resources for the service to create, to the Cloud Development Kit that generates them.[10] Automating and Provisioning to Amazon AWS using boto3 SDK for Python 3 scripts a cloud directly from Python and hands the configuration of the machines to Ansible at the end,[39] and Proxmox VE 9 Mastery ends a book on a virtualisation platform with its automation through Ansible, Terraform and pipelines.[40]
Local environments and whole systems
Vagrant CookBook starts from a sentence every developer has said, that it works on my machine. Vagrant answers it by keeping the definition of a virtual machine in the project's repository, so that every developer, on any operating system, gets the same environment with one command; the tool creates the machine and hands the installing of packages to a provisioner. The book provisions the same web server three ways, with Ansible, Puppet and Chef, so that a reader can compare them, and notes that the same definitions can deploy real servers at a hosting provider. It names three kinds of user: a team that wants one testing environment for everyone, an open-source project that wants new contributors to be able to start at once, and administrators who want to try a multi-server setup before it reaches production. It also sets a condition, that the reader can already set up a server by hand, on the reasoning that a problem has to be understood before its solution can be automated.[3]
NixOS in Production (2024) represents a more radical approach, an operating system in which the whole machine is built from a declarative description. It is concerned less with the mechanism than with adoption: which uses the system suits, what a mature organisation using it looks like, how to migrate and what to avoid.[41]
Testing and reviewing infrastructure code
If infrastructure is code, it can be tested like code, and two short books say that it seldom is. Test in Infrastructure as Code (2023) observes that the literature explains how to write, run and roll back infrastructure code and rarely how to test it, and begins with the unit test of a container image: a file of assertions that the right files and versions are present, and that sensitive files are not. Provisioning a resource, its preface points out, answers none of the later questions, whether an update is correct, whether resources refer to one another properly, whether the configuration is what was intended, and a misconfiguration found in production is an outage; the book's scope takes in container images, Kubernetes manifests and charts, and provisioning tools.[6] Testing Ansible (2022), which its author describes as unfinished, brings a developer's habits to playbooks: tests written before the code they exercise, and linters, which matter as soon as a second person works on the same code and which score every role published to Ansible's public library. An ad-hoc command, it remarks, is for doing something once without sharing it, and a role is the opposite, a reusable block others will read; its contents run from syntax checks and dry runs to dedicated testing tools, continuous integration and security scanning.[7] Mastering Ansible Best Practices and Troubleshooting is a catalogue of those lint rules and of common error messages, one at a time.[33]
Review by someone other than the author is the subject of Infrastructure as Code for Security Engineers (2026): where secrets end up, what the state file exposes, how a pipeline can be attacked, the risks in third-party modules and providers, and what evidence an auditor should ask for.[42]
Pipelines, GitOps and platforms
Infrastructure code is usually applied by a pipeline rather than a person. Jenkins book (2019) packages the Jenkins user handbook with its author's articles, on pipelines defined in a file kept with the code, shared libraries and administration.[43] On Kubernetes the same idea is called GitOps: the desired state of the cluster is kept in a repository and a controller makes the cluster match it. Master GitOps with Argo CD and GitOps the Hard Way, with Argo CD both teach it with Argo CD,[44][45] Cloud Native Microservices With Kubernetes combines it with Terraform for the cluster itself and Ansible for the machines,[46] and Kubernetes A Complete Visual Guide treats declarative management and delivery as one part of running a cluster.[47] Success your LPI 701 DevOps Tools engineer exam covers the same tools at the level of a certification exam.[48]
Sources
Every source is a Leanpub book. The note after each says which part of it was read; where no sample was available, only the public description and table of contents were used.
- 1.Ansible for DevOps, Jeff Geerling: Server and configuration management for humans Free sample: the foreword, the introduction on the history of system administration and of Ansible, and the opening of chapter one. 2025. Free sample: PDF · EPUB
- 2.Ansible for Network Engineers, Jozef Baros: From First Playbook to Production Practice Free sample: the front matter and the preface, on the book's central claim, its reader and its organisation. 2026. Free sample: PDF
- 3.Vagrant CookBook, Erika Heidi: A practical guide to Vagrant Free sample: the introduction and the start of the chapter on how Vagrant works. 2017. Free sample: PDF · EPUB
- 4.Ansible for AWS, Yan Kurniawan: A simple way to provision and manage your Amazon Cloud infrastructure Free sample: the preface, on the history of configuration management, and the chapter outline. 2016. Free sample: PDF · EPUB
- 5.become Ansible, Josh Duffney Free sample: the preface on the author's path to configuration management, and the start of Part 1. 2020. Free sample: PDF
- 6.Test in Infrastructure as Code, Aldira Putra Raharja Free sample: the preface, the scope and the chapter on unit tests for container images. 2023. Free sample: PDF · EPUB
- 7.Testing Ansible, David Norman: Because you really should Free sample: the preface and the sections on test-driven development and linters. 2022. Free sample: PDF · EPUB
- 8.Modern Cloud Infrastructure-as-Code for Developers, Salie Lim Free sample: the introduction and the chapter on infrastructure as code and DevOps. 2023. Free sample: PDF · EPUB
- 9.Architecting and Implementing DevOps for Infrastructure Management in Azure, Ashish Raj: Infrastructure DevOps in Azure: Configure, Deploy, & Automate Your Azure resources with terraform, GitHub Actions and Ansible Free sample: chapter one, including the opening of the section on DevOps and infrastructure as code. 2025. Free sample: PDF · EPUB
- 10.Stratospheric, Tom Hombergs, Björn Wilmsmann, Philip Riecks: From Zero to Production with Spring Boot and AWS Free sample: chapter one, a first deployment with CloudFormation templates. 2024. Free sample: PDF · EPUB
- 11.Automated Configuration Management using Ansible, Gábor Szabó From the description and table of contents. 2019. Free sample: PDF · EPUB
- 12.DevOps For PHP Developers, David Mjomba: From Server Setup to Deployment. From the description and table of contents. 2020. Free sample: PDF
- 13.The Ansible Workshop, Aymen El Amri: Hands-On Learning For Rapid Mastery No sample: from the description and table of contents. 2024.
- 14.Ansible Cookbook, Luca Berton: A Comprehensive Guide to Unleashing the Power of Ansible via Best Practices, Troubleshooting, and Linting Rules with Luca Berton No sample: from the description and table of contents. 2024.
- 15.Ansible Tips and Tricks, Luca Berton: 10+ Ansible Examples to Save Time and Automate More Tasks No sample: from the description and table of contents. 2022.
- 16.The ProLUG Big Book of Labs, Scott Champine No sample: from the description and table of contents. 2025.
- 17.Ansible by Examples, Luca Berton: 200+ Automation Examples For Linux and Windows System Administrators and DevOps No sample: from the description and table of contents. A course of the same name covers the same ground. 2024.
- 18.Ansible For Linux by Examples, Luca Berton: 200+ Automation Examples For Linux System Administrator and DevOps No sample: from the description and table of contents. 2024.
- 19.Ansible For Windows By Examples, Luca Berton: 50+ Automation Examples For Windows System Administrator And DevOps No sample: from the description and table of contents. 2024.
- 20.Ansible For Security by Examples, Luca Berton: 100+ Automation Examples to Automate Security and Verify Compliance for IT Modern Infrastructure No sample: from the description and table of contents. 2024.
- 21.Ansible Linux Filesystem By Examples, Luca Berton: 40+ Automation Examples on Linux File and Directory Operation for Modern IT Infrastructure No sample: from the description and table of contents. 2022.
- 22.Ansible Linux Users & Groups By Examples, Luca Berton: 20+ Automation Examples on Linux Users and Groups Operation for Modern IT Infrastructure No sample: from the description and table of contents. 2022.
- 23.Ansible For PostgreSQL by Examples, Luca Berton: 10+ Examples To Automate Your PostgreSQL database No sample: from the description and table of contents. 2022.
- 24.Manage AWS Resources Using Ansible, David Clinton: the super short guide to cloud automation No sample: from the description and table of contents. 2019.
- 25.Ansible For Amazon Web Services AWS By Examples, Luca Berton: Automate Your AWS Infrastructure As Code No sample: from the description and table of contents. 2024.
- 26.Ansible for Kubernetes, Jeff Geerling: Automate app deployment on any scale with Ansible and K8s No sample: from the description and table of contents. 2020.
- 27.Self-Healing Infrastructure: A Homelab Guide to Ansible Automation, Will Smith: A Homelab Guide to Ansible Automation No sample: from the description and table of contents. 2026.
- 28.Cyber Range Essentials, Nicholas McKinney: Construct a Hybrid Cloud-Physical Lab with Ansible and Terraform No sample: from the description and table of contents. 2022.
- 29.AWX in Action, Aymen El Amri: Ansible Orchestration at Scale No sample: from the description and table of contents. 2026.
- 30.Ansible AWX By Examples, Luca Berton: Learn Ansible AWX web UI and API with some real-life examples No sample: from a one-line description; the table of contents is empty. 2022.
- 31.Ansible Automation Platform By Example, Luca Berton: Learn Ansible Automation Platform with a step-by-step guide for the most common user scenarios. No sample: from the description and table of contents. 2023.
- 32.Salt To Ansible Migration Guide, Jude Nagurney From the description and table of contents; the sample holds a contents list only. 2026. Free sample: PDF
- 33.Mastering Ansible Best Practices and Troubleshooting, Luca Berton: Elevating Your Ansible Coding Skills with Linting Rules Maximizing Your Ansible Proficiency for Remarkable Outcomes No sample: from a one-sentence description and the table of contents. 2023.
- 34.Introduction to Terraform, Bobby Iliev: From Zero to Hero: Unleashing the Power of Terraform No sample: from the description and table of contents. 2023.
- 35.Terraform Quickstart: The Beginner's Guide to Infrastructure as Code, Kirshi Yin | Curious Devs Corner: The Beginner's Guide to Infrastructure as Code No sample: from the description and table of contents. 2026.
- 36.Terraform Authoring and Operations Professional Study Guide, Mattias Fjellström: Azure edition No sample: from the description and table of contents. 2025.
- 37.The Journey to DevOps, Harry Yan: A Practical Guide for Software Engineers and Enthusiasts The free sample is a table of contents only: from that and the description. 2024. Free sample: PDF
- 38.Pulumi in action, Scott van Kalken: The python version No sample: from the description and table of contents. 2025.
- 39.Automating and Provisioning to Amazon AWS using boto3 SDK for Python 3, Carles Mateo: Code written for boto3 Python3 SDK v.1.20 From the description and table of contents; the short sample, whose example code prints credentials, was not used. 2022. Free sample: PDF
- 40.Proxmox VE 9 Mastery, BEKROUNDJO Akoley Aristide: Build Enterprise Clusters, Deploy Ceph, Replace VMware From the description and table of contents. 2025. Free sample: PDF
- 41.NixOS in Production, Gabriella Gonzalez: The NixOS handbook for professional use ONLY No sample: from the description and table of contents. 2024.
- 42.Infrastructure as Code for Security Engineers, Joshua Phillips No sample: from the description and table of contents. 2026.
- 43.Jenkins book, Gábor Szabó From the table of contents; the description is empty and the sample withholds the chapters. 2019. Free sample: PDF · EPUB
- 44.Master GitOps with Argo CD, Kirshi Yin | Curious Devs Corner: A hands-on guide to managing Kubernetes with GitOps No sample: from the description and table of contents. 2025.
- 45.GitOps the Hard Way, with Argo CD, Aymen El Amri: Build Real GitOps Pipelines From Empty Clusters to Automated Deploys No sample: from the description and table of contents. 2026.
- 46.Cloud Native Microservices With Kubernetes, Aymen El Amri: A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in Kubernetes No sample: from the description and table of contents. 2024.
- 47.Kubernetes A Complete Visual Guide, Reiner Braun: From Foundations to Production Operations From the description and table of contents. 2026. Free sample: PDF · EPUB
- 48.Success your LPI 701 DevOps Tools engineer exam, Radhouen Assakra No sample: from the description and table of contents. 2023.
Further reading
Other books in the library on the same ground, not cited above.
- Kubernetes 101, Jeff Geerling, Katherine Geerling: Learn the basics of Kubernetes and container-based infrastructure. A Kubernetes basics book whose manifests, Helm charts and short automation section touch on declared infrastructure. 2021.
- Kubernetes for DevOps, Anish Nath A Kubernetes operations cookbook with cluster setup, Helm installs and a Jenkins delivery pipeline. 2019. Free sample: PDF · EPUB
- Red Hat Enterprise Linux 10 Handbook, Luca Berton: A Comprehensive Guide to Mastering RHEL 10 Administration, Automation, and Emerging Technologies A Red Hat Enterprise Linux 10 overview with one section on automation through system roles. 2024.
- OpenShift AI Platform Guide, Luca Berton: Platform Engineering, GPUs, and Air-Gapped Clusters with OpenShift AI A guide to building an OpenShift platform for AI workloads, with GitOps and an Ansible collection among its parts. 2025.
- Red Hat Cloud Foundations, BEKROUNDJO Akoley Aristide: The Complete Guide to Building Enterprise Private Clouds with OpenShift, OpenStack, and Ceph A private cloud build guide in which GitOps automation and orchestration templates are parts. 2025. Free sample: PDF
- The Cybernetic Enterprise, Romano Roth: How to Build a Future-Ready Organization An operating-model book in which platform engineering and continuous delivery form one layer; no tooling. 2025.