Files
kubevirt.core/examples/play-stop.yml
Javier Cano Cano 0475a8d39b feat(kubevirt_vm): add state=start/stop/restart to manage VM lifecycle
It adds support for starting, stopping, and restarting VirtualMachines.
The operations are performed through the KubeVirt restart subresource
API (PUT to `subresources.kubevirt.io/v1`). These calls are extracted
into a single shared helper function `_call_subresource()` to handle the
common flow, i.e., check mode, API call and wait conditions.
Moreover, it adds the optional parameter  `grace_period_seconds` for
stop and start operations.

Additionally, it adds unit tests and integration tests for all
operations.

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Javier Cano Cano <jcanocan@redhat.com>
2026-06-08 15:37:43 +02:00

11 lines
219 B
YAML

---
- name: Playbook stopping a virtual machine
hosts: localhost
tasks:
- name: Stop VM
kubevirt.core.kubevirt_vm:
state: stopped
name: testvm
namespace: default
wait: true