added autodeflate option
This commit is contained in:
parent
fa6de19f0f
commit
214070fd35
1 changed files with 31 additions and 35 deletions
|
@ -24,9 +24,11 @@ where:
|
||||||
-s subnet Subnet to place server on (default to 172.16.99.xx)
|
-s subnet Subnet to place server on (default to 172.16.99.xx)
|
||||||
-i ip_address Specify IP address to assign (default to next available in subnet)
|
-i ip_address Specify IP address to assign (default to next available in subnet)
|
||||||
-b branch Specify branch of build_ansible to use (defult prod)
|
-b branch Specify branch of build_ansible to use (defult prod)
|
||||||
-a attach Attach existing extra disk (use full path to disK, default none)"
|
-a attach Attach existing extra disk (use full path to disK, default none)
|
||||||
|
-d autodeflate Autodeflate memory on use - default true, avoid for ipa-server"
|
||||||
|
|
||||||
# process flags
|
# process flags
|
||||||
while getopts "h:n:c:r:d:v:p:m:s:i:b:" flag
|
while getopts "h:n:c:r:d:v:p:m:s:i:b:d:" flag
|
||||||
do
|
do
|
||||||
case "$flag" in
|
case "$flag" in
|
||||||
n) name=${OPTARG};;
|
n) name=${OPTARG};;
|
||||||
|
@ -40,6 +42,7 @@ do
|
||||||
i) ip=${OPTARG};dhcp_opts+=" -i $ip";;
|
i) ip=${OPTARG};dhcp_opts+=" -i $ip";;
|
||||||
b) branch=${OPTARG};;
|
b) branch=${OPTARG};;
|
||||||
a) attach=${OPTARG};;
|
a) attach=${OPTARG};;
|
||||||
|
d) deflate=${OPTARG};;
|
||||||
h) ;&
|
h) ;&
|
||||||
*) echo "$usage";exit;;
|
*) echo "$usage";exit;;
|
||||||
esac
|
esac
|
||||||
|
@ -63,53 +66,46 @@ img=`./shared_scripts/download_install_image.sh $variant`
|
||||||
# determine if extra disk should be attached
|
# determine if extra disk should be attached
|
||||||
if [ -n "$attach" ]; then attach="--disk ${attach},discard=unmap";fi
|
if [ -n "$attach" ]; then attach="--disk ${attach},discard=unmap";fi
|
||||||
|
|
||||||
case "$variant" in
|
#determine if deflate should be on
|
||||||
"archlinux")
|
if [ -n "$deflate" ]; then deflate="--memballoon model=virtio,autodeflate=on";else deflate="--memballoon model=virtio";fi
|
||||||
# create cloud-init - replace by grabbing these directly from git
|
|
||||||
mkdir -p /tmp/cloud-init
|
|
||||||
|
|
||||||
|
|
||||||
echo "#cloud-config
|
|
||||||
users:
|
|
||||||
- name: root
|
- name: root
|
||||||
ssh_authorized_keys:
|
ssh_authorized_keys:
|
||||||
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILG56T1k766Cru14kyXI8WXSJwlO2sVhmH6JeRWy+mfe root@host.actcur.com" > /tmp/cloud-init/user-data
|
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILG56T1k766Cru14kyXI8WXSJwlO2sVhmH6JeRWy+mfe root@host.actcur.com" > /tmp/cloud-init/user-data
|
||||||
|
|
||||||
|
# create new base VM
|
||||||
|
virt-install --name=$name --vcpus=$cpu --memory=$memory --disk path=$path,size=$root_disk,sparse=true,discard=unmap,bus=scsi ${attach} --os-variant=$variant --network bridge=br1,mac=$mac $deflate --cdrom=$img --graphics vnc --cloud-init user-data="/tmp/cloud-init/user-data" --autoconsole=none
|
||||||
|
|
||||||
# create new base VM
|
#wait until server is available
|
||||||
virt-install --name=$name --vcpus=$cpu --memory=$memory --disk path=$path,size=$root_disk,sparse=true,discard=unmap,bus=scsi ${attach} --os-variant=$variant --network bridge=br1,mac=$mac --memballoon model=virtio,autodeflate=on --cdrom=$img --graphics vnc --cloud-init user-data="/tmp/cloud-init/user-data" --autoconsole=none
|
echo "Waiting for server to be available"
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
sleep 1
|
||||||
|
ping -c 1 ${lname}.actcur.com 2>&1 > /dev/null
|
||||||
|
if [ $? -eq 0 ]; then break;fi
|
||||||
|
done
|
||||||
|
echo "server up, waiting for ssh"
|
||||||
|
|
||||||
#wait until server is available
|
sleep 30
|
||||||
echo "Waiting for server to be available"
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
sleep 1
|
|
||||||
ping -c 1 ${lname}.actcur.com 2>&1 > /dev/null
|
|
||||||
if [ $? -eq 0 ]; then break;fi
|
|
||||||
done
|
|
||||||
echo "server up, waiting for ssh"
|
|
||||||
|
|
||||||
sleep 30
|
sed "s/REPLACE_HOSTNAME/${lname}.actcur.com/g" ../base_files/user_configuration.json > /tmp/user_configuration.json
|
||||||
|
rs=$((root_disk*1024-206))
|
||||||
|
sed -i "s/REPLACE_SIZE/${rs}/g" /tmp/user_configuration.json
|
||||||
|
|
||||||
sed "s/REPLACE_HOSTNAME/${lname}.actcur.com/g" ../base_files/user_configuration.json > /tmp/user_configuration.json
|
ssh-keygen -R ${lname}.actcur.com
|
||||||
rs=$((root_disk*1024-206))
|
ssh-keyscan ${lname}.actcur.com | grep -v "#" | grep "ecdsa-sha2-nistp256" >> ~/.ssh/known_hosts
|
||||||
sed -i "s/REPLACE_SIZE/${rs}/g" /tmp/user_configuration.json
|
|
||||||
|
|
||||||
ssh-keygen -R ${lname}.actcur.com
|
scp -i $ssh_key_dir/id_arch_builder /tmp/user_configuration.json ${lname}.actcur.com:/tmp/user_configuration.json
|
||||||
ssh-keyscan ${lname}.actcur.com | grep -v "#" | grep "ecdsa-sha2-nistp256" >> ~/.ssh/known_hosts
|
ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "systemctl mask reflector.service; echo 'Server = https://pkg.actcur.com/repo/archlinux/\$repo/os/\$arch' > /etc/pacman.d/mirrorlist"
|
||||||
|
ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "archinstall --config /tmp/user_configuration.json --silent"
|
||||||
scp -i $ssh_key_dir/id_arch_builder /tmp/user_configuration.json ${lname}.actcur.com:/tmp/user_configuration.json
|
ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "ln -s /usr/lib/systemd/system/sshd.service /mnt/archinstall/etc/systemd/system/multi-user.target.wants/sshd.service"
|
||||||
ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "systemctl mask reflector.service; echo 'Server = https://pkg.actcur.com/repo/archlinux/\$repo/os/\$arch' > /etc/pacman.d/mirrorlist"
|
ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "cp -r /root/.ssh/ /mnt/archinstall/root/;reboot"
|
||||||
ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "archinstall --config /tmp/user_configuration.json --silent"
|
;;
|
||||||
ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "ln -s /usr/lib/systemd/system/sshd.service /mnt/archinstall/etc/systemd/system/multi-user.target.wants/sshd.service"
|
|
||||||
ssh -i $ssh_key_dir/id_arch_builder ${lname}.actcur.com "cp -r /root/.ssh/ /mnt/archinstall/root/;reboot"
|
|
||||||
;;
|
|
||||||
"alma")
|
"alma")
|
||||||
# set up kickstart file
|
# set up kickstart file
|
||||||
sed "s/REPLACE_HOSTNAME/${lname}.actcur.com/g" ../base_files/kickstart.cfg > /tmp/kickstart.cfg
|
sed "s/REPLACE_HOSTNAME/${lname}.actcur.com/g" ../base_files/kickstart.cfg > /tmp/kickstart.cfg
|
||||||
|
|
||||||
# create new VM
|
# create new VM
|
||||||
virt-install --name=$name --vcpus=$cpu --memory=$memory --disk path=$path,size=$root_disk,sparse=true,discard=unmap,bus=scsi --os-variant=almalinux9 --network bridge=br1,mac=$mac --memballoon model=virtio,autodeflate=on --location=$img --graphics vnc --initrd-inject /tmp/kickstart.cfg --extra-args "inst.ks=file:/kickstart.cfg" --autoconsole=none
|
virt-install --name=$name --vcpus=$cpu --memory=$memory --disk path=$path,size=$root_disk,sparse=true,discard=unmap,bus=scsi --os-variant=almalinux9 --network bridge=br1,mac=$mac $deflate --location=$img --graphics vnc --initrd-inject /tmp/kickstart.cfg --extra-args "inst.ks=file:/kickstart.cfg" --autoconsole=none
|
||||||
|
|
||||||
echo "server up, waiting for install to complete"
|
echo "server up, waiting for install to complete"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue