mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Make a COLLINS['SOMETHING'] variable instead of ATTRIBS['0']['SOMETHING']
This commit is contained in:
parent
8f06ba2bc1
commit
cc4c70120a
1 changed files with 7 additions and 3 deletions
|
@ -41,7 +41,9 @@ that will be used instead of the configured values if they are set:
|
||||||
If errors are encountered during operation, this script will return an exit code of
|
If errors are encountered during operation, this script will return an exit code of
|
||||||
255; otherwise, it will return an exit code of 0.
|
255; otherwise, it will return an exit code of 0.
|
||||||
|
|
||||||
Tested against Ansible 1.6.6 and Collins 1.2.4.
|
Collins attributes are accessable as variables in ansible via the COLLINS['attribute_name'].
|
||||||
|
|
||||||
|
Tested against Ansible 1.8.2 and Collins 1.3.0.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# (c) 2014, Steve Salevan <steve.salevan@gmail.com>
|
# (c) 2014, Steve Salevan <steve.salevan@gmail.com>
|
||||||
|
@ -305,6 +307,8 @@ class CollinsInventory(object):
|
||||||
else:
|
else:
|
||||||
ip_index = self.ip_address_index
|
ip_index = self.ip_address_index
|
||||||
|
|
||||||
|
asset['COLLINS'] = {}
|
||||||
|
|
||||||
# Attempts to locate the asset's primary identifier (hostname or IP address),
|
# Attempts to locate the asset's primary identifier (hostname or IP address),
|
||||||
# which will be used to index the asset throughout the Ansible inventory.
|
# which will be used to index the asset throughout the Ansible inventory.
|
||||||
if self.prefer_hostnames and self._asset_has_attribute(asset, 'HOSTNAME'):
|
if self.prefer_hostnames and self._asset_has_attribute(asset, 'HOSTNAME'):
|
||||||
|
@ -332,8 +336,8 @@ class CollinsInventory(object):
|
||||||
if 'ATTRIBS' in asset:
|
if 'ATTRIBS' in asset:
|
||||||
for attrib_block in asset['ATTRIBS'].keys():
|
for attrib_block in asset['ATTRIBS'].keys():
|
||||||
for attrib in asset['ATTRIBS'][attrib_block].keys():
|
for attrib in asset['ATTRIBS'][attrib_block].keys():
|
||||||
attrib_key = self.to_safe(
|
asset['COLLINS'][attrib] = asset['ATTRIBS'][attrib_block][attrib]
|
||||||
'%s-%s' % (attrib, asset['ATTRIBS'][attrib_block][attrib]))
|
attrib_key = self.to_safe('%s-%s' % (attrib, asset['ATTRIBS'][attrib_block][attrib]))
|
||||||
self.push(self.inventory, attrib_key, asset_identifier)
|
self.push(self.inventory, attrib_key, asset_identifier)
|
||||||
|
|
||||||
# Indexes asset by all built-in Collins attributes.
|
# Indexes asset by all built-in Collins attributes.
|
||||||
|
|
Loading…
Reference in a new issue