Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxmox_kvm: Only show changed when something managed actually changes #9576

Open
1 task done
pgporada opened this issue Jan 15, 2025 · 3 comments
Open
1 task done
Labels
feature This issue/PR relates to a feature request module module plugins plugin (any type)

Comments

@pgporada
Copy link

pgporada commented Jan 15, 2025

Summary

When running ansible against my proxmox cluster, every VM managed by proxmox_kvm reports changes when realistically none should. I implementing a very janky config diff which shows that unmanageable results from the PVE API affect the proxmox_kvm module.

Here's my diff tool

- name: Check existing config
  community.general.proxmox_vm_info:
    api_host: "{{ proxmox_host }}"
    api_user: "{{ proxmox_user }}"
    api_token_id: "{{ proxmox_token_id }}"
    api_token_secret: "{{ proxmox_token_secret }}"
    node: "{{ groups.proxmox_nodes[0] }}"
    name: "{{ hostname }}"
    config: "current"
  register: current_config

# Pending changes indicate that we should restart a VM, but _not always_.
- name: Check for pending changes
  community.general.proxmox_vm_info:
    api_host: "{{ proxmox_host }}"
    api_user: "{{ proxmox_user }}"
    api_token_id: "{{ proxmox_token_id }}"
    api_token_secret: "{{ proxmox_token_secret }}"
    node: "{{ groups.proxmox_nodes[0] }}"
    name: "{{ hostname }}"
    config: "pending"
  register: pending_config

- name: Diff current vs pending
  ansible.utils.fact_diff:
    before: "{{ current_config | to_nice_yaml }}"
    after: "{{ pending_config | to_nice_yaml }}"

Versions of various relevant software I'm using.

$ ansible --version
ansible [core 2.14.16]

$ pip list | grep proxmoxer
proxmoxer          2.2.0

$ ansible-galaxy collection list | grep community.general
community.general 10.2.0

Issue Type

Feature Idea

Component Name

proxmox_kvm

Additional Information

TASK [proxmox/ansible-role-proxmox-manage-vm : Check existing config] ***********************************************************************************************************************
ok: [localhost]

TASK [proxmox/ansible-role-proxmox-manage-vm : Check for pending changes] *******************************************************************************************************************
ok: [localhost]

TASK [proxmox/ansible-role-proxmox-manage-vm : Diff current vs pending] *********************************************************************************************************************
--- before
+++ after
@@ -40,7 +40,7 @@
         vcpus: 4
         vga: serial0
         vmgenid: 2ae6c662-49e7-47fa-b9c0-4397c572854a
-    cpu: 0.00230293270089206
+    cpu: 0
     cpus: 4
     disk: 0
     diskread: 0
@@ -52,7 +52,7 @@
     mem: 177890429
     name: localhost.dev.mybox
     netin: 0
-    netout: 6050
+    netout: 6092
     node: pr0xch0pz
     pid: 616019
     serial: 1

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link
Collaborator

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
Copy link
Collaborator

@ansibullbot ansibullbot added feature This issue/PR relates to a feature request module module plugins plugin (any type) labels Jan 15, 2025
@russoz
Copy link
Collaborator

russoz commented Jan 18, 2025

Hi @pgporada thanks for reporting

Not all values returned by proxmox_vm_info are configurations, some of them are metrics, like cpu in your diff. It is obtained from:
https://pve.proxmox.com/pve-docs/api-viewer/index.html#/cluster/resources

The documentation of proxmox_vm_info could be more clear about this, but the evidence presented does not seem to point to a problem with proxmox_kvm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request module module plugins plugin (any type)
Projects
None yet
Development

No branches or pull requests

3 participants