# How to create a big inventpry file in ansible

**URL:** <https://forum.ansible.com/t/how-to-create-a-big-inventpry-file-in-ansible/26112>\
**Category:** Ansible Project\
**Created:** [November 23, 2017, 1:52am UTC](https://forum.ansible.com/t/how-to-create-a-big-inventpry-file-in-ansible/26112 "2017-11-23T01:52:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![parwinderjit\_singh](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@parwinderjit\_singh](https://forum.ansible.com/u/parwinderjit_singh)\
**Post date:** [November 23, 2017, 1:52am UTC](https://forum.ansible.com/t/how-to-create-a-big-inventpry-file-in-ansible/26112/1 "2017-11-23T01:52:00Z")

</div>

Hi All,

I have a excel sheet which contain 1000 server hostname with there IP address. I have to create a ansible host file from that sheet. My question is, is there a east way to create a ansible host file or i have to manually create hostfile for all 100 server ?

Thanks & Regards,

---

<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:** [November 23, 2017, 8:20pm UTC](https://forum.ansible.com/t/how-to-create-a-big-inventpry-file-in-ansible/26112/2 "2017-11-23T20:20:13Z")

</div>

To my knowledge nothing like that comes with Ansible.  
But you could use ansible to create one.  
Ansible has a lookup plugins for csv[1] so if you save the sheet to a csv you could use that in combination with the template module.

[1] [https://docs.ansible.com/ansible/latest/playbooks\_lookups.html#the-csv-file-lookup](https://docs.ansible.com/ansible/latest/playbooks_lookups.html#the-csv-file-lookup)

---

<div class="post-metadata">

**Author:** ![Andrew\_Latham](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Andrew\_Latham](https://forum.ansible.com/u/Andrew_Latham)\
**Post date:** [November 23, 2017, 8:26pm UTC](https://forum.ansible.com/t/how-to-create-a-big-inventpry-file-in-ansible/26112/3 "2017-11-23T20:26:20Z")

</div>

Have a look at [http://docs.ansible.com/ansible/latest/dev\_guide/developing\_inventory.html](http://docs.ansible.com/ansible/latest/dev_guide/developing_inventory.html)

---

<div class="post-metadata">

**Author:** ![Larry\_Smith1](https://avatars.discourse-cdn.com/v4/letter/l/d26b3c/32.png) [@Larry\_Smith1](https://forum.ansible.com/u/Larry_Smith1)\
**Post date:** [December 2, 2017, 5:26am UTC](https://forum.ansible.com/t/how-to-create-a-big-inventpry-file-in-ansible/26112/4 "2017-12-02T05:26:02Z")

</div>

Not sure if you figured this out yet or not. But thought I would share with you how I was able to do this and it works really well. I do not use the CSV lookup as it didn’t seem to work how I needed it to (or I just couldn’t make it work) so I just used the file lookup.

[https://everythingshouldbevirtual.com/automation/ansible-parsing-csv-list-hosts-ip-hostnames-mac/](https://everythingshouldbevirtual.com/automation/ansible-parsing-csv-list-hosts-ip-hostnames-mac/)

---

<div class="post-metadata">

**Author:** ![parwinderjit\_singh](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@parwinderjit\_singh](https://forum.ansible.com/u/parwinderjit_singh)\
**Post date:** [December 2, 2017, 7:38am UTC](https://forum.ansible.com/t/how-to-create-a-big-inventpry-file-in-ansible/26112/5 "2017-12-02T07:38:58Z")

</div>

Hi Larry,

Can you help me out. I am attaching one excel file and i want to make my host file like below

[cloudera\_master]  
orion-RHEL-05 ansible\_ssh\_host=10.48.21.53 host\_fqdn=orion-RHEL-05  
orion-RHEL-06 ansible\_ssh\_host=10.48.21.54 host\_fqdn=orion-RHEL-06

[cloudera\_client]  
orion-RHEL-05 ansible\_ssh\_host=10.48.21.53 host\_fqdn=orion-RHEL-05  
orion-RHEL-06 ansible\_ssh\_host=10.48.21.54 host\_fqdn=orion-RHEL-06  
orion-RHEL-07 ansible\_ssh\_host=10.48.21.55 host\_fqdn=orion-RHEL-07  
orion-RHEL-08 ansible\_ssh\_host=10.48.21.56 host\_fqdn=orion-RHEL-08  
orion-RHEL-09 ansible\_ssh\_host=10.48.21.57 host\_fqdn=orion-RHEL-09

regards

parwinder

> **(attachments)**
>
> [aaa.xlsx](https://forum.ansible.com/uploads/short-url/4KdlnTWg28Op8NgxxpHGsOJcGQv.xlsx) (43.6 KB)

---

<div class="post-metadata">

**Author:** ![Larry\_Smith1](https://avatars.discourse-cdn.com/v4/letter/l/d26b3c/32.png) [@Larry\_Smith1](https://forum.ansible.com/u/Larry_Smith1)\
**Post date:** [December 5, 2017, 5:17am UTC](https://forum.ansible.com/t/how-to-create-a-big-inventpry-file-in-ansible/26112/6 "2017-12-05T05:17:36Z")

</div>

Have you been able to figure this out? I would be glad to help if needed. How are you determining which are the masters vs. clients? The first two in the list become masters or some other logic?
