[awx-project] Create more hosts in one group using API

55 views
Skip to first unread message

saravanan jothilingam

unread,
Mar 15, 2023, 1:37:06 PM3/15/23
to awx-p...@googlegroups.com
Hi All,
We have an AWX instance hosted on Ubuntu. We don't have access to the server and just the AWX UI access. Here I need to create an inventory with groups having more than 100+ servers. In the UI, using 'add newhost' options is taking a long time to add server by server.  Are there any API which will add those 100+ under one group. Could you please throw some light on this.

Note - We don't have access to AWX server to run awx-manage cli cmd to create the multiple servers in the inv file.

Thanks
Saravanan

saravanan jothilingam

unread,
Mar 16, 2023, 9:59:38 AM3/16/23
to awx-p...@googlegroups.com
Any update on this?

Ian Board

unread,
Mar 16, 2023, 10:37:55 AM3/16/23
to awx-p...@googlegroups.com
Without knowing how you are hosting the servers it is hard to give a specific solution. Have you checked out some of the built in functionality for creating dynamic inventories? Maybe start here https://docs.ansible.com/ansible-tower/latest/html/administration/scm-inv-source.html#inventory-file-importing. There are also inventory plugins that can do the heavy lifting for you too. 



--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/CAE7H9qqGM%2BDo-8UJF4htZ%2BOPoUMh_nJdWMxsD7v0Fxk5MohOoQ%40mail.gmail.com.



This email and any files transmitted with it contain confidential information and/or privileged or personal advice. This email is intended for the addressee(s) stated above only. If you are not the addressee of the email please do not copy or forward it or otherwise use it or any part of it in any form whatsoever. If you have received this email in error please notify the sender and remove the e-mail from your system. Thank you.

This is an email from the company Just Eat Takeaway.com N.V., a public limited liability company with corporate seat in Amsterdam, the Netherlands, and address at Piet Heinkade 61, 1019GM Amsterdam, registered with the Dutch Chamber of Commerce with number 08142836 and where the context requires, includes its subsidiaries and associated undertakings.

Michael Kelly

unread,
Mar 16, 2023, 11:59:21 AM3/16/23
to awx-p...@googlegroups.com
Assuming that you have your playbooks in a git repository somewhere, then, what you can do is use the repository to store your inventory file(s).
To access the file(s) do the following.
Create a new inventory and save it.
Click the Sources tab and click the Add button.
Give it a name and for Source, select 'Sourced from a Project'.
In the extra fields that appear, select the Project you are using and in the filename field enter a name which is relative to the project root in the repository.
All you need to do now is find a way to populate that file with the data you want.
Once you have data in the file, you can modify the template to use the new inventory.


AWX Project

unread,
Mar 17, 2023, 1:44:45 PM3/17/23
to AWX Project
using dynamic inventory is the recommended route for this use case

I'll also mention that we just added a Bulk Host create endpoint, which should land in the next AWX release https://github.com/ansible/awx/pull/13462

This will allow you to efficiently add many hosts to a single inventory in one API call

AWX Team
Reply all
Reply to author
Forward
0 new messages