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