URI and Until

85 views
Skip to first unread message

Matt Hughes

unread,
Dec 17, 2014, 4:22:20 PM12/17/14
to ansible...@googlegroups.com

I have a cluster of N nodes.  Cluster status is reported by http://cluster_fqdn/health/.  I want to do a rolling upgrade of every node in my cluster with serial: 1.  I don't want to proceed to the next node until http://cluster_fqdn/health/ reports the cluster is healthy.  


Trying to use uri and until, but can't seem to get the syntax quite right:


- name: Await Cluster Healthy Status
  uri
: url=http://{{host_ip}}/cluster_health/ return_content=yes
 
register: cluster_health
 
until: "green" in "{{cluster_health.content}}
  retries: 100
  delay: 10




errors out with:


ERROR: Syntax Error while loading YAML script, main.yml

Note: The error may actually appear before this position: line 67, column 18


  register: cluster_health

  until: "green" in "{{cluster_health.content}}"


I was going by the example here: http://docs.ansible.com/uri_module.html



I also tried using the example here (http://docs.ansible.com/playbooks_loops.html#do-until-loops)


- name: Await Cluster Healthy Status
  uri
: url=http://{{host_ip}}/cluster_health/ return_content=yes
 
register: cluster_health
 
until: cluster_health.content.contains("green") != -1
  retries
: 100
  delay
: 10



but that fails with:


fatal: [prod.clustertest-elk-fxbo-1] => error while evaluating conditional: cluster_health.content.contains("green") != -1



Took me a while to realize I needed to install liburi module, but that's a different story.  I debugged 'cluster_health' var and it definitely contains the word "green".   

Matt Hughes

unread,
Dec 17, 2014, 4:31:00 PM12/17/14
to ansible...@googlegroups.com
The error was 'contains' isn't a method.  'find' is though.

I love Ansible, but the error reporting really leaves a lot to be desired.  Still have no idea what was wrong with the first example.  Maybe until and when have different conditional syntaxes?
Reply all
Reply to author
Forward
0 new messages