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
You dont need moustaches in conditionals:
when: builds[item] == pkgversion
Unfortunately its the same error
fatal: [abc.xyz.com]: FAILED! => {“msg”: "The conditional check ‘builds[item] == pkgversion’ failed. The error was: error while evaluating conditional (builds[item] == pkgversion): ‘list object’ has no attribute u’0’