From the course: Ansible Essential Training
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Using loops - Ansible Tutorial
From the course: Ansible Essential Training
Using loops
- [Instructor] One of the many reasons that people love Ansible is its ability to automate the repetition that we must often perform in IT. Maybe we need to ensure that the permissions are changed on many different files. Or perhaps we need to create hundreds of new users accounts. Loops are the magic behind much of this repetition. In fact, loops were great with conditionals for performing acts until a certain value is reached. In Ansible, we have simple loops and complex loops. More complex loops can be used to do things like iterate over nested lists, or retry a task until a condition is met. So let's go to our command line here on the control node, and let's examine the first loop example that I have for us. So we're just going to cat loop1.yml and that's .yml, there we go. And we can see we're just running a playbook against our web servers. And notice I have a variables section and that variable section defines a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
(Locked)
Using host groups4m 31s
-
(Locked)
Using tags4m 27s
-
(Locked)
Running tasks against localhost5m 25s
-
(Locked)
Using the command line to control execution5m 2s
-
(Locked)
Specifying variables in the inventory file5m 51s
-
(Locked)
Creating dynamic inventory files7m 5s
-
(Locked)
Using templates6m 15s
-
(Locked)
Conditional execution4m 25s
-
(Locked)
Using loops7m 45s
-
(Locked)
Testing plays with check mode3m 27s
-
(Locked)
-
-
-
-
-