You shouldn't need {{ }} in when. And you probably want to strip whitespace
from the shell output.
Try:
when: nginx_version == nginx.stdout.strip()
Zaitsev Dmitriy <[email protected]> napisał:
>I want to add a simple check on the version of nginx.
>But version with conditionals won't work :(
> - name: check for install nginx
> shell: nginx -v 2>&1 | awk '{print $3}' | sed -e 's/nginx\///g'
> register: nginx
>
> - debug: msg="{{ nginx.stdout }}"
>
> - name: download nginx latest version
> shell: wget -N http://nginx.org/download/nginx-{{ nginx_version
>}}.tar.gz -P /usr/src
> when: "{{ nginx_version }} != {{ nginx.stdout }}"
>
>Result:
>error while evaluating conditional: 1.6.1 != 1.6.1
>
>--
>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 post to this group, send email to [email protected].
>To view this discussion on the web visit
>https://groups.google.com/d/msgid/ansible-project/78023921-7c33-4df2-93ab-c92ad5585c00%40googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.
--
Wysłane za pomocą K-9 Mail.
--
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/5cf51c76-5331-4f08-a3a3-07ae61f73fbe%40email.android.com.
For more options, visit https://groups.google.com/d/optout.