# Ansible lookup on file format issue

**URL:** <https://forum.ansible.com/t/ansible-lookup-on-file-format-issue/22633>\
**Category:** Ansible Project\
**Created:** [September 23, 2016, 7:43pm UTC](https://forum.ansible.com/t/ansible-lookup-on-file-format-issue/22633 "2016-09-23T19:43:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anthony\_Cheng](https://avatars.discourse-cdn.com/v4/letter/a/c57346/32.png) [@Anthony\_Cheng](https://forum.ansible.com/u/Anthony_Cheng)\
**Post date:** [September 23, 2016, 7:43pm UTC](https://forum.ansible.com/t/ansible-lookup-on-file-format-issue/22633/1 "2016-09-23T19:43:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [September 23, 2016, 8:27pm UTC](https://forum.ansible.com/t/ansible-lookup-on-file-format-issue/22633/2 "2016-09-23T20:27:04Z")

</div>

BUCKET\_LIST: "{{ lookup('file', 'test').split('\n') }}"
