1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

proxmox inventory: fix for agent enabled (#4910)

* Update proxmox.py

* Forgot a debug print.

* pep

* Check if int, old school way.

* pep, once again.

* Create 4910-fix-for-agent-enabled.yml

* Must check the first listentry for enabled=1

* Update changelogs/fragments/4910-fix-for-agent-enabled.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
ube 2022-07-12 11:03:13 +02:00 committed by GitHub
parent bf94f08bc4
commit aa03c71267
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 6 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- proxmox inventory plugin - fix crash when ``enabled=1`` is used in agent config string (https://github.com/ansible-collections/community.general/pull/4910).

View file

@ -412,8 +412,16 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
properties[parsed_key] = [tag.strip() for tag in stripped_value.split(",")] properties[parsed_key] = [tag.strip() for tag in stripped_value.split(",")]
# The first field in the agent string tells you whether the agent is enabled # The first field in the agent string tells you whether the agent is enabled
# the rest of the comma separated string is extra config for the agent # the rest of the comma separated string is extra config for the agent.
if config == 'agent' and int(value.split(',')[0]): # In some (newer versions of proxmox) instances it can be 'enabled=1'.
if config == 'agent':
agent_enabled = 0
try:
agent_enabled = int(value.split(',')[0])
except ValueError:
if value.split(',')[0] == "enabled=1":
agent_enabled = 1
if agent_enabled:
agent_iface_value = self._get_agent_network_interfaces(node, vmid, vmtype) agent_iface_value = self._get_agent_network_interfaces(node, vmid, vmtype)
if agent_iface_value: if agent_iface_value:
agent_iface_key = self.to_safe('%s%s' % (key, "_interfaces")) agent_iface_key = self.to_safe('%s%s' % (key, "_interfaces"))