What Is Ansible
Picking up from Terraform: what Ansible is, how it works without agents, its core benefits for DBAs, and how it compares with Terraform.
Picking up from Terraform
Terraform builds the infrastructure: the server, its disks, and its network. Ansible takes over from there and configures what runs on it: operating system settings, database software, parameters, users, patches, and the routine jobs DBAs repeat across many servers. It's the most widely used configuration management tool, and the one DBAs tend to use most.
In the IaC and Configuration Management lesson, you saw the usual pattern: Terraform to build, Ansible to configure. Terraform's work is mostly done once a server exists; Ansible's carries on for the server's whole life, through every patch, parameter change, and new user.
What Ansible is
Ansible was created by Michael DeHaan and released in 2012; Red Hat bought the company behind it in 2015. You write playbooks, files in YAML that list the tasks to perform, and Ansible connects to each server over SSH and carries them out.
- Agentless
- Nothing has to be installed on the servers Ansible manages, beyond SSH and Python, which Linux servers already have. That makes it easy to start using on an existing estate.
- Control node
- The machine where Ansible runs, holding the inventory and playbooks: a laptop, a jump server, or a pipeline.
- Managed nodes
- The servers Ansible configures, listed in the inventory.
- Modules
- Small, ready-made units of work, such as "install a package", "create a user", or "set a kernel parameter", each idempotent. Thousands are available, grouped into collections.
- Push-based
- Ansible pushes changes when you run it, rather than agents pulling them, so you decide exactly when each server changes.
Core benefits for DBAs
- Consistency across the fleet
- Every database server is configured from the same playbook, so kernel settings, packages, directory layouts, and parameters are the same everywhere. No more "it works on db01 but not db07".
- Safe to run again
- Ansible's modules are idempotent: they change only what isn't already right. Running a playbook on a server that's already correct changes nothing, so you can rerun it to check, or to fix drift.
- Scale
- One command patches, checks, or reconfigures one server or three hundred, in controlled batches.
- Runbooks that run
- A playbook reads like a runbook, in plain YAML, but it actually does the work. It's documentation that can't go out of date.
- Version control and review
- Playbooks live in Git, so every change to how servers are configured is reviewed and recorded.
- Works with everything
- Linux and Windows servers, databases, cloud APIs, network devices, and monitoring tools, and it fits naturally after Terraform in a pipeline.
Ansible and Terraform
| Terraform | Ansible | |
|---|---|---|
| Main job | Create infrastructure | Configure servers and run operational tasks |
| Knows what exists from | Its state file | Checking each server live, every run |
| Language | HCL | YAML |
| Preview | terraform plan | --check --diff |
| DBA example | Create a DB server and its disks | Install Oracle on it, set parameters, and patch it every quarter |
In practice: one setting, 200 servers
Oracle Support recommends a new kernel parameter for all of Kofi's database servers. Before Ansible, the team logged in to each of the 200 servers and edited the setting by hand, over several weeks. Some servers were missed, a few got typos, and nobody could say for certain which had the change.
With Ansible, Kofi adds one task to the OS baseline role and opens a pull request. After review, a dry run shows exactly which servers would change, then the playbook applies it to every server in about ten minutes, in batches. Running it again reports changed=0 everywhere, which proves every server is right. When a new server is built next month, it gets the setting automatically.
Key takeaways
- Ansible configures what runs on servers, picking up where Terraform leaves off, for the server's whole life.
- It's agentless: a control node runs playbooks against managed nodes over SSH, using idempotent modules.
- For DBAs, it brings consistency, safe reruns, scale, runbooks that run, and version-controlled configuration.
- ansible-core is the open source tool; Ansible Automation Platform and AWX add a web interface, permissions, and scheduling.