Build Ansible inventory based on server variables [closed]

The name of the pictureThe name of the pictureThe name of the pictureClash 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







share|improve this 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














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







share|improve this 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












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







share|improve this question











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









share|improve this question










share|improve this question




share|improve this question









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
















  • 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










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 "





share|improve this answer




























    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 "





    share|improve this answer

























      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 "





      share|improve this answer























        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 "





        share|improve this answer













        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 "






        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered May 16 at 12:47









        Patrick

        47.6k10125176




        47.6k10125176












            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay