Hi Team,i was working on coding exercise in ansible beginers course under the co . . .

Anupama Ramesh:
Hi Team,i was working on coding exercise in ansible beginers course under the conditionals and loops concept.So from variable concept i learnt that a vars has to be represented within a curly braces representing jinja2 templating format,but when i used in exercise it throws error.Can someone explain me why its wrong.Please find the image below.
Screenshot from 2022-08-17 22-40-38.png

Al West:
paste the error, also easier if you paste the text in markdown rather than share screen shots

Momoh Sani Musa:
Hi Anupama, when using variables with a conditional when, you don’t need to place it within curly braces. See the link to ansible docs below: <Conditionals — Ansible Documentation docs> . I hope this helps.

Al West:
Also you might want to use debug, as the echo happens in a different shell.

---
- name: Am I an Adult or a Child
  hosts: localhost
  vars:
    age: 25
  tasks:
  - name: Child
    debug: 
      msg: I am a Child
    when: age &lt; 18
  - name: Adult
    debug: 
      msg: I am an Adult
    when: age &gt;= 18

Anupama Ramesh:
@Al West this is in the coding excersise so i couldnt do more debugging here,its within the course and @Momoh Sani Musa cleared my doubt and thank you both :slightly_smiling_face:

Al West:
Just to be clear in this context debugoutputs to the console.