On 23. sep. 2016 21:43, Anthony Cheng wrote:
I have been struggling to use the lookup for vars feature, specifically
tried something like:
vars:
BUCKET_LIST: "{{ lookup('file', 'test') }}"
vars:
BUCKET_LIST: "{{ lookup('file', 'test') |to_json }}"
Where test is basically just a flat text file, new line separated
What I want to do is to call the variable in a loop so I can use it in
another module, e.g. s3
- name: List s3 bucket
local_action:
module: s3
bucket: "{{ item }}"
mode: list
with_items: "{{ BUCKET_LIST }}"
However from debug I can see that the items are not separated:
ok: [localhost] => (item="test1\ntest2-inputtxt2") => {
"invocation": {
▽ "module_args": {
"msg": "\"test1\\ntest2-inputtxt2\""
},
"module_name": "debug"
},
"item": "\"test1\\ntest2-inputtxt2\"",
"msg": "\"test1\\ntest2-inputtxt2\""
}
Any idea how to properly format with lookup so the item are separated?
BUCKET_LIST: "{{ lookup('file', 'test').split('\n') }}"
--
Kai Stian Olstad
--
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/d58235aa-b5d2-b2cb-81d8-4cfe7c4c73b4%40olstad.com.
For more options, visit https://groups.google.com/d/optout.