mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* Initial commit
* Adding changelog fragment
* Applying initial review suggestions
(cherry picked from commit 111c5de550
)
Co-authored-by: Ajpantuso <ajpantuso@gmail.com>
This commit is contained in:
parent
754cd31195
commit
e3e25b60d3
3 changed files with 15 additions and 3 deletions
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- proxmox inventory plugin - fixed parsing failures when some cluster nodes are offline (https://github.com/ansible-collections/community.general/issues/2931).
|
|
@ -353,6 +353,9 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
||||||
if node['type'] == 'node':
|
if node['type'] == 'node':
|
||||||
self.inventory.add_child(nodes_group, node['node'])
|
self.inventory.add_child(nodes_group, node['node'])
|
||||||
|
|
||||||
|
if node['status'] == 'offline':
|
||||||
|
continue
|
||||||
|
|
||||||
# get node IP address
|
# get node IP address
|
||||||
ip = self._get_node_ip(node['node'])
|
ip = self._get_node_ip(node['node'])
|
||||||
self.inventory.set_variable(node['node'], 'ansible_host', ip)
|
self.inventory.set_variable(node['node'], 'ansible_host', ip)
|
||||||
|
|
|
@ -9,7 +9,6 @@ __metaclass__ = type
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from ansible.errors import AnsibleError, AnsibleParserError
|
|
||||||
from ansible.inventory.data import InventoryData
|
from ansible.inventory.data import InventoryData
|
||||||
from ansible_collections.community.general.plugins.inventory.proxmox import InventoryModule
|
from ansible_collections.community.general.plugins.inventory.proxmox import InventoryModule
|
||||||
|
|
||||||
|
@ -46,7 +45,12 @@ def get_json(url):
|
||||||
"disk": 1000,
|
"disk": 1000,
|
||||||
"maxmem": 1000,
|
"maxmem": 1000,
|
||||||
"uptime": 10000,
|
"uptime": 10000,
|
||||||
"level": ""}]
|
"level": ""},
|
||||||
|
{"type": "node",
|
||||||
|
"node": "testnode2",
|
||||||
|
"id": "node/testnode2",
|
||||||
|
"status": "offline",
|
||||||
|
"ssl_fingerprint": "yy"}]
|
||||||
elif url == "https://localhost:8006/api2/json/pools":
|
elif url == "https://localhost:8006/api2/json/pools":
|
||||||
# _get_pools
|
# _get_pools
|
||||||
return [{"poolid": "test"}]
|
return [{"poolid": "test"}]
|
||||||
|
@ -315,7 +319,6 @@ def test_populate(inventory, mocker):
|
||||||
host_qemu = inventory.inventory.get_host('test-qemu')
|
host_qemu = inventory.inventory.get_host('test-qemu')
|
||||||
host_qemu_template = inventory.inventory.get_host('test-qemu-template')
|
host_qemu_template = inventory.inventory.get_host('test-qemu-template')
|
||||||
host_lxc = inventory.inventory.get_host('test-lxc')
|
host_lxc = inventory.inventory.get_host('test-lxc')
|
||||||
host_node = inventory.inventory.get_host('testnode')
|
|
||||||
|
|
||||||
# check if qemu-test is in the proxmox_pool_test group
|
# check if qemu-test is in the proxmox_pool_test group
|
||||||
assert 'proxmox_pool_test' in inventory.inventory.groups
|
assert 'proxmox_pool_test' in inventory.inventory.groups
|
||||||
|
@ -331,3 +334,6 @@ def test_populate(inventory, mocker):
|
||||||
|
|
||||||
# check if qemu template is not present
|
# check if qemu template is not present
|
||||||
assert host_qemu_template is None
|
assert host_qemu_template is None
|
||||||
|
|
||||||
|
# check that offline node is in inventory
|
||||||
|
assert inventory.inventory.get_host('testnode2')
|
||||||
|
|
Loading…
Reference in a new issue