student@bchd~$ vim whenpractice.yml
---
- name: When and Loops
hosts: localhost
vars:
names_list:
- Chad
- Damian
- Jason
tasks:
- name: Print that only YOUR name is awesome
debug:
msg: "{{ item }} is awesome!"
loop: "{{ names_list }}"
# CHALLENGE: Add a `when` condition here that this task only prints out YOUR name as awesome :)student@bchd~$ ansible-playbook whenpractice.yml
Gimme a hint!
- Hint 1: Your name is being compared to the current
itemin the loop.
Need another hint?
- Hint 2: You'll need to confirm that your name and the current
itemare the same.
Want another hint?
- Hint 3: Use
==to compare your name to the currentitem.
Want the answer?
- Hint 4: Use the
whencondition like this:
- name: Print that only YOUR name is awesome
debug:
msg: "{{ item }} is awesome!"
loop: "{{ names_list }}"
when: item == "YourName"Replace "YourName" with your actual name.