feat(proxmox): automatic vm creation

Signed-off-by: Tuan-Dat Tran <tuan-dat.tran@tudattr.dev>
This commit is contained in:
Tuan-Dat Tran
2025-04-26 21:58:58 +02:00
parent 0e8e07ed3e
commit f2ea03bc01
27 changed files with 247 additions and 90 deletions

View File

@@ -0,0 +1,30 @@
---
- name: Gather info about VM
community.general.proxmox_vm_info:
api_user: root@pam
api_password: "{{ vault.pve.aya01.root.sudo }}"
api_host: "192.168.20.12"
vmid: "{{ vm.vmid }}"
register: vm_info
- name: Stop VM
community.general.proxmox_kvm:
api_user: root@pam
api_password: "{{ vault.pve.aya01.root.sudo }}"
api_host: "192.168.20.12"
node: "{{ vm.node }}"
vmid: "{{ vm.vmid }}"
state: stopped
force: true
when: vm_info.proxmox_vms | length > 0
- name: Destroy VM
community.general.proxmox_kvm:
api_user: root@pam
api_password: "{{ vault.pve.aya01.root.sudo }}"
api_host: "192.168.20.12"
node: "{{ vm.node }}"
vmid: "{{ vm.vmid }}"
state: absent
force: true
when: vm_info.proxmox_vms | length > 0