0 / 13 lessons — 0%
Lesson 02 / 13
Installing Ansible & the inventory
Ansible only needs to be installed in one place: your control node — your laptop, or a dedicated ops box. Managed hosts need nothing but SSH access and Python.
# control node setup (pick your platform) python3 -m pip install --user ansible # or: brew install ansible / apt install ansible ansible --version
Before Ansible can manage anything, it needs to know what to manage. That list — the inventory — groups hosts by role so you can target "all webservers" instead of listing IPs every time.
# inventory.ini [webservers] web1.example.com web2.example.com [dbservers] db1.example.com ansible_user=admin [staging:children] webservers dbservers
# sanity checks before you run anything real ansible-inventory -i inventory.ini --list ansible all -i inventory.ini -m ping
Real teams rarely hand-type static inventories. A dynamic inventory plugin queries AWS, Azure, or GCP directly and builds the host list from actual running instances and their tags — so newly launched servers show up automatically with no manual editing.
Try it yourselfWrite a two-host inventory file pointing at machines you actually have SSH access to (even two local VMs), then run
ansible all -i inventory.ini -m ping. A green "pong" from each host means your control node can reach them — the foundation everything else builds on.