On 10/11/19 7:58 AM, Manish Kumar wrote:
>
> Dear All,
>
> Is it possible to get the output from .sh file and compare with "Apache Tomcat/9.0.26" and if condition is true proceed
> for next step ?
>
The condition in "when" is evaluated before running the task. You need an additional task where you can apply the
condition based on the values in output.stdout.
Regards
Racke
>
> ---
> - hosts: localhost
> tasks:
>
> - name: Extract archive
> shell: sh /U01/apache-tomcat-9.0.26/bin/version.sh
> register: output
> when: output.stdout == "Apache Tomcat/9.0.26"
> debug: msg="passed"
>
>
> Error Log:
>
> [WARNING] Ansible is in a world writable directory (/U01/automation/playbooks), ignoring it as an ansible.cfg source.
>
>
>
> PLAY [localhost] ***************************************************************
>
>
>
> TASK [Gathering Facts] *********************************************************
>
> ok: [localhost]
>
>
>
> TASK [Extract archive] *********************************************************
>
> fatal: [localhost]: FAILED! => {"failed": true, "msg": "The conditional check 'output.stdout == \"Apache
> Tomcat/9.0.26\"' failed. The error was: error while evaluating conditional (output.stdout == \"Apache Tomcat/9.0.26\"):
> 'output' is undefined\n\nThe error appears to have been in '/U01/automation/playbooks/Esm_java.yml': line 5, column 7,
> but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n -
> name: Extract archive\n ^ here\n"}
>
> Debugger invoked
>
> (debug)
>
>
> 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
>
ansible-proje...@googlegroups.com <mailto:
ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/ansible-project/78097434-3c2e-4b33-9747-a1b83d52a1a0%40googlegroups.com
> <
https://groups.google.com/d/msgid/ansible-project/78097434-3c2e-4b33-9747-a1b83d52a1a0%40googlegroups.com?utm_medium=email&utm_source=footer>.
--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.