Create more hosts in one group using API

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

Any update on this?

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.

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.

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