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,
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
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/
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 (43.6 KB)
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?