ngine-io / ansible-collection-cloudstack

CloudStack Ansible Collections
https://galaxy.ansible.com/ngine_io/cloudstack
GNU General Public License v3.0
21 stars 27 forks source link

Inventory plugin group by VPC #106

Open rvalle opened 2 years ago

rvalle commented 2 years ago

The inventory plugin documentation states that it is possible to filter instances by VPC,

However, it does not seem possible to group instances by VPC.

Is it possible?

rvalle commented 2 years ago

I think this is because the API allows to filter by VPC, but does not return VPC information in the instance, which seems odd.

rvalle commented 2 years ago

Without having this information returned by the API an implementation would be a very nasty workaround that would break the inventory plugin architecture. So, I have asked for that information returned by the API and then we will be able to cleanly implement in the inventory plugin:

https://github.com/apache/cloudstack/issues/6452

Meanwhile a viable workaround is to have 2 inventory files (using an inventory directory), one using the inventory plugin, and another using plain text to create supergroups like this:

[vpc:children]
net_tier1
net_tier2
net_tier3

[vpc2:children]
net_tier4
net_tier5
net_tier6

This would create 2 groups vpc and vpc2, that would include the hosts in the related tiers. For that to work first the inventory plugin must group by network like this:

keyed_groups:
  - prefix: net
    key: networks

Unfortunately this setup is only viable for few stable VPCs, as the tier to VPC supergroups file needs to be maintained manually.

rvalle commented 2 years ago

good news, https://github.com/apache/cloudstack/issues/6452 has been implemented and will be released in ACS 4.17.1 We will then be able to implement this in the Iventory Plugin.

rvalle commented 2 years ago

thanks @Pearl1594 for implementing this.