Add complete VM creation script with hardcoded password
- Creates VM 202 with all settings in one script - Hardcoded password: devmatrix202 - Enables SSH password authentication via cloud-init - Includes proper disk attachment syntax - Optimized for pve-main storage and vmbr1 network
This commit is contained in:
parent
5bd1bff77e
commit
f77ea9a05d
|
|
@ -0,0 +1,81 @@
|
|||
#!/bin/bash
|
||||
# Complete VM creation script with hardcoded password
|
||||
# Run on Proxmox host as root
|
||||
set -e
|
||||
|
||||
VM_ID=202
|
||||
VM_NAME="DevMatrix-Prod"
|
||||
VM_IP="192.168.5.211/24"
|
||||
VM_GW="192.168.5.1"
|
||||
PASSWORD="devmatrix202" # HARDCODED PASSWORD
|
||||
|
||||
echo "🚀 Creating VM $VM_ID..."
|
||||
|
||||
# Create VM
|
||||
qm create $VM_ID \
|
||||
--name "$VM_NAME" \
|
||||
--memory 16384 \
|
||||
--balloon 0 \
|
||||
--cores 6 \
|
||||
--cpu host \
|
||||
--sockets 2 \
|
||||
--numa 1 \
|
||||
--net0 virtio,bridge=vmbr1,firewall=1 \
|
||||
--scsihw virtio-scsi-single \
|
||||
--ostype l26 \
|
||||
--agent enabled=1 \
|
||||
--cpuunits 2048 \
|
||||
--onboot 1
|
||||
|
||||
# Download cloud image if not exists
|
||||
cd /var/lib/vz/template/iso
|
||||
if [ ! -f jammy-server-cloudimg-amd64.img ]; then
|
||||
echo "Downloading Ubuntu cloud image..."
|
||||
wget -q --show-progress https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
|
||||
fi
|
||||
|
||||
# Import and attach disk
|
||||
echo "Importing disk..."
|
||||
qm importdisk $VM_ID jammy-server-cloudimg-amd64.img pve-main --format qcow2
|
||||
qm set $VM_ID --scsi0 pve-main:202/vm-202-disk-0.qcow2,discard=on,iothread=1
|
||||
qm disk resize $VM_ID scsi0 150G
|
||||
|
||||
# Create cloud-init with HARDCODED PASSWORD
|
||||
echo "Setting up cloud-init..."
|
||||
qm set $VM_ID --ide2 pve-main:cloudinit
|
||||
|
||||
# Create custom cloud-init snippet for SSH password auth
|
||||
mkdir -p /var/lib/vz/snippets
|
||||
cat > /var/lib/vz/snippets/vm-${VM_ID}-user-data.yaml << 'EOF'
|
||||
#cloud-config
|
||||
password: devmatrix202
|
||||
chpasswd: { expire: False }
|
||||
ssh_pwauth: True
|
||||
EOF
|
||||
|
||||
qm set $VM_ID --cicustom "user=local:snippets/vm-${VM_ID}-user-data.yaml"
|
||||
qm set $VM_ID --ciuser devmatrix
|
||||
qm set $VM_ID --cipassword "$PASSWORD"
|
||||
|
||||
# Configure network and boot
|
||||
qm set $VM_ID --ipconfig0 ip=$VM_IP,gw=$VM_GW
|
||||
qm set $VM_ID --boot order=scsi0
|
||||
qm set $VM_ID --tags production,mission-control,devmatrix
|
||||
|
||||
# Start VM
|
||||
echo "Starting VM..."
|
||||
qm start $VM_ID
|
||||
|
||||
echo ""
|
||||
echo "✅ VM $VM_ID created successfully!"
|
||||
echo "================================"
|
||||
echo "VM ID: $VM_ID"
|
||||
echo "Name: $VM_NAME"
|
||||
echo "IP: 192.168.5.211"
|
||||
echo "User: devmatrix"
|
||||
echo "Password: $PASSWORD"
|
||||
echo "================================"
|
||||
echo ""
|
||||
echo "Wait 60 seconds for first boot, then:"
|
||||
echo " ssh devmatrix@192.168.5.211"
|
||||
echo " Password: $PASSWORD"
|
||||
Loading…
Reference in New Issue