Files
Kamino/roles/pve_vm/molecule/default/molecule.yml
T
Defame1297 f3cab37c7b
Build / build (pull_request) Successful in 46s
Lint / lint (pull_request) Successful in 2m57s
Molecule / molecule (pull_request) Successful in 30m40s
feat(pve_vm): add the pve_vm role
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
2026-11-29 20:10:33 +00:00

108 lines
3.7 KiB
YAML

---
# Runs on the repository's own runner (label kamino-molecule), in the molecule-ubuntu2404
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
# .gitea/workflows/molecule.yml. The containers stand in for the guest: the role's input
# validation and its drift detection over a seeded VM config run against them. Nothing calls the
# Proxmox API (README, Tests). The containers run systemd as PID 1 with a writable cgroup; no
# privileged mode.
driver:
name: docker
platforms:
- name: ${KAMINO_RUN_ID:-local}-pve-vm-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE}
pre_build_image: true
pull: true
command: /sbin/init
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /run
- /run/lock
security_opts:
- apparmor=unconfined
- name: ${KAMINO_RUN_ID:-local}-pve-vm-2604-instance
labels:
net.rkdr.mortis.molecule-run: "${KAMINO_RUN_ID:-local}"
image: ${MOLECULE_IMAGE_2604}
pre_build_image: true
pull: true
command: /sbin/init
cgroupns_mode: host
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:rw
tmpfs:
- /run
- /run/lock
security_opts:
- apparmor=unconfined
provisioner:
name: ansible
# One source for every play, so the converge, the drift cases and the negative tests in
# verify.yml start from the same valid input, which matches the seeded VM config of converge.yml.
inventory:
group_vars:
all:
pve_vm_node: pve-node
pve_vm_vmid: 9200
# The node is not an inventory host, from which the role defaults the API address;
# argument validation templates that default, so main would fail on it instead.
pve_vm_api_host: 192.0.2.1
pve_vm_api_user: molecule
pve_vm_api_token_secret: not-a-secret
# pve_vm_disk_size is set where a case needs it, so the refusal case can leave it undefined.
pve_vm_state: started
pve_vm_memory: 2048
pve_vm_cores: 2
pve_vm_sockets: 1
pve_vm_ci_user: ubuntu
pve_vm_sshkeys: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMoleculeTestKeyNotARealKey molecule
pve_vm_network:
net0:
model: virtio
bridge: vmbr0
tag: 20
firewall: true
pve_vm_ipconfig:
ipconfig0: ip=192.0.2.30/24,gw=192.0.2.1
pve_vm_nameservers:
- 192.0.2.53
- 198.51.100.53
# The live config the REST lookup would return, in Proxmox's own forms: agent with flags,
# ipconfig0 tokens reordered, sshkeys URL-encoded, nameservers space-separated.
pve_vm_test_config:
name: "{{ inventory_hostname | lower | replace('_', '-') }}"
cpu: host
memory: 2048
cores: 2
sockets: 1
ciuser: ubuntu
sshkeys: ssh-ed25519%20AAAAC3NzaC1lZDI1NTE5AAAAIMoleculeTestKeyNotARealKey%20molecule%0A
ipconfig0: gw=192.0.2.1,ip=192.0.2.30/24
nameserver: 192.0.2.53 198.51.100.53
onboot: 1
agent: fstrim_cloned_disks=1,enabled=1
net0: virtio=BC:24:11:00:00:01,bridge=vmbr0,firewall=1,tag=20
scsi0: local-lvm:vm-9200-disk-0,size=32G
verifier:
name: ansible
scenario:
# molecule's default sequence minus both destroys (scripts/run_molecule_scenarios.sh removes the
# containers as soon as this scenario ends; after a local run, run `molecule destroy` yourself),
# plus a check before the converge (fresh host) and one after it (converged host).
test_sequence:
- dependency
- cleanup
- syntax
- create
- prepare
- check
- converge
- check
- idempotence
- side_effect
- verify
- cleanup