# tried to use pre-defined variable in WHEN conditional but not working, please assist

**URL:** <https://forum.ansible.com/t/tried-to-use-pre-defined-variable-in-when-conditional-but-not-working-please-assist/35680>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [August 26, 2021, 2:19pm UTC](https://forum.ansible.com/t/tried-to-use-pre-defined-variable-in-when-conditional-but-not-working-please-assist/35680 "2021-08-26T14:19:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 26, 2021, 2:19pm UTC](https://forum.ansible.com/t/tried-to-use-pre-defined-variable-in-when-conditional-but-not-working-please-assist/35680/1 "2021-08-26T14:19:12Z")

</div>

2 problems:

too many moustaches (all conditionals aka \*when: have templating implied)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: ansible\_net\_version in ios\_image1.stdout[0]

from the expression above, ios\_image1 does not have stdout, it is a  
string itself, you seem to be confusing it with a result dictionary

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when: ansible\_net\_version in ios\_image1
