awx-manage inventory_import no longer works

44 views
Skip to first unread message

Andrew Mulheirn

unread,
Nov 29, 2021, 12:47:07 PM11/29/21
to AWX Project
Hi all,

I hope someone can help me here.

I need to do a one-off import of 500 hosts into the AWX inventory.  When I tested this back in March, I was able to get a bash shell on the awx-web container going and run the command:

awx-manage inventory_import --inventory-name <inventory> --source hosts

This would take my hosts file and all the related host_vars files and put them in the inventory nicely.  After that, I was going to manually maintain the inventory since it doesn't change a lot.

I come to try to deploy this 9 months later, and it fails - complains that podman isn't in the container.   I see from this issue that apparently the containers aren't supposed to have pod man in them.

Can anyone give me a way of importing a large number of hosts into the inventory?   I thought aww-manage was the way to do this, and Tower documentation still refers to my method that worked back in March.

Many thanks,

Andrew

John Westcott

unread,
Nov 29, 2021, 5:48:02 PM11/29/21
to Andrew Mulheirn, AWX Project
What about using the awx.awx collection? Specifically the awx.awx.inventory(1) module to create the inventory and then awx.awx.host(2) module to pull the hosts into the inventory. If the hosts file is parsable you should be able to read it in and do a loop to make this happen in a playbook.



--
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/5ab655fb-364a-4d1a-90c1-7be77c1e59c2n%40googlegroups.com.

Andrew Mulheirn

unread,
Nov 30, 2021, 4:04:10 PM11/30/21
to AWX Project
Thanks for the ideas on that.  I had a similar one while I was eating my cornflakes this morning.  Sometimes a break is as good as a rest.   In the end, a colleague and I worked on a python script that put a JSON structure into the inventory via the API:

def create_host(
    hostname: str, mgmt_ip: str, model: str, serial: str, ipsec_endpoint: str
):
    data = {
        "hostname": hostname,
        "management_ip": mgmt_ip,
        "model": model,
        "serial": serial,
        "ipsec_endpoint": ipsec_endpoint,
    }
    result=requests.post("https://awx.test.com/api/v2/inventories/2/hosts/",headers={"Authorization":"Bearer <YOUR TOKEN>"},json={"name":hostname,"variables":json.dumps(data)},verify=False)


Seems to work.  Just makes me wonder why they've made the previous method using aww-manage inoperative.

Thanks again for taking time to reply.

Andrew
Reply all
Reply to author
Forward
0 new messages