How to create a big inventpry file in ansible

51 views
Skip to first unread message

parwinderjit singh

unread,
Nov 22, 2017, 8:52:00 PM11/22/17
to Ansible Project
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,

Kai Stian Olstad

unread,
Nov 23, 2017, 3:20:58 PM11/23/17
to ansible...@googlegroups.com
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


--
Kai Stian Olstad

Andrew Latham

unread,
Nov 23, 2017, 3:26:34 PM11/23/17
to ansible...@googlegroups.com

--
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 ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bee7bc7b-ca5c-4436-b12b-a5e5ae888271%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
- Andrew "lathama" Latham -

Larry Smith

unread,
Dec 2, 2017, 12:26:03 AM12/2/17
to Ansible Project
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.

parwinderjit singh

unread,
Dec 2, 2017, 2:39:18 AM12/2/17
to ansible...@googlegroups.com
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


--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/YzQCV3D5ZM4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-project+unsubscribe@googlegroups.com.

To post to this group, send email to ansible-project@googlegroups.com.
aaa.xlsx

Larry Smith

unread,
Dec 5, 2017, 12:17:36 AM12/5/17
to Ansible Project
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?


On Saturday, December 2, 2017 at 2:39:18 AM UTC-5, parwinderjit singh wrote:
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

On Sat, Dec 2, 2017 at 10:56 AM, Larry Smith <mrles...@gmail.com> wrote:
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.



On Wednesday, November 22, 2017 at 8:52:00 PM UTC-5, parwinderjit singh wrote:
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,

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/YzQCV3D5ZM4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages