Ansible basics: inventory, ad-hoc commands, playbooks
Sign in to read this lesson
Making the same change on ten servers by hand is both slow and error-prone. Ansible connects to servers over SSH and lets you describe the state you want in a YAML file. In this lesson we write an inventory, ad-hoc commands, use modules and write our first playbook.
What you will learn
- Ansible is agentless: managed servers only need SSH and Python; installation happens only on the control machine.
- The inventory is the list of servers, with groups:
[web],[db].ansible all -m pingchecks all of them. - A module does one job (
dnf,service,copy,user,firewalld); modules are idempotent — running them a second time changes nothing. - A playbook is a YAML file:
hosts,become,tasks; it runs withansible-playbook file.yml, and in test mode with--check. - Result colours:
ok(already like that),changed(changed),failed(error).
The lesson has 5 key points, an explanation and 5 questions. It opens with a package.