Ansible Proxmox Vm Config

under Ansible Proxmox

 

Looking for a way to get Proxmox VM configuration in ansible? The community.general.proxmox_kvm module doesn’t have a qm config output, but you can use the Rest API to find out all current configuration.

    - name: Get VMID 101 config
      uri:
        url: https://{{ vm_host }}:8006/api2/json/nodes/{{ vm_host }}/qemu/{{ vm_id }}/config
        method: GET
        headers:
            Authorization: "PVEAPIToken={{ proxmox_api_user }}!{{ proxmox_api_token }}={{ proxmox_api_secret }}"
            Content-Type: "application/json"
        validate_certs: false
        register: vm_config

    - name: Debug config
      debug:
        var: vm_config.json.data

Filtering and inspecting is now done via the returned json response in the register variable.