Building inventory from csv file

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

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’) }}”