--- # Under --check the module (no check mode support) does not run; the preview compares the status the # lookup in detect.yml read with the desired state. - name: Preview VM power state ansible.builtin.debug: msg: "VM {{ pve_vm_vmid }} is {{ __pve_vm_info.status | default('unknown') }}, desired {{ pve_vm_state }}" changed_when: >- (__pve_vm_info.status | default('unknown')) != ('running' if pve_vm_state == 'started' else 'stopped') when: ansible_check_mode - name: Ensure VM state no_log: true # defence in depth: the module already masks the API token secret delegate_to: "{{ pve_vm_delegate }}" community.proxmox.proxmox_kvm: node: "{{ pve_vm_node }}" vmid: "{{ pve_vm_vmid }}" state: "{{ pve_vm_state }}" when: not ansible_check_mode