Foreman ansible inventory is slow


I am using callback to call tower while server provisioning, i found when i call tower template it calls inventory and tries to get all the hosts and then list my new host in inventory, which is very slow process as i need my servers quickly build.

Is there any Option to make it faster or any other script i can use that only queries single server while provisioning with limited parameters.


@Unix_SA There are a few options to make the inventory faster.

I assume on your Tower server you have some file /etc/ansible/foreman.ini like .

Notice there are a few options that can make the inventory faster. Try disabling want_facts, want_hostcollections , rich_params and scan_new_hosts.

Also as you can see the inventory is cached, you can also define the age of the cache in the ini file.

Thanks @dLobatog, i have tried that but as i have more than 2000 hosts it makes it slow, to work around i have created inventory called “provision” on Tower and then while provisoning i am running API call to tower to add new host to that inventory (regularly clean inventory so it doesnt get huge)

Later i am running callback with extra vars to initiate post job

And for ongoing config i will continue using foreman inventory and run schedule sync.

Do you think approch ia good for initial provision of servers ?