From 05dc7fd3b57499dbc3ec2cec6b9d0fde7c75422e Mon Sep 17 00:00:00 2001 From: Dmitry Badovsky Date: Wed, 22 Oct 2025 19:46:54 +0000 Subject: [PATCH] Update vmcreate1.sh --- vmcreate1.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/vmcreate1.sh b/vmcreate1.sh index 394c54d..49adb10 100644 --- a/vmcreate1.sh +++ b/vmcreate1.sh @@ -32,6 +32,7 @@ embed_key(){ # } + while getopts "a:f:h" opt; do case $opt in a) haadd=true ;; @@ -41,7 +42,8 @@ while getopts "a:f:h" opt; do esac done -cat ./hosts | while read line + +cat $file | while read line do ip=$(echo $line | cut -d ' ' -f 1) hostname=$(echo $line | cut -d ' ' -f 2) @@ -60,13 +62,21 @@ do qm set $vmnum --ipconfig0 ip=$ip/24,gw=10.10.35.1 qm cloudinit update $vmnum qm start $vmnum -# ДОБАВИТЬ правило HA если $haadd + echo "VMs from $1 successfully created" + if [ haadd ] + then + ha-manager add vm:$vmnum --state started --max_relocate 2 + ha-manager rules add node-affinity gfx-rule --resources vm:$vmnum --nodes pve1,pve2,pve3 --strict 1 + # ОБЯЗАТЕЛЬНО ПРОВЕРИТЬ КОМАНДУ!!! + fi + echo "HA rules added" done + +# Финальная часть if [ -e hosts.tmp] then rm hosts.tmp fi -echo "VMs from 'hosts' successfully created" if [ -v $privkey ] then echo "Generated private key $privkey"