Missing VM info when calling API through Ansible

crazyelectron-io

New Member
May 16, 2024
2
0
1
Running Proxmox 8.2 on 3 nodes (bare metal) and deploying everything with Ansible.
For some reason, it works fine for all VMs, except one. I deploy my VMs with Ansible using a Debian 12.5 genericcloud based template VM, except one VM that is deployed manually by cloning an Ubuntu 24.10 based template.

The Ansible playbook and roles worked fine before I created this VM but now the playbook stumbles across the following task:
YAML:
- name: Populate vminfo variable for VMs
  set_fact:
    vminfo: "{{ vminfo | default({}) | combine ({ item|json_query('proxmox_vms[].name')|first : item.proxmox_vms[0] }, recursive=true) }}"
  with_items: "{{ vm_info.results }}"
  run_once: true
  when: inventory_hostname == "arwen"

The purpose of this Ansible task is to extract the VM info in a way I can use in the follow-up tasks. It returns the proxmox VM info for all VMs based on the Debian template, but the info for the Ubuntu VM is empty as can be seen from this snippit of the extracted `vm_info.results`:
Code:
...
          {
                "ansible_loop_var": "item",
                "changed": false,
                "failed": false,
                "invocation": {
                    "module_args": {
                        "api_host": "10.0.0.6",
                        "api_password": null,
                        "api_token_id": "ansible_token",
                        "api_token_secret": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                        "api_user": "ansible_user@pam",
                        "config": "none",
                        "name": null,
                        "node": "legolas",
                        "type": "qemu",
                        "validate_certs": false,
                        "vmid": 2003
                    }
                },
                "item": "k3sprodw03",
                "proxmox_vms": [
                    {
                        "balloon_min": 1073741824,
                        "cpu": 0,
                        "cpus": 2,
                        "disk": 0,
                        "diskread": 0,
                        "diskwrite": 0,
                        "id": "qemu/2003",
                        "maxcpu": 2,
                        "maxdisk": 2147483648,
                        "maxmem": 2147483648,
                        "mem": 0,
                        "name": "k3sprodw03",
                        "netin": 0,
                        "netout": 0,
                        "node": "legolas",
                        "serial": 1,
                        "shares": 1000,
                        "status": "stopped",
                        "template": false,
                        "type": "qemu",
                        "uptime": 0,
                        "vmid": 2003
                    }
                ]
            },
            {
                "ansible_loop_var": "item",
                "changed": false,
                "failed": false,
                "invocation": {
                    "module_args": {
                        "api_host": "10.0.0.6",
                        "api_password": null,
                        "api_token_id": "ansible_token",
                        "api_token_secret": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                        "api_user": "ansible_user@pam",
                        "config": "none",
                        "name": null,
                        "node": "frodo",
                        "type": "qemu",
                        "validate_certs": false,
                        "vmid": 601
                    }
                },
                "item": "plexvm",
                "proxmox_vms": []
            },
...
The PVE API returns nothing for that one VM. What could cause this?

EDIT: tested with 2 other manually cloned VMs (one Debian and one Ubuntu 24.10) and they were picked up just fine by the `vminfo` task.
 
Last edited:
Ansible plugin is not developed by PVE, so you'd need to reach out to the author or debug on your own.

I'd start with running API directly, for example, via "pvesh" and comparing "good" and "bad" output to see if there is anything obvious that might be tripping the Ansible loop.

Good luck


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox