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.
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.
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 < 18 - name: Adult debug: msg: I am an Adult when: age >= 18
@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
Just to be clear in this context
debugoutputs to the console.