Couldn't evaluate conditionals

I want to add a simple check on the version of nginx.
But version with conditionals won’t work :frowning:

  • 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 might want to look into this:
http://docs.ansible.com/playbooks_variables.html#version-comparison-filters

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 bhavenger@gmail.com napisał: