I have vars file as below

---
builds:
 - 10350.0.0
 - 10351.0.0
 - 10352.0.0
 - 10360.0.0
 - 10361.0.0
 - 10362.0.0
 - 10363.0.0
 - 10364.0.0
 - 10365.0.0
 - 10366.0.0
 - 10367.0.0
 - 10368.0.0
 - 10370.0.0
 - 10371.0.0
 - 10372.0.0
 - 10380.0.0
 - 10381.0.0
 - 10382.0.0
 - 10383.0.0
 - 10384.0.0
 - 10390.0.0
 - 10391.0.0
 - 10392.0.0
 - 10400.0.0
 - 10401.0.0
 - 10402.0.0
 - 10403.0.0
 - 10404.0.0

I am trying to setup an variable when particular build length matches with the 
package version but it throws with the following error 

    - debug: var=builds[4]  -> Getting value from the list works
    - set_fact: buildslen={{ builds | length }} -> Length of the list 
    - debug: var=pkgversion -> Package version
    - debug: var=buildslen 
    - debug: var=builds[{{item}}]
      with_sequence: start=0 count={{ buildslen }}  -> Looping through all the 
versions works fine
    - set_fact: exactlen=builds[{{ item }}]
      when: builds[{{ item }}] == {{ pkgversion }} 
      with_sequence: start=0 count={{ buildslen }}
    - debug: var=exactlen

-> This is the error "msg": "The conditional check 'builds[{{ item }}] == {{ 
pkgversion }}' failed. The error was: Invalid conditional detected: invalid 
syntax . 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to