$ ansible --version · Complete Cheat Sheet
| Term | Description |
|---|---|
| Control Node | Machine where Ansible is installed and runs from |
| Managed Node | Remote host Ansible manages — no agent required |
| Inventory | File listing hosts and groups to manage |
| Playbook | YAML file with ordered list of plays and tasks |
| Play | Maps a set of hosts to a list of tasks |
| Task | Single unit of work — calls exactly one module |
| Module | Reusable unit of code (apt, copy, template…) |
| Role | Structured, reusable unit of playbook content |
| Handler | Task triggered only when notified by another task |
| Fact | System info auto-gathered from managed nodes |
| Template | Jinja2 file rendered with variable substitution |
| Vault | Encryption for sensitive data in playbooks |
| Collection | Distributable package of roles, modules, plugins |
| Variable | Purpose |
|---|---|
| ansible_host | IP / hostname to connect to |
| ansible_port | SSH port (default 22) |
| ansible_user | Remote user for SSH |
| ansible_password | SSH password — use vault! |
| ansible_ssh_private_key_file | Path to private key |
| ansible_become | Enable privilege escalation |
| ansible_become_user | User to become (default root) |
| ansible_become_method | sudo, su, pbrun, pfexec… |
| ansible_connection | ssh, local, docker, winrm… |
| ansible_python_interpreter | Python path on remote host |
| Pattern | Matches |
|---|---|
| all / * | All hosts in inventory |
| webservers | All hosts in a group |
| web1.example.com | Specific host |
| web* | Wildcard name match |
| web:db | Union of two groups |
| web:&db | Intersection (in both) |
| web:!staging | web minus staging group |
| webservers[0] | First host in group |
| webservers[0:2] | First three hosts |
| ~web.*\.com | Regex pattern |
| Flag | Description |
|---|---|
| -i inventory | Inventory file, directory or script |
| -u user | Remote SSH user |
| -b | Become (sudo / privilege escalation) |
| -K | Prompt for become password |
| --ask-pass | Prompt for SSH password |
| -f 10 | Forks / parallelism level |
| -v / -vvv | Verbosity (1–4 levels) |
| --check | Dry run — no changes made |
| --diff | Show diffs for changed files |
| -l host1,host2 | Limit to specific hosts |
| --tags tag1 | Run only tagged tasks |
| Variable | Description |
|---|---|
| hostvars | All variables for all hosts |
| groups | All inventory groups and their hosts |
| group_names | Groups the current host belongs to |
| inventory_hostname | Current host's inventory name |
| play_hosts | Active hosts in the current play |
| ansible_play_batch | Hosts in the current serial batch |
| role_path | Filesystem path of current role |
| playbook_dir | Directory containing the playbook |
| Fact | Example |
|---|---|
| ansible_hostname | web1 |
| ansible_fqdn | web1.example.com |
| ansible_default_ipv4.address | 10.0.0.5 |
| ansible_all_ipv4_addresses | [10.0.0.5] |
| Fact | Example |
|---|---|
| ansible_os_family | Debian |
| ansible_distribution | Ubuntu |
| ansible_distribution_version | 22.04 |
| ansible_distribution_major_version | 22 |
| ansible_kernel | 5.15.0-91 |
| Fact | Example |
|---|---|
| ansible_architecture | x86_64 |
| ansible_processor_vcpus | 4 |
| ansible_memtotal_mb | 7962 |
| ansible_pkg_mgr | apt |
| ansible_service_mgr | systemd |