mirror of
https://github.com/RogerSik/proxmox-vm-template.git
synced 2024-11-24 01:10:28 +01:00
first commit added
Signed-off-by: Roger Sikorski <roger@sikorski.cloud>
This commit is contained in:
parent
73e651b873
commit
7e705dae92
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
ssh-keys.pub
|
1
README.md
Normal file
1
README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
A simple script to download and a create a cloud init ready Ubuntu LTS vm.
|
0
ssh-keys.pub.dist
Normal file
0
ssh-keys.pub.dist
Normal file
46
ubuntu-lts.sh
Normal file
46
ubuntu-lts.sh
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
CURL_LAST_LTS_RELEASE=$(curl -s https://changelogs.ubuntu.com/meta-release-lts | grep Dist: | tail -n1)
|
||||||
|
LAST_LTS_RELEASE=${CURL_LAST_LTS_RELEASE:6}
|
||||||
|
|
||||||
|
if [ "$EUID" -ne 0 ]; then
|
||||||
|
echo "Please run as root"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "ssh-keys.pub" ]; then
|
||||||
|
echo "Warning ssh-keys.pub doesn't exists"
|
||||||
|
echo "Will abort now"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "VM ID"
|
||||||
|
read -r VM_ID
|
||||||
|
echo "VM Name?"
|
||||||
|
read -r VM_NAME
|
||||||
|
|
||||||
|
echo "Image download"
|
||||||
|
wget https://cloud-images.ubuntu.com/"$LAST_LTS_RELEASE"/current/"$LAST_LTS_RELEASE-server-cloudimg-amd64.img"
|
||||||
|
apt install libguestfs-tools -y
|
||||||
|
|
||||||
|
echo "Install qemu-guest-agent on Ubuntu image"
|
||||||
|
virt-customize -a "$LAST_LTS_RELEASE-server-cloudimg-amd64.img" --install qemu-guest-agent
|
||||||
|
|
||||||
|
echo "Create Proxmox VM image from Ubuntu Cloud Image"
|
||||||
|
qm create "$VM_ID" --memory 1024 --balloon 0 --cores 2 --net0 virtio,bridge=vmbr0 --scsihw virtio-scsi-pci
|
||||||
|
qm set "$VM_ID" --scsi0 local-lvm:0,import-from="$LAST_LTS_RELEASE-server-cloudimg-amd64.img"
|
||||||
|
qm set "$VM_ID" --agent enabled=1,fstrim_cloned_disks=1
|
||||||
|
|
||||||
|
echo "Create Cloud-Init Disk and configure boot"
|
||||||
|
qm set "$VM_ID" --ide2 local-lvm:cloudinit
|
||||||
|
qm set "$VM_ID" --boot order=scsi0
|
||||||
|
|
||||||
|
echo "Configure vm"
|
||||||
|
qm set "$VM_ID" \
|
||||||
|
--name "$VM_NAME" \
|
||||||
|
--onboot 1 \
|
||||||
|
--ciuser "devops" \
|
||||||
|
--sshkeys ssh-keys.pub \
|
||||||
|
--ipconfig0 "ip=dhcp,ip6=dhcp"
|
||||||
|
|
||||||
|
echo "Delete downloaded image"
|
||||||
|
rm -f "$LAST_LTS_RELEASE-server-cloudimg-amd64.img"
|
Loading…
Reference in New Issue
Block a user