Module 2 · Project 02 · Automated Server Configuration with Ansible · Lesson 6 of 48
Configuration management and your first inventory
Why scripts stop scaling, how Ansible pushes configuration over SSH, and how an inventory groups your servers.
In this lesson · about 25 minutes
- Explain what configuration management solves
- Describe Ansible's control node, managed nodes and inventory
- Write an inventory with groups and run ad-hoc commands
Why Bash isn't enough
Project 01's scripts are great on one server. Now picture forty. You copy files around, forget one server, run a setup script twice and break something, and no one is sure which servers match which version. Servers that were each fixed by hand drift apart until every one is a snowflake: unique, fragile and impossible to rebuild.
Configuration management fixes this. You write down the state each server should be in (these packages installed, this user present, this file with this content, this service running) and a tool makes every server match it, as often as you like.
How Ansible works
- The control node is where you run Ansible: your laptop or a CI runner. Only it needs Ansible installed.
- Managed nodes are the servers. Ansible reaches them over plain SSH and runs small Python programs there. There is no agent to install, which is a big reason teams like it.
- The inventory lists the managed nodes and puts them in groups, such as
webanddb. - Modules do the work:
aptinstalls packages,usermanages users,copyandtemplatewrite files,servicestarts services. There are thousands. - A playbook is a YAML file that says which modules to run on which group, in order. That's the next lesson.
An inventory
# inventory.ini
[web]
web-01 ansible_host=10.0.1.11
web-02 ansible_host=10.0.1.12
[db]
db-01 ansible_host=10.0.2.21
[all:vars]
ansible_user=deploy
Groups let you target a role: "all web servers" rather than a list of names. The built-in group all means every host.
Whiteboard · watch and try
Push, over SSH, with no agent
Press Play to see the shape of an Ansible setup.
Tip: press Pause, then use the pen to work along on the board. Space plays and pauses; Ctrl+Z undoes your last mark.
Try it · watch it run
Run a playbook across your inventory
Pick a play, then run it. Watch the tasks fan out over SSH. Run it a second time, then switch db-01 off and run the baseline again.
| Task | web-01 | web-02 | db-01 |
|---|---|---|---|
| Gathering Facts | … | … | … |
| Install base packages (curl, git, ufw) | … | … | … |
| Create the deploy user | … | … | … |
| Disable SSH password login | … | … | … |
$ ansible-playbook -i inventory.ini site.yml PLAY [all] ******************************
Hands-on lab (simulated terminal)
Lab: inventory and ad-hoc commands
Your control node has Ansible installed and SSH keys copied to three practice servers.
Step 1 of 4. Type each command and press Enter. Nothing runs on your computer.
1. Check which Ansible version is installed.
Check your understanding0 of 3 correct
Key terms
Say the meaning to yourself, then tap a card to check.
Quiz score: 0 of 3
Written by Noviq Academy in its own words. The labs are simulations: no real servers are touched. When you build the projects yourself, use a practice virtual machine or a free-tier cloud account you control, watch your cloud spending, and never run cleanup or delete commands on a machine you care about. Tool names belong to their owners; versions and output are shown for learning and may differ slightly from yours. Read-aloud and the whiteboard voice use your device's built-in voices.