Couldn't evaluate conditionals

23 views
Skip to first unread message

Zaitsev Dmitriy

unread,
Nov 27, 2014, 11:43:10 PM11/27/14
to ansible...@googlegroups.com
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

Brian Coca

unread,
Nov 28, 2014, 8:51:03 AM11/28/14
to ansible...@googlegroups.com

Tomasz Kontusz

unread,
Nov 28, 2014, 9:16:29 AM11/28/14
to ansible...@googlegroups.com
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 <bhav...@gmail.com> napisał:

--
Wysłane za pomocą K-9 Mail.
Reply all
Reply to author
Forward
0 new messages