On 10/14/19 11:47 AM, Manish Kumar wrote: > 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
Racke
>
>
> - 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
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
> [email protected]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/c8fbf8af-ea96-4c4b-8433-63fdcee86654%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/c8fbf8af-ea96-4c4b-8433-63fdcee86654%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/a72b8dd9-2705-380e-10f5-ec6ba4e1968a%40linuxia.de.
signature.asc
Description: OpenPGP digital signature
