Complex Openstack Inventory – A Nightmare!

Complex Openstack Inventory – A Nightmare!


OpenStack is a powerful open-source cloud computing platform that allows organizations to build and manage private and public clouds. Deploying and managing an OpenStack environment can be a complex task, especially when it comes to managing the inventory of servers, networks, and services. OpenStack-Ansible is a deployment tool that simplifies the installation and management of OpenStack components. One of the essential tools included in OpenStack-Ansible is the‘ script, which helps manage your OpenStack inventory efficiently using Python scripts.

In this article, we will explore how to use the ‘’ script to manage your OpenStack inventory effectively, including adding and removing hosts, generating inventory files, and customizing your inventory configuration.


Before diving into the details of using the ‘’ script, you should have an OpenStack-Ansible deployment already set up and a basic understanding of Python scripting.

Understanding the Script

The ‘’ script is a Python tool that allows you to manipulate the OpenStack inventory used by OpenStack-Ansible. It provides a range of commands and options to perform various tasks related to your OpenStack inventory.

**Common Commands:**

1. ‘list’: List all the hosts in the current OpenStack inventory.
2. ‘add_host’: Add a new host to the inventory.
3. ‘remove_host’: Remove an existing host from the inventory.
4. generate’: Generate an inventory file from the current inventory data.

**Usage Example:**

To list all hosts in the current inventory, you can run the following command:

root@OpenStack-Pilot-SC:/opt/openstack-ansible# scripts/ list

Adding a Host

Adding a host to your OpenStack inventory is a straightforward process with the ‘’ script. You need to specify the necessary details for the new host, including its name, IP address, and SSH keys.

Here’s an example of how to add a host:

root@OpenStack-Pilot-SC:/opt/openstack-ansible# scripts/ add_host --name new-host --ip --key /path/to/ssh/key

This command will add a new host with the name “new-host” and the specified IP address and SSH key to your OpenStack inventory.

Removing a Host

If you need to decommission a host or remove it from your OpenStack environment, you can use the ‘remove_host’ command:

root@OpenStack-Pilot-SC:/opt/openstack-ansible# scripts/ -r infra1_ceph-nfs_container-14c4e85d
Success. . .
root@OpenStack-Pilot-SC:/opt/openstack-ansible# scripts/ -r infra2_ceph-nfs_container-16400dab
Success. . .
root@OpenStack-Pilot-SC:/opt/openstack-ansible# scripts/ -r infra3_ceph-nfs_container-9ce1fbf4
Success. . .

Replace “old-host” with the name of the host you want to remove from the inventory.

Generating Inventory Files

The ‘generate’ command allows you to generate inventory files from the current inventory data. This is particularly useful when you want to update your inventory configuration or create customized inventory files.

To generate inventory files, use the following command:

root@OpenStack-Pilot-SC:/opt/openstack-ansible# scripts/ generate

By default, this command will create inventory files in the ‘openstack_inventory’ directory within your OpenStack-Ansible deployment.

Customizing Inventory Configuration

The ‘‘ script also supports various options and configurations to customize your inventory. You can specify inventory file locations, customize groups and variables, and more.

root@OpenStack-Pilot-SC:/opt/openstack-ansible# scripts/ -g
| container_name                               | groups                                                                                                                                              |
| infra1_aodh_container-2839823e               | aodh_alarm_evaluator, aodh_alarm_notifier, aodh_api, aodh_container, aodh_listener, infra1-host_containers, metering-alarm_all                      |
| infra1_ceilometer_central_container-8f51d105 | ceilometer_agent_central, ceilometer_agent_notification, ceilometer_central_container, infra1-host_containers, metering-infra_all                   |
| infra1_ceph-mds_container-fa6e45d1           | ceph-mds, ceph-mds_all, ceph-mds_container, infra1-host_containers                                                                                  |
| infra1_ceph-mon_container-13a9433c           | ceph-mon, ceph-mon_all, ceph-mon_container, infra1-host_containers                                                                                  |
| infra1_ceph-nfs_container-14c4e85d           | ceph-nfs, ceph-nfs_all, ceph-nfs_container, infra1-host_containers                                                                                  |
| infra1_cinder_api_container-73944841         | cinder_api, cinder_api_container, cinder_scheduler, infra1-host_containers, storage-infra_all                                                       |
| infra1_galera_container-38399307             | galera, galera_container, infra1-host_containers, shared-infra_all                                                                                  |
| infra1_glance_container-69b6373b             | glance_api, glance_container, image_all, infra1-host_containers                                                                                     |
| infra1_gnocchi_container-754ac985            | gnocchi_api, gnocchi_container, gnocchi_metricd, infra1-host_containers, metrics_all                                                                |
| infra1_heat_api_container-9bf10c7e           | heat_api, heat_api_cfn, heat_api_container, heat_engine, infra1-host_containers, orchestration_all                                                  |
| infra1_horizon_container-85a33644            | dashboard_all, horizon, horizon_container, infra1-host_containers                                                                                   |
| infra1_keystone_container-0c3bf6a3           | identity_all, infra1-host_containers, keystone, keystone_container                                                                                  |
| infra1_manila_container-83fa25be             | infra1-host_containers, manila-infra_all, manila_api, manila_container, manila_scheduler                                                            |
| infra1_memcached_container-7d9b20a8          | infra1-host_containers, memcached, memcached_container, shared-infra_all                                                                            |
| infra1_neutron_server_container-418832ac     | infra1-host_containers, network_all, neutron_server, neutron_server_container, opendaylight                                                         |
| infra1_nova_api_container-d5434b99           | compute-infra_all, infra1-host_containers, nova_api_container, nova_api_metadata, nova_api_os_compute, nova_conductor, nova_console, nova_scheduler |
| infra1_placement_container-2c2c092e          | infra1-host_containers, placement-infra_all, placement_api, placement_container                                                                     |
| infra1_rabbit_mq_container-75d927bb          | infra1-host_containers, rabbit_mq_container, rabbitmq, shared-infra_all                                                                             |
| infra1_repo_container-3909c34f               | infra1-host_containers, pkg_repo, repo-infra_all, repo_container                                                                                    |
| infra1_utility_container-2e7aca6c            | infra1-host_containers, shared-infra_all, utility, utility_container                                                                                |
| infra2_aodh_container-a5d23402               | aodh_alarm_evaluator, aodh_alarm_notifier, aodh_api, aodh_container, aodh_listener, infra2-host_containers, metering-alarm_all                      |
| infra2_ceilometer_central_container-719c29c4 | ceilometer_agent_central, ceilometer_agent_notification, ceilometer_central_container, infra2-host_containers, metering-infra_all                   |
| infra2_ceph-mds_container-58fc36bb           | ceph-mds, ceph-mds_all, ceph-mds_container, infra2-host_containers                                                                                  |
| infra2_ceph-mon_container-2c1aa99a           | ceph-mon, ceph-mon_all, ceph-mon_container, infra2-host_containers                                                                                  |
| infra2_ceph-nfs_container-16400dab           | ceph-nfs, ceph-nfs_all, ceph-nfs_container, infra2-host_containers                                                                                  |
| infra2_cinder_api_container-d12d18b2         | cinder_api, cinder_api_container, cinder_scheduler, infra2-host_containers, storage-infra_all                                                       |
| infra2_galera_container-491cdb86             | galera, galera_container, infra2-host_containers, shared-infra_all                                                                                  |
| infra2_glance_container-b825e0a7             | glance_api, glance_container, image_all, infra2-host_containers                                                                                     |
| infra2_gnocchi_container-a547f64c            | gnocchi_api, gnocchi_container, gnocchi_metricd, infra2-host_containers, metrics_all                                                                |
| infra2_heat_api_container-f5e2623f           | heat_api, heat_api_cfn, heat_api_container, heat_engine, infra2-host_containers, orchestration_all                                                  |
| infra2_horizon_container-7ae50899            | dashboard_all, horizon, horizon_container, infra2-host_containers                                                                                   |
| infra2_keystone_container-afc5f877           | identity_all, infra2-host_containers, keystone, keystone_container                                                                                  |
| infra2_manila_container-6920fa5b             | infra2-host_containers, manila-infra_all, manila_api, manila_container, manila_scheduler                                                            |
| infra2_memcached_container-ef3f2b63          | infra2-host_containers, memcached, memcached_container, shared-infra_all                                                                            |
| infra2_neutron_server_container-7e6f5512     | infra2-host_containers, network_all, neutron_server, neutron_server_container, opendaylight                                                         |
| infra2_nova_api_container-87e9d41f           | compute-infra_all, infra2-host_containers, nova_api_container, nova_api_metadata, nova_api_os_compute, nova_conductor, nova_console, nova_scheduler |
| infra2_placement_container-36b12a62          | infra2-host_containers, placement-infra_all, placement_api, placement_container                                                                     |
| infra2_rabbit_mq_container-d56bc302          | infra2-host_containers, rabbit_mq_container, rabbitmq, shared-infra_all                                                                             |
| infra2_repo_container-0b06410e               | infra2-host_containers, pkg_repo, repo-infra_all, repo_container                                                                                    |
| infra2_utility_container-d2d026d0            | infra2-host_containers, shared-infra_all, utility, utility_container                                                                                |
| infra3_aodh_container-cb417883               | aodh_alarm_evaluator, aodh_alarm_notifier, aodh_api, aodh_container, aodh_listener, infra3-host_containers, metering-alarm_all                      |
| infra3_ceilometer_central_container-a1116bc9 | ceilometer_agent_central, ceilometer_agent_notification, ceilometer_central_container, infra3-host_containers, metering-infra_all                   |
| infra3_ceph-mds_container-74a60179           | ceph-mds, ceph-mds_all, ceph-mds_container, infra3-host_containers                                                                                  |
| infra3_ceph-mon_container-c047c39d           | ceph-mon, ceph-mon_all, ceph-mon_container, infra3-host_containers                                                                                  |
| infra3_ceph-nfs_container-9ce1fbf4           | ceph-nfs, ceph-nfs_all, ceph-nfs_container, infra3-host_containers                                                                                  |
| infra3_cinder_api_container-42ee49fd         | cinder_api, cinder_api_container, cinder_scheduler, infra3-host_containers, storage-infra_all                                                       |
| infra3_galera_container-a14d1a73             | galera, galera_container, infra3-host_containers, shared-infra_all                                                                                  |
| infra3_glance_container-a43b7b31             | glance_api, glance_container, image_all, infra3-host_containers                                                                                     |
| infra3_gnocchi_container-fa4f1955            | gnocchi_api, gnocchi_container, gnocchi_metricd, infra3-host_containers, metrics_all                                                                |
| infra3_heat_api_container-a40ad3fc           | heat_api, heat_api_cfn, heat_api_container, heat_engine, infra3-host_containers, orchestration_all                                                  |
| infra3_horizon_container-7ed5740f            | dashboard_all, horizon, horizon_container, infra3-host_containers                                                                                   |
| infra3_keystone_container-b666aaa1           | identity_all, infra3-host_containers, keystone, keystone_container                                                                                  |
| infra3_manila_container-5a1255e4             | infra3-host_containers, manila-infra_all, manila_api, manila_container, manila_scheduler                                                            |
| infra3_memcached_container-9e95d73c          | infra3-host_containers, memcached, memcached_container, shared-infra_all                                                                            |
| infra3_neutron_server_container-483229af     | infra3-host_containers, network_all, neutron_server, neutron_server_container, opendaylight                                                         |
| infra3_nova_api_container-94ba6606           | compute-infra_all, infra3-host_containers, nova_api_container, nova_api_metadata, nova_api_os_compute, nova_conductor, nova_console, nova_scheduler |
| infra3_placement_container-e19e99af          | infra3-host_containers, placement-infra_all, placement_api, placement_container                                                                     |
| infra3_rabbit_mq_container-b11d2b7b          | infra3-host_containers, rabbit_mq_container, rabbitmq, shared-infra_all                                                                             |
| infra3_repo_container-884fe2b7               | infra3-host_containers, pkg_repo, repo-infra_all, repo_container                                                                                    |
| infra3_utility_container-72ce91d8            | infra3-host_containers, shared-infra_all, utility, utility_container                                                                                |
| log1_rsyslog_container-a9507ac1              | log1-host_containers, log_all, rsyslog, rsyslog_container                                                                                           |

The above output shows many logical groups of inventory hosts according to their respective roles. We can just try using the Ansible ping module to verify if the role/group names listed are valid.

root@OpenStack-Pilot-SC:/opt/openstack-ansible# ansible ceph-nfs_all -m ping
Variable files: "-e @/etc/openstack_deploy/user_secrets.yml -e @/etc/openstack_deploy/user_variables.yml "
[WARNING]: Unable to parse /etc/openstack_deploy/inventory.ini as an inventory source
infra1 | SUCCESS => {
"changed": false,
"ping": "pong"
infra1_ceph-nfs_container-14c4e85d | SUCCESS => {
"changed": false,
"ping": "pong"
infra2 | SUCCESS => {
"changed": false,
"ping": "pong"
infra2_ceph-nfs_container-16400dab | SUCCESS => {
"changed": false,
"ping": "pong"
infra3 | SUCCESS => {
"changed": false,
"ping": "pong"
infra3_ceph-nfs_container-9ce1fbf4 | SUCCESS => {
"changed": false,
"ping": "pong"


Managing an OpenStack inventory is a crucial aspect of deploying and maintaining an OpenStack environment. The ‘’ script provided by OpenStack-Ansible simplifies this process, allowing you to add and remove hosts, generate inventory files, and customize your inventory configuration with ease.

By leveraging the power of Python scripting and the flexibility of the ‘’ script, you can streamline your OpenStack inventory management tasks and ensure that your cloud infrastructure remains efficient and up-to-date.



logo web transparent 1

Pinakastra is an organization committed to making cloud computing infrastructure more accessible to enterprises, academia & research organizations by helping them in IT infrastructure consolidation through the Pinakastra™ cloud platform.



The post Complex Openstack Inventory – A Nightmare! appeared first on Superuser.

OpenStack Public Cloud