I understand the |default([]) can be used to run a loop only if the item is 
not an empty list, 
But I can't find a way to proceed to quit the playbook if one parameter is 
missing:

vars: booleen: False
- set_facts:
         booleen: True
  with_items:
         - "{{ KARAFHTTPTIMEOUT|default([]) }}"
         - "{{ dbType|default([]) }}"

if all parameters are empty, booleen is False and I can use fail: ... when 
booleen = False
But if only one parameter is missing, booleen is true.

Thanks for helping: my purpose is to verify that all parameters are set in 
a csv file and to fail of one is missing.


Le mardi 27 septembre 2016 12:10:13 UTC+2, fanvalt a écrit :
>
> The purpose is that the playbook fails if some parameters are not defined 
> in the csv file
>
> Le mardi 27 septembre 2016 11:44:40 UTC+2, fanvalt a écrit :
>>
>> Hello,
>>
>> I read a csv file with the lookup command with a loop on the items:
>>
>>    tasks:
>>      - set_fact:
>>          "{{ item.name }}": "{{ lookup('csvfile', '{{ item.csvvar }} 
>> file=vars/fvaltat.csv delimiter=; col=1') }}"
>>        with_items:
>>          - { name: 'KARAFHTTPTIMEOUT', csvvar: 'TOTO' }
>>          - { name: 'dbType', csvvar: 'DBTYPE' }
>>
>> How to check the variable does exist and is different from space
>> I tried without success a fail ... when :
>> when: item.0 is not defined
>> when: item.name is not defined
>> when: item.name =='[]'
>> I tried to use a register variable but I cannot find the way to test the 
>> register variable content.
>>
>> Thanks for your help
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/98a08911-fce4-4703-ae07-b4adbbecde25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to