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:
parent
bf94f08bc4
commit
aa03c71267
2 changed files with 16 additions and 6 deletions
2
changelogs/fragments/4910-fix-for-agent-enabled.yml
Normal file
2
changelogs/fragments/4910-fix-for-agent-enabled.yml
Normal 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).
|
|
@ -412,12 +412,20 @@ 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'.
|
||||||
agent_iface_value = self._get_agent_network_interfaces(node, vmid, vmtype)
|
if config == 'agent':
|
||||||
if agent_iface_value:
|
agent_enabled = 0
|
||||||
agent_iface_key = self.to_safe('%s%s' % (key, "_interfaces"))
|
try:
|
||||||
properties[agent_iface_key] = agent_iface_value
|
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)
|
||||||
|
if agent_iface_value:
|
||||||
|
agent_iface_key = self.to_safe('%s%s' % (key, "_interfaces"))
|
||||||
|
properties[agent_iface_key] = agent_iface_value
|
||||||
|
|
||||||
if config == 'lxc':
|
if config == 'lxc':
|
||||||
out_val = {}
|
out_val = {}
|
||||||
|
|
Loading…
Reference in a new issue