fix(tooling): added missing steps to virtd reset task

This commit is contained in:
NaeiKinDus 2025-03-07 00:00:00 +00:00
parent 7342cf1c50
commit 75f18e2ac7
Signed by: WoodSmellParticle
GPG key ID: 8E52ADFF7CA8AE56
2 changed files with 15 additions and 2 deletions

View file

@ -70,12 +70,13 @@ tasks:
vars:
VIRSH_CONNECT: '{{.VIRSH_CONNECT | default "qemu:///system"}}'
cmds:
- ./scripts/purge_virsh.sh
- ./scripts/reset_virtd.sh
- task: 'molecule'
vars:
CLI_ARGS: 'destroy'
- sudo systemctl restart nftables.service
- sudo systemctl restart libvirtd.service
- sudo systemctl restart libvirtd.service # reset libvirtd related nft rules
- sudo systemctl restart docker.service # reset docker related nft rules
ansible:new:role:*:
desc: create a new role for the specified collection

12
scripts/reset_virtd.sh Normal file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
VIRSH_CONNECT="${VIRSH_CONNECT:=qemu:///system}"
VIRSH_VOL_POOL="${VIRSH_VOL_POOL:=default}"
for domain in $(virsh -c "${VIRSH_CONNECT}" list --name --all); do
virsh -c "${VIRSH_CONNECT}" destroy "${domain}" || true
virsh -c "${VIRSH_CONNECT}" undefine "${domain}" || true
done
for volume in $(virsh -c "${VIRSH_CONNECT}" vol-list --pool "${VIRSH_VOL_POOL}" | tail -n +3 | sed -E 's/^\s*([^\s]+)\s+.*$/\1/'); do
virsh -c "${VIRSH_CONNECT}" vol-delete --pool "${VIRSH_VOL_POOL}" "${volume}" || true
done