Hello,
Is there a way to set a default value when using the lookup module for a
csv file.
Case 1:
Here is the csv file:
OPENHRPORT;;;;;;
I would like to set the '1' value if the value in the csv file is not
specified:
vars:
- port: "{{ lookup('csvfile', 'OPENHRPORT file=vars/test.csv
delimiter=; col=1') | default('1') }}"
tasks:
- debug: msg="port openhr {{ port }}"
But it returns the port varibale set to blank or unset, I would like it set
to 1
"msg": "port openhr "
Case 2:
the csv file has only one key set:
OPENHRPORT;;;;;;
And I want to lookup at another key and set a default value if the key is
not present in the csv file:
vars:
- port: "{{ lookup('csvfile', 'OPDFT file=vars/test.csv delimiter=;
col=1') | default('1') }}"
tasks:
- debug: msg="port openhr {{ port }}"
But it returns in the list bracket , I would expect it set to 1
"msg": "port openhr []"
Could you give me any help on this lookup module and default value ?
Regards,
--
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/0494e393-b5ea-496f-b037-19f68d5521ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.