← Back to tools

Ansible

Automate IT infrastructure provisioning and configuration

Description

Ansible is an agentless automation tool for configuration management, application deployment, and infrastructure orchestration. It uses simple YAML playbooks to describe desired system states, connects over SSH, and requires no agent software on managed nodes. It supports hundreds of modules for cloud providers, networking, containers, and more.

Install

pippip install ansible
homebrewbrew install ansible
aptsudo apt install ansible

AI Summary

Agentless IT automation. Define infrastructure and configuration as YAML playbooks, push changes over SSH to any number of servers. No agent required on managed nodes. Supports cloud provisioning, app deployment, and configuration management.

Capabilities

  • + Configure servers and services using declarative YAML playbooks
  • + Manage hundreds of servers without installing agents
  • + Provision cloud resources on AWS, GCP, Azure, and others
  • + Orchestrate multi-step deployment workflows with roles and playbooks
  • + Manage secrets with Ansible Vault encryption
  • + Run ad-hoc commands across an inventory of servers
  • + Create reusable roles and share them via Ansible Galaxy

Use When

  • Configuring and managing multiple servers consistently
  • Automating application deployments across environments
  • Need agentless configuration management over SSH
  • Orchestrating complex multi-step provisioning workflows
  • Managing cloud infrastructure alongside server configuration

Avoid When

  • x Managing a single local machine only (overkill for simple tasks)
  • x Need real-time infrastructure state tracking (use Terraform for state management)
  • x Windows-only environments where PowerShell DSC is preferred

Usage Patterns

Ping all hosts

ansible all -m ping -i inventory.ini

Tests connectivity to all hosts in the inventory

Run a playbook

ansible-playbook -i inventory.ini site.yml --become

Executes a playbook with sudo privileges on all targeted hosts

Run an ad-hoc command

ansible webservers -m shell -a 'uptime' -i inventory.ini

Runs the uptime command on all hosts in the webservers group

Encrypt a file with Vault

ansible-vault encrypt secrets.yml

Encrypts a YAML file containing sensitive variables

Input / Output

stdin: Vault passwords, confirmation prompts
stdout: Task results, changed/ok/failed status per host
Exit codes:
0 Success
1 Error
2 One or more hosts failed
4 One or more hosts unreachable

Typical Pipelines

terraform apply && ansible-playbook -i inventory.ini configure.yml
ansible-inventory --list -i inventory.ini | jq '.all.hosts'
ansible all -m setup -i inventory.ini | jq '.ansible_facts.ansible_os_family'

Related Tools

View AGENTS.md for Ansible