mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 03:11:24 -07:00
Allow tags strings containing commas in proxmox inventory plug-in (#1949)
* Included explicit parsing for proxmox guest tags and updated corresponding unit test with tags key * Including changelog fragment for PR 1949 * Removed ellipsis from test Proxmox only permits periods when surrounded by alphanumeric characters * Corrected punctuation for changelog entry Co-authored-by: Felix Fontein <felix@fontein.de> * Allowing tags string to contain commas * Incorporated new parsed tags fact with bugfix * Correcting whitespace issues * Update changelogs/fragments/1949-proxmox-inventory-tags.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/inventory/proxmox.py Co-authored-by: Felix Fontein <felix@fontein.de> * Update changelogs/fragments/1949-proxmox-inventory-tags.yml Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
7452a53647
commit
d0bb74a03b
3 changed files with 19 additions and 2 deletions
|
@ -217,6 +217,10 @@ class InventoryModule(BaseInventoryPlugin, Cacheable):
|
|||
vmtype_key = self.to_safe('%s%s' % (self.get_option('facts_prefix'), vmtype_key.lower()))
|
||||
self.inventory.set_variable(name, vmtype_key, vmtype)
|
||||
|
||||
plaintext_configs = [
|
||||
'tags',
|
||||
]
|
||||
|
||||
for config in ret:
|
||||
key = config
|
||||
key = self.to_safe('%s%s' % (self.get_option('facts_prefix'), key.lower()))
|
||||
|
@ -226,6 +230,12 @@ class InventoryModule(BaseInventoryPlugin, Cacheable):
|
|||
if config == 'rootfs' or config.startswith(('virtio', 'sata', 'ide', 'scsi')):
|
||||
value = ('disk_image=' + value)
|
||||
|
||||
# Additional field containing parsed tags as list
|
||||
if config == 'tags':
|
||||
parsed_key = self.to_safe('%s%s' % (key, "_parsed"))
|
||||
parsed_value = [tag.strip() for tag in value.split(",")]
|
||||
self.inventory.set_variable(name, parsed_key, parsed_value)
|
||||
|
||||
if not (isinstance(value, int) or ',' not in value):
|
||||
# split off strings with commas to a dict
|
||||
# skip over any keys that cannot be processed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue