# conditional statement and if it is true , it should accept yes and continue for next step if not then it should terminate

**URL:** <https://forum.ansible.com/t/conditional-statement-and-if-it-is-true-it-should-accept-yes-and-continue-for-next-step-if-not-then-it-should-terminate/31469>\
**Category:** Ansible Project\
**Created:** [October 14, 2019, 9:47am UTC](https://forum.ansible.com/t/conditional-statement-and-if-it-is-true-it-should-accept-yes-and-continue-for-next-step-if-not-then-it-should-terminate/31469 "2019-10-14T09:47:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manish\_Kumar](https://avatars.discourse-cdn.com/v4/letter/m/d07c76/32.png) [@Manish\_Kumar](https://forum.ansible.com/u/Manish_Kumar)\
**Post date:** [October 14, 2019, 9:47am UTC](https://forum.ansible.com/t/conditional-statement-and-if-it-is-true-it-should-accept-yes-and-continue-for-next-step-if-not-then-it-should-terminate/31469/1 "2019-10-14T09:47:53Z")

</div>

Hi All,

I am trying to implement an conditional statement and if it is true , it should accept yes and continue for next step if not then it should terminate . Below playbook is not reading vaue like what we do in shell script with Echo “…” read value etc.

Any help ?

- hosts: localhost  
gather\_facts: False

tasks:

- name: Fetch Java version  
shell: java -version 2\>&1 | grep version | awk ‘{print $3}’ | sed ‘s/"//g’  
register: java\_result

- debug:  
msg: “{{ java\_result.stdout }}”

- name: condition when passed  
debug: msg=“passed”  
when: java\_result.stdout != “1.8.0\_131”  
vars\_prompt:

- name: condition  
prompt: " Do you want to continue?"  
confirm: yes  
debug: msg= “stop”  
when: java\_result.stdout == “1.8.0\_131”

Thanks,  
Manish

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [October 14, 2019, 9:58am UTC](https://forum.ansible.com/t/conditional-statement-and-if-it-is-true-it-should-accept-yes-and-continue-for-next-step-if-not-then-it-should-terminate/31469/2 "2019-10-14T09:58:57Z")

</div>

> Hi All,
> 
> I am trying to implement an conditional statement and if it is true , it should accept yes and continue for next step if  
> not then it should terminate . Below playbook is not reading vaue like what we do in shell script with Echo "..." read  
> value etc.
> 
> Any help ?

I would suggest to use the assert module to make sure a condition is met and bails out if the condition is false.

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke
