mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* 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>
(cherry picked from commit d0bb74a03b
)
Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
This commit is contained in:
parent
46e221cbc6
commit
87000ae491
3 changed files with 19 additions and 2 deletions
5
changelogs/fragments/1949-proxmox-inventory-tags.yml
Normal file
5
changelogs/fragments/1949-proxmox-inventory-tags.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- proxmox inventory plugin - allowed proxomox tag string to contain commas when returned as fact (https://github.com/ansible-collections/community.general/pull/1949).
|
||||||
|
minor_changes:
|
||||||
|
- proxmox inventory plugin - added ``tags_parsed`` fact containing tags parsed as a list (https://github.com/ansible-collections/community.general/pull/1949).
|
|
@ -217,6 +217,10 @@ class InventoryModule(BaseInventoryPlugin, Cacheable):
|
||||||
vmtype_key = self.to_safe('%s%s' % (self.get_option('facts_prefix'), vmtype_key.lower()))
|
vmtype_key = self.to_safe('%s%s' % (self.get_option('facts_prefix'), vmtype_key.lower()))
|
||||||
self.inventory.set_variable(name, vmtype_key, vmtype)
|
self.inventory.set_variable(name, vmtype_key, vmtype)
|
||||||
|
|
||||||
|
plaintext_configs = [
|
||||||
|
'tags',
|
||||||
|
]
|
||||||
|
|
||||||
for config in ret:
|
for config in ret:
|
||||||
key = config
|
key = config
|
||||||
key = self.to_safe('%s%s' % (self.get_option('facts_prefix'), key.lower()))
|
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')):
|
if config == 'rootfs' or config.startswith(('virtio', 'sata', 'ide', 'scsi')):
|
||||||
value = ('disk_image=' + value)
|
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):
|
if not (isinstance(value, int) or ',' not in value):
|
||||||
# split off strings with commas to a dict
|
# split off strings with commas to a dict
|
||||||
# skip over any keys that cannot be processed
|
# skip over any keys that cannot be processed
|
||||||
|
|
|
@ -71,7 +71,8 @@ def get_json(url):
|
||||||
"status": "running",
|
"status": "running",
|
||||||
"vmid": "100",
|
"vmid": "100",
|
||||||
"disk": "1000",
|
"disk": "1000",
|
||||||
"uptime": 1000}]
|
"uptime": 1000,
|
||||||
|
"tags": "test, tags, here"}]
|
||||||
elif url == "https://localhost:8006/api2/json/nodes/testnode/qemu":
|
elif url == "https://localhost:8006/api2/json/nodes/testnode/qemu":
|
||||||
# _get_qemu_per_node
|
# _get_qemu_per_node
|
||||||
return [{"name": "test-qemu",
|
return [{"name": "test-qemu",
|
||||||
|
@ -105,7 +106,8 @@ def get_json(url):
|
||||||
"vmid": "9001",
|
"vmid": "9001",
|
||||||
"uptime": 0,
|
"uptime": 0,
|
||||||
"disk": 0,
|
"disk": 0,
|
||||||
"status": "stopped"}]
|
"status": "stopped",
|
||||||
|
"tags": "test, tags, here"}]
|
||||||
elif url == "https://localhost:8006/api2/json/pools/test":
|
elif url == "https://localhost:8006/api2/json/pools/test":
|
||||||
# _get_members_per_pool
|
# _get_members_per_pool
|
||||||
return {"members": [{"uptime": 1000,
|
return {"members": [{"uptime": 1000,
|
||||||
|
|
Loading…
Reference in a new issue