Ravindra BagaleCourses & study guides

Chapter 11: Ansible Introduction

11.2 Inventory — who are we configuring?

Inventory lists hosts and groups. INI style (simple labs):

# inventory/hosts.ini
[badge-api_web]
lab1 ansible_host=203.0.113.10 ansible_user=ec2-user

[badge-api_web:vars]
ansible_python_interpreter=/usr/bin/python3

YAML inventory is also common. Use your real lab IP/DNS name — the sample IP above is documentation-style, not a promise about your account.

Key Meaning
Group [badge-api_web] Logical set of hosts
ansible_host Address SSH reaches
ansible_user SSH login user
Group vars Shared settings for the group

SSH keys should already work (ssh ec2-user@…). Ansible reuses that trust. If SSH fails, fix SSH first — do not blame YAML yet.

Practice task

Write a two-host inventory group badge-api_web with fake lab hostnames and a shared ansible_user. Mark which line is the group name.