# Building inventory from csv file

**URL:** <https://forum.ansible.com/t/building-inventory-from-csv-file/29021>\
**Category:** Ansible Project\
**Created:** [November 13, 2018, 11:36pm UTC](https://forum.ansible.com/t/building-inventory-from-csv-file/29021 "2018-11-13T23:36:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abdul\_Rahim](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@Abdul\_Rahim](https://forum.ansible.com/u/Abdul_Rahim)\
**Post date:** [November 13, 2018, 11:36pm UTC](https://forum.ansible.com/t/building-inventory-from-csv-file/29021/1 "2018-11-13T23:36:27Z")

</div>

Hi there ,

I am new to ansible , looking to see if I can import variables from csv file and either build an inventory file or use them in a playbook , Appreciate your feedback.

Basic playbook I tried:

root@ansibile-launch:~/ansible/tasks/csv-file# cat test2.yml

---

<div class="post-metadata">

**Author:** ![Foss\_Geek](https://avatars.discourse-cdn.com/v4/letter/f/df705f/32.png) [@Foss\_Geek](https://forum.ansible.com/u/Foss_Geek)\
**Post date:** [November 14, 2018, 8:05am UTC](https://forum.ansible.com/t/building-inventory-from-csv-file/29021/2 "2018-11-14T08:05:22Z")

</div>

> tasks:
> 
> - name: efine Values From CSV File  
> set\_fact:  
> tenant: "{{ lookup(‘csvfile’, ’ file=/root/ansible/tasks/csv-file/example.csv delimiter=, col=1’) }}

Your error seems due to missing closing double quote in the above line.

tenant: “{{ lookup(‘csvfile’, ’ file=/root/ansible/tasks/csv-file/example.csv delimiter=, col=1’) }}”
