-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboot-to-talos-cozystack.sh
More file actions
executable file
·102 lines (85 loc) · 3.64 KB
/
boot-to-talos-cozystack.sh
File metadata and controls
executable file
·102 lines (85 loc) · 3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
# boot-to-talos-cozystack.sh - Deploy CozyStack image via kexec
set -e
echo "🥾 Launching ARM64 instance with boot-to-talos to CozyStack image..."
# Get latest Ubuntu 24.04 ARM64 AMI (should have good kexec support!)
echo "🔍 Finding latest Ubuntu 24.04 ARM64 AMI..."
UBUNTU_AMI=$(aws ec2 describe-images \
--region eu-west-1 \
--owners 099720109477 \
--filters "Name=name,Values=ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-arm64-server-*" \
"Name=state,Values=available" \
--query 'Images | sort_by(@, &CreationDate) | [-1].ImageId' \
--output text)
echo "📀 Using Ubuntu ARM64 AMI: $UBUNTU_AMI"
# Fixed IP for consistency
IPV4_ADDRESS="10.10.1.105"
COZYSTACK_IMAGE="10.10.1.100:5054/urmanac/cozystack-assets/talos/cozystack-spin-tailscale/talos:latest"
# Create cloud-init that uses boot-to-talos to kexec into CozyStack
cat > cloud-init.yaml << EOF
#cloud-config
package_update: true
packages:
- kexec-tools
- curl
- tar
# Add SSH key for debugging access with sudo password
users:
- name: ubuntu
sudo: 'ALL=(ALL) NOPASSWD:ALL'
passwd: '$6$rounds=4096$saltsalt$HIqhv2Pt2TG8WJ6UKxWGFJa0wJpCQKFdyNMZSLAhGCa6TIxPi1yCLaE36w.RsxPAPrLNOSjsZ0pMKt15QnqLQ.' # password is 'cozystack'
ssh_authorized_keys:
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFAJEwbe8ZuresTTfBGXSmpFKDcAkd6584qaA3y/3uVQ yebyen@Kingdons-MacBook-Pro-2.local
# Disable password authentication for SSH
ssh_pwauth: false
disable_root: true
runcmd:
# Download boot-to-talos from IPv6 mirror (now with IPv6 configured)
- curl -L http://[2620:8d:8000:e49:a00:27ff:fe2f:b6d9]/boot-to-talos-linux-arm64.tar.gz -o /tmp/boot-to-talos.tar.gz
- cd /tmp && tar -xzf boot-to-talos.tar.gz
- mv boot-to-talos /usr/local/bin/boot-to-talos
- chmod +x /usr/local/bin/boot-to-talos
# Install CozyStack Talos to disk (explicit install mode)
- sleep 30 # Give network time to stabilize
- /usr/local/bin/boot-to-talos -m install -image $COZYSTACK_IMAGE -disk /dev/nvme0n1 -yes
power_state:
delay: "+1"
mode: reboot
message: Rebooting to complete boot-to-talos setup
timeout: 30
condition: True
EOF
echo "📝 Created cloud-init with boot-to-talos to CozyStack image"
# Launch instance with Amazon Linux 2023
echo "🚀 Launching instance..."
INSTANCE_ID=$(aws ec2 run-instances \
--region eu-west-1 \
--image-id $UBUNTU_AMI \
--count 1 \
--instance-type t4g.small \
--security-group-ids sg-0e6b4a78092854897 \
--subnet-id subnet-07a140ab2b20bf89b \
--private-ip-address $IPV4_ADDRESS \
--ipv6-address-count 1 \
--no-associate-public-ip-address \
--block-device-mappings '[{"DeviceName":"/dev/sda1","Ebs":{"VolumeSize":30,"VolumeType":"gp3","DeleteOnTermination":true}}]' \
--user-data file://cloud-init.yaml \
--tag-specifications 'ResourceType=instance,Tags=[{Key=Name,Value=cozystack-boot-to-talos}]' \
--query 'Instances[0].InstanceId' \
--output text)
echo "✅ Created instance: $INSTANCE_ID at $IPV4_ADDRESS"
# Wait for instance to be running
echo "⏳ Waiting for instance to be running..."
aws ec2 wait instance-running --region eu-west-1 --instance-ids $INSTANCE_ID
echo "🥾 Instance is running and executing boot-to-talos..."
echo "⌛ Wait ~5-10 minutes for:"
echo " 1. Ubuntu to boot and setup"
echo " 2. boot-to-talos to download CozyStack image"
echo " 3. Install Talos to disk (install mode)"
echo ""
echo "🔍 Then check serial console for Talos maintenance mode"
echo "💻 Instance: $INSTANCE_ID"
echo "📍 IP: $IPV4_ADDRESS"
echo "🔑 SSH: ssh ubuntu@<ipv6> (sudo password: 'cozystack')"
echo "🌐 Once in maintenance mode, you can use Talm discovery!"
rm -f cloud-init.yaml