ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
787 stars 1.45k forks source link

Proxmox inventory plugin: Groups are empty if VMs have more than 1 tag #8036

Open zenhighzer opened 4 months ago

zenhighzer commented 4 months ago

Summary

When I try to build my ansible inventory via. proxmox inventory plugin the groups are empty when a machine has more than 1 tag:

my proxmox-machines and their tags i.e.:

lb01: loadbalancer, stack lb02: loadbalaner, stack k8scp1: controlplane, stack k8scp2: controlplane, stack k8scp3: controlplane, stack k8swk1: worker, stack k8swk2: worker, stack k8swk2: worker, stack

My Inventory-Plugin looks like:

plugin: community.general.proxmox
url: https://proxmox:8006/
user: myuser@pam
password: secretpassword
validate_certs: false
want_facts: true
groups:
  k8s_loadbalancer: "'loadbalancer' in (proxmox_tags_parsed|list)"
  k8s_controlplane: "'controlplane' in (proxmox_tags_parsed|list)"
  k8s_worker: "'worker' in (proxmox_tags_parsed|list)" 
  k8s_stack: "'stack' in (proxmox_tags_parsed|list)"
want_proxmox_nodes_ansible_host: true

Issue Type

Bug Report

Component Name

proxmox inventory

Ansible Version

$ ansible --version

ansible [core 2.16.4]
  config file = None
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/.local/lib/python3.10/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/.local/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/usr/bin/python3)
  jinja version = 3.0.3
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general

# /home/user/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 6.0.1  

# /home/user/.local/lib/python3.10/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 8.3.0  

Configuration

$ ansible-config dump --only-changed
CONFIG_FILE() = None

OS / Environment

Ansible running on Ubuntu 22.04.4 LTS Proxmox Version: 8.1.4

Steps to Reproduce

1) giving machines more then 1 tag and then run inventory -> result: empty groups
2) giving machines only one tag -> result: groups with machines created successfully

plugin: community.general.proxmox
url: https://proxmox:8006/
user: myuser@pam
password: secretpassword
validate_certs: false
want_facts: true
groups:
  k8s_loadbalancer: "'loadbalancer' in (proxmox_tags_parsed|list)"
  k8s_controlplane: "'controlplane' in (proxmox_tags_parsed|list)"
  k8s_worker: "'worker' in (proxmox_tags_parsed|list)" 
  k8s_stack: "'stack' in (proxmox_tags_parsed|list)"
want_proxmox_nodes_ansible_host: true

Expected Results

I expect to have four groups:

k8s_loadbalancer: lb01, lb02 k8s_controlplane: k8scp1, k8scp2, k8scp3 k8s_worker: k8swk1, k8swk2, k8swk3 k8s_stack: lb01, lb02, k8scp1, k8scp2, k8scp3, k8swk1, k8swk2, k8swk3

Actual Results


$ansible-inventory -i my.proxmox.yml --list 

....  redacted , .... 

         "k8scp1": {
        "proxmox_tags": "controlplane;stack",
                "proxmox_tags_parsed": [
                    "controlplane;stack"
                ],

Code of Conduct

ansibullbot commented 4 months ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 4 months ago

cc @Ajpantuso @Thulium-Drake @ilijamt @joshainglis @karmab @krauthosting click here for bot help