Lab 5: Conditionals & Loops

Intermediate 50 minutes Intermediate Labs

Learning Objectives

  • Use when conditionals effectively
  • Loop over lists and dictionaries
  • Combine loops with conditionals
  • Use register to capture task results

Progress

0 of 3 tasks completed

Tasks

1
Use Conditionals
Execute tasks based on conditions
2
Loop Over Items
Use loops to process multiple items
3
Register and Use Results
Capture task output and use it in subsequent tasks
Hints for Task
    Playbook
    Inventory
    --- - name: Conditionals and Loops Lab hosts: localhost gather_facts: yes vars: packages: - git - curl - vim users: - name: alice group: developers - name: bob group: operators tasks: # Task 1: Use conditionals # Add your code here # Task 2: Loop over items # Add your code here # Task 3: Register and use results # Add your code here
    localhost ansible_connection=local
    Output
    Waiting for playbook execution...