diff options
author | Etienne Deneuve <1010321+EtienneDeneuve@users.noreply.github.com> | 2018-08-09 11:00:17 +0200 |
---|---|---|
committer | Yunge Zhu <37337818+yungezz@users.noreply.github.com> | 2018-08-09 17:00:17 +0800 |
commit | 379fb87b44985df12988c9baae343cf8354ab9f5 (patch) | |
tree | eaf9c009c95c00d33d5d3201537680a5b7e84604 /contrib | |
parent | adc0efe10c5be833b5138e1d8b0d0316f87c5241 (diff) | |
download | ansible-379fb87b44985df12988c9baae343cf8354ab9f5.tar.gz |
add group_by_os_family in azure dynamic inventory (#40702)
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/inventory/azure_rm.ini | 1 | ||||
-rwxr-xr-x | contrib/inventory/azure_rm.py | 10 |
2 files changed, 10 insertions, 1 deletions
diff --git a/contrib/inventory/azure_rm.ini b/contrib/inventory/azure_rm.ini index 816da16532..6edd9b981b 100644 --- a/contrib/inventory/azure_rm.ini +++ b/contrib/inventory/azure_rm.ini @@ -19,4 +19,5 @@ include_powerstate=yes group_by_resource_group=yes group_by_location=yes group_by_security_group=yes +group_by_os_family=yes group_by_tag=yes diff --git a/contrib/inventory/azure_rm.py b/contrib/inventory/azure_rm.py index d68c83fae4..36ea938a6a 100755 --- a/contrib/inventory/azure_rm.py +++ b/contrib/inventory/azure_rm.py @@ -261,6 +261,7 @@ AZURE_CONFIG_SETTINGS = dict( group_by_location='AZURE_GROUP_BY_LOCATION', group_by_security_group='AZURE_GROUP_BY_SECURITY_GROUP', group_by_tag='AZURE_GROUP_BY_TAG', + group_by_os_family='AZURE_GROUP_BY_OS_FAMILY', use_private_ip='AZURE_USE_PRIVATE_IP' ) @@ -572,6 +573,7 @@ class AzureInventory(object): self.replace_dash_in_groups = False self.group_by_resource_group = True self.group_by_location = True + self.group_by_os_family = True self.group_by_security_group = True self.group_by_tag = True self.include_powerstate = True @@ -706,7 +708,7 @@ class AzureInventory(object): host_vars['os_disk'] = dict( name=machine.storage_profile.os_disk.name, - operating_system_type=machine.storage_profile.os_disk.os_type.value + operating_system_type=machine.storage_profile.os_disk.os_type.value.lower() ) if self.include_powerstate: @@ -811,10 +813,16 @@ class AzureInventory(object): host_name = self._to_safe(vars['name']) resource_group = self._to_safe(vars['resource_group']) + operating_system_type = self._to_safe(vars['os_disk']['operating_system_type'].lower()) security_group = None if vars.get('security_group'): security_group = self._to_safe(vars['security_group']) + if self.group_by_os_family: + if not self._inventory.get(operating_system_type): + self._inventory[operating_system_type] = [] + self._inventory[operating_system_type].append(host_name) + if self.group_by_resource_group: if not self._inventory.get(resource_group): self._inventory[resource_group] = [] |