Loops and Conditionals
Part of the Ansible course
A playbook that installs one package has one task. A playbook that installs ten packages should not have ten nearly identical tasks that differ only in a package name, and a playbook that only needs to touch some of your machines should not run every task against all of them regardless.
Picture a machine on an assembly line that stamps the same shape onto a sheet of metal, over and over, once per sheet fed into it. The machine does not care that sheet three is a slightly different size than sheet seven, it repeats the identical stamping motion for whatever comes down the line. ...
Want to learn Ansible Loops and Conditionals in a real environment?
Click below, get a fresh Linux box with Ansible ready to go, and work through Loops and Conditionals hands-on with an AI tutor that knows your code.
Start this lessonLoops and ConditionalsWhat you'll learn
- Loop keyword
- Loop with dicts
- When conditionals
- Register
- Block and rescue basics
Read this lesson in your language
All lessons in this course
12 lessons- 1What Is Ansible20 min
- 2Inventory and Ad Hoc Commands25 min
- 3Your First Playbook30 min
- 4Tasks, Modules, and Handlers30 min
- 5Variables and Facts30 min
- 6Templates with Jinja230 min
- 7Loops and Conditionals30 min
- 8Roles and Galaxy35 min
- 9Vault and Secrets25 min
- 10Tags and Debugging25 min
- 11Collections and Plugins25 min
- 12Capstone: Multi Host Deploy60 min
