Update vmcreate1.sh
This commit is contained in:
16
vmcreate1.sh
16
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"
|
||||
|
||||
Reference in New Issue
Block a user