Manage a Proxmox VE QEMU VM through the Proxmox API: clone from a template, cloud-init user, SSH keys and network, update only on detected drift, grow the boot disk, apply the power state, wait for SSH and cloud-init, and delete behind pve_vm_allow_destroy. The role never sets a cloud-init password and deletes a stored one with no_log. Inputs are validated first under the always tag: the API credentials, and pve_vm_disk_size while the disk is managed; the clone asserts pve_vm_clone_vmid. Only pve_vm_exists is public, every other fact and register is __pve_vm_. The molecule scenario runs offline on noble and resolute: validation with positive and refusal cases, drift detection over seeded VM configs, and static checks over the role's task files that no proxmox_kvm task or module_defaults entry carries cipassword and that the one task deleting a stored cipassword is no_log. The API lifecycle and the cloud-init wait are not exercised. README Roadmap: the pve_vm wave 2 line and the opnsense and proxmox_firewall line are removed; wave 3 stays. Closes #482 Assisted-by: Claude Code:claude-opus-5-5
29 lines
1.2 KiB
YAML
29 lines
1.2 KiB
YAML
---
|
|
# The input rules the argument spec cannot express. main.yml imports this file under
|
|
# tags: always, before any change; each assert keeps the condition under which its input is read.
|
|
|
|
# Every run calls the API: even pve_vm_state absent without pve_vm_allow_destroy looks the VM up.
|
|
- name: Assert the Proxmox API credentials are set
|
|
ansible.builtin.assert:
|
|
that:
|
|
- pve_vm_api_user | length > 0
|
|
- pve_vm_api_token_secret is defined and pve_vm_api_token_secret | length > 0
|
|
fail_msg: >-
|
|
The Proxmox API calls need pve_vm_api_user (bare user name, the role appends
|
|
@<pve_vm_api_realm>) and pve_vm_api_token_secret (normally vaulted). Neither has a usable
|
|
default: set them in the inventory.
|
|
quiet: true
|
|
|
|
# The update reads the resize flag, which is only computed while pve_vm_disk_size is defined.
|
|
- name: Assert the boot disk size is set while the disk is managed
|
|
ansible.builtin.assert:
|
|
that:
|
|
- pve_vm_disk_size is defined
|
|
fail_msg: >-
|
|
pve_vm_disk_size (for example 32G) must be set while pve_vm_manage_disk is true, the default.
|
|
Set pve_vm_manage_disk to false to leave the boot disk alone.
|
|
quiet: true
|
|
when:
|
|
- pve_vm_manage_disk | bool
|
|
- pve_vm_state != "absent"
|