Build Ansible inventory based on server variables [closed]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Please help in building ansible inventory. I want to build ansible inventory and assign hosts to respective groups based on the values gathered from Clients.
Eg: Information of all the clients and their respective group will be
pushed to ansible server every night in the below format.
File Format
Hostgroup1,Hostname1
Hostgroup1,Hostname2
Hostgroup1,Hostname3
Hostgroup2,Hostname1
Hostgroup2,Hostname2
From the content of above file i need to create ansible inventory
ansible
closed as unclear what you're asking by Kiwy, Romeo Ninov, Jeff Schaller, G-Man, dr01 May 17 at 10:33
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |Â
up vote
0
down vote
favorite
Please help in building ansible inventory. I want to build ansible inventory and assign hosts to respective groups based on the values gathered from Clients.
Eg: Information of all the clients and their respective group will be
pushed to ansible server every night in the below format.
File Format
Hostgroup1,Hostname1
Hostgroup1,Hostname2
Hostgroup1,Hostname3
Hostgroup2,Hostname1
Hostgroup2,Hostname2
From the content of above file i need to create ansible inventory
ansible
closed as unclear what you're asking by Kiwy, Romeo Ninov, Jeff Schaller, G-Man, dr01 May 17 at 10:33
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
what have you tried ? what is the expected output ? Ansible work with Yaml put can accept other format.
â Kiwy
May 16 at 12:47
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Please help in building ansible inventory. I want to build ansible inventory and assign hosts to respective groups based on the values gathered from Clients.
Eg: Information of all the clients and their respective group will be
pushed to ansible server every night in the below format.
File Format
Hostgroup1,Hostname1
Hostgroup1,Hostname2
Hostgroup1,Hostname3
Hostgroup2,Hostname1
Hostgroup2,Hostname2
From the content of above file i need to create ansible inventory
ansible
Please help in building ansible inventory. I want to build ansible inventory and assign hosts to respective groups based on the values gathered from Clients.
Eg: Information of all the clients and their respective group will be
pushed to ansible server every night in the below format.
File Format
Hostgroup1,Hostname1
Hostgroup1,Hostname2
Hostgroup1,Hostname3
Hostgroup2,Hostname1
Hostgroup2,Hostname2
From the content of above file i need to create ansible inventory
ansible
asked May 16 at 12:05
upkar
1558
1558
closed as unclear what you're asking by Kiwy, Romeo Ninov, Jeff Schaller, G-Man, dr01 May 17 at 10:33
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Kiwy, Romeo Ninov, Jeff Schaller, G-Man, dr01 May 17 at 10:33
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
what have you tried ? what is the expected output ? Ansible work with Yaml put can accept other format.
â Kiwy
May 16 at 12:47
add a comment |Â
what have you tried ? what is the expected output ? Ansible work with Yaml put can accept other format.
â Kiwy
May 16 at 12:47
what have you tried ? what is the expected output ? Ansible work with Yaml put can accept other format.
â Kiwy
May 16 at 12:47
what have you tried ? what is the expected output ? Ansible work with Yaml put can accept other format.
â Kiwy
May 16 at 12:47
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
You have several options you can use here.
1) Write a script which takes those files and generates the "inventory file" format that ansible uses. Then run that script on a cron job or something after all the uploads take place.
2) Write a script which generates output format complying with the Ansible inventory JSON format, and use it as such: https://docs.ansible.com/ansible/2.5/plugins/inventory/script.html
3) Use the add_host
task type as the very first task in your playbook (with a localhost
host) with a loop to add the hosts.
add_host:
name: " item.hostname "
groups: " item.group "
with_items: " somehow inject your list here "
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
You have several options you can use here.
1) Write a script which takes those files and generates the "inventory file" format that ansible uses. Then run that script on a cron job or something after all the uploads take place.
2) Write a script which generates output format complying with the Ansible inventory JSON format, and use it as such: https://docs.ansible.com/ansible/2.5/plugins/inventory/script.html
3) Use the add_host
task type as the very first task in your playbook (with a localhost
host) with a loop to add the hosts.
add_host:
name: " item.hostname "
groups: " item.group "
with_items: " somehow inject your list here "
add a comment |Â
up vote
1
down vote
You have several options you can use here.
1) Write a script which takes those files and generates the "inventory file" format that ansible uses. Then run that script on a cron job or something after all the uploads take place.
2) Write a script which generates output format complying with the Ansible inventory JSON format, and use it as such: https://docs.ansible.com/ansible/2.5/plugins/inventory/script.html
3) Use the add_host
task type as the very first task in your playbook (with a localhost
host) with a loop to add the hosts.
add_host:
name: " item.hostname "
groups: " item.group "
with_items: " somehow inject your list here "
add a comment |Â
up vote
1
down vote
up vote
1
down vote
You have several options you can use here.
1) Write a script which takes those files and generates the "inventory file" format that ansible uses. Then run that script on a cron job or something after all the uploads take place.
2) Write a script which generates output format complying with the Ansible inventory JSON format, and use it as such: https://docs.ansible.com/ansible/2.5/plugins/inventory/script.html
3) Use the add_host
task type as the very first task in your playbook (with a localhost
host) with a loop to add the hosts.
add_host:
name: " item.hostname "
groups: " item.group "
with_items: " somehow inject your list here "
You have several options you can use here.
1) Write a script which takes those files and generates the "inventory file" format that ansible uses. Then run that script on a cron job or something after all the uploads take place.
2) Write a script which generates output format complying with the Ansible inventory JSON format, and use it as such: https://docs.ansible.com/ansible/2.5/plugins/inventory/script.html
3) Use the add_host
task type as the very first task in your playbook (with a localhost
host) with a loop to add the hosts.
add_host:
name: " item.hostname "
groups: " item.group "
with_items: " somehow inject your list here "
answered May 16 at 12:47
Patrick
47.6k10125176
47.6k10125176
add a comment |Â
add a comment |Â
what have you tried ? what is the expected output ? Ansible work with Yaml put can accept other format.
â Kiwy
May 16 at 12:47