added ubuntu 20.04
This commit is contained in:
parent
78b40626e6
commit
c168edb271
1 changed files with 132 additions and 11 deletions
143
README.md
143
README.md
|
|
@ -8,6 +8,92 @@ The design is based on the Hetzner Clound API implementation: https://github.com
|
|||
|
||||
How to prepare a cloud-init image.
|
||||
|
||||
### Ubuntu 20.04
|
||||
|
||||
Download the latest version of the base image to one of your proxmox nodes:
|
||||
|
||||
```
|
||||
curl -sSL https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img >/tmp/focal-server-cloudimg-amd64.img
|
||||
```
|
||||
|
||||
Create a cloud-init config to bootstrap the template:
|
||||
```
|
||||
cat <<'EOF'> /var/lib/vz/snippets/9002_bootstrap
|
||||
#cloud-config
|
||||
package_update: true
|
||||
package_upgrade: true
|
||||
ntp:
|
||||
enabled: true
|
||||
servers: ["pool.ntp.org"]
|
||||
ssh_deletekeys: true
|
||||
ssh_genkeytypes: ["ed25519", "rsa"]
|
||||
runcmd:
|
||||
- "apt-get -y clean"
|
||||
- "apt-get -y autoremove --purge"
|
||||
- "bash -c 'rm /home/ubuntu/.ssh/authorized_keys; exit 0'"
|
||||
- "bash -c 'find /var/log -type f | while read f; do echo -ne >$f; done; exit 0'"
|
||||
- "bash -c 'rm -rf /var/lib/cloud/* /var/tmp/* /tmp/* /tmp/.*-unix; exit 0'"
|
||||
power_state:
|
||||
mode: poweroff
|
||||
EOF
|
||||
```
|
||||
|
||||
Create the template VM:
|
||||
```
|
||||
qm stop 9002; qm destroy 9002
|
||||
qm create 9002 --name ubuntu-2004 --memory 2048 --net0 virtio,bridge=vmbr0
|
||||
qm importdisk 9002 /tmp/focal-server-cloudimg-amd64.img local
|
||||
qm set 9002 --scsihw virtio-scsi-pci --scsi0 local:9002/vm-9002-disk-0.raw
|
||||
qm set 9002 --ide0 local:cloudinit
|
||||
qm set 9002 --boot c --bootdisk scsi0
|
||||
qm set 9002 --serial0 socket --vga serial0
|
||||
qm set 9002 --cicustom "user=local:snippets/9002_bootstrap"
|
||||
qm set 9002 --ipconfig0 ip=dhcp,ip6=dhcp
|
||||
|
||||
qm start 9002
|
||||
sleep 10;while :; do qm status 9002|grep -q stopped && break; done
|
||||
qm set 9002 --cicustom ""
|
||||
qm set 9002 --ipconfig0 ""
|
||||
qm template 9002
|
||||
```
|
||||
|
||||
#### More Image Cleanup
|
||||
|
||||
```
|
||||
mkdir /etc/systemd/system/motd-news.service.d
|
||||
cat <<EOF>/etc/systemd/system/motd-news.service.d/override.conf
|
||||
[Service]
|
||||
ExecStart=/bin/true
|
||||
EOF
|
||||
|
||||
mkdir /etc/systemd/timesyncd.conf.d
|
||||
cat <<EOF>/etc/systemd/timesyncd.conf.d/ntp.conf
|
||||
[Time]
|
||||
NTP=pool.ntp.org
|
||||
EOF
|
||||
|
||||
apt -y purge alsa-topology-conf alsa-ucm-conf apport \
|
||||
apport-symptoms at bash-completion bolt byobu eatmydata command-not-found \
|
||||
eject fonts-ubuntu-console htop install-info landscape-common lxd-agent-loader \
|
||||
motd-news-config nano ntfs-3g pastebinit plymouth plymouth-theme-ubuntu-text \
|
||||
popularity-contest policykit-1 python3-apport os-prober snapd \
|
||||
sound-theme-freedesktop ubuntu-advantage-tools ufw
|
||||
|
||||
# optional
|
||||
# apt -y purge accountsservice multipath-tools packagekit udisks2 unattended-upgrades
|
||||
|
||||
apt -y autoremove
|
||||
```
|
||||
|
||||
Even more cleanup:
|
||||
|
||||
```
|
||||
apt -y purge lshw lsof ltrace man-db manpages mdadm mtr-tiny screen sosreport strace tcpdump tmux usbutils whiptail
|
||||
apt -y autoremove
|
||||
```
|
||||
|
||||
### Ubuntu 18.04
|
||||
|
||||
Download the latest version of the base image to one of your proxmox nodes:
|
||||
|
||||
```
|
||||
|
|
@ -38,8 +124,8 @@ EOF
|
|||
|
||||
Create the template VM:
|
||||
```
|
||||
qm destroy 9000
|
||||
qm create 9000 --memory 2048 --net0 virtio,bridge=vmbr0
|
||||
qm stop 9000; qm destroy 9000
|
||||
qm create 9000 --name ubuntu-1804 --memory 2048 --net0 virtio,bridge=vmbr0
|
||||
qm importdisk 9000 /tmp/bionic-server-cloudimg-amd64.img local
|
||||
qm set 9000 --scsihw virtio-scsi-pci --scsi0 local:9000/vm-9000-disk-0.raw
|
||||
qm set 9000 --ide0 local:cloudinit
|
||||
|
|
@ -55,7 +141,7 @@ qm set 9000 --ipconfig0 ""
|
|||
qm template 9000
|
||||
```
|
||||
|
||||
### More Image Cleanup
|
||||
#### More Image Cleanup
|
||||
|
||||
```
|
||||
apt -y purge apport apport-symptoms bash-completion byobu htop landscape-common lxcfs lxd lxd-client motd-news-config nano ntfs-3g os-prober ufw
|
||||
|
|
@ -71,6 +157,44 @@ apt -y autoremove
|
|||
|
||||
## Minimal Cloud Image
|
||||
|
||||
### Ubuntu 20.04
|
||||
|
||||
```
|
||||
curl -sSL https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img >/tmp/focal-server-cloudimg-amd64.img
|
||||
|
||||
cat <<'EOF'> /var/lib/vz/snippets/9002_bootstrap
|
||||
#cloud-config
|
||||
package_update: true
|
||||
package_upgrade: true
|
||||
ssh_deletekeys: true
|
||||
ssh_genkeytypes: ["ed25519", "rsa"]
|
||||
runcmd:
|
||||
- "curl -sSL https://git.giftfish.de/ston1th/cleanup/raw/branch/master/ubuntu_2004_full.sh >/tmp/cleanup.sh"
|
||||
- |
|
||||
bash -c '[ "$(sha256sum /tmp/cleanup.sh|cut -d" " -f1)" = "fe2827d03ebba6e058ed7b9e56116eef78a45606f2e5f2956b2b2f495f042724" ] && sh /tmp/cleanup.sh || echo "error: cleanup script hash does not match" >&2'
|
||||
power_state:
|
||||
mode: poweroff
|
||||
EOF
|
||||
|
||||
qm stop 9002; qm destroy 9002
|
||||
qm create 9002 --name ubuntu-2004 --memory 2048 --net0 virtio,bridge=vmbr0
|
||||
qm importdisk 9002 /tmp/focal-server-cloudimg-amd64.img local
|
||||
qm set 9002 --scsihw virtio-scsi-pci --scsi0 local:9002/vm-9002-disk-0.raw
|
||||
qm set 9002 --ide0 local:cloudinit
|
||||
qm set 9002 --boot c --bootdisk scsi0
|
||||
qm set 9002 --serial0 socket --vga serial0
|
||||
qm set 9002 --cicustom "user=local:snippets/9002_bootstrap"
|
||||
qm set 9002 --ipconfig0 ip=dhcp,ip6=dhcp
|
||||
|
||||
qm start 9002
|
||||
sleep 10;while :; do qm status 9002|grep -q stopped && break; done
|
||||
qm set 9002 --cicustom ""
|
||||
qm set 9002 --ipconfig0 ""
|
||||
qm template 9002
|
||||
```
|
||||
|
||||
### Ubuntu 18.04
|
||||
|
||||
```
|
||||
curl -sSL https://cloud-images.ubuntu.com/minimal/releases/bionic/release/ubuntu-18.04-minimal-cloudimg-amd64.img >/tmp/ubuntu-18.04-minimal-cloudimg-amd64.img
|
||||
|
||||
|
|
@ -84,18 +208,15 @@ ntp:
|
|||
ssh_deletekeys: true
|
||||
ssh_genkeytypes: ["ed25519", "rsa"]
|
||||
runcmd:
|
||||
- "apt-get -y purge apport htop lxcfs lxd lxd-client motd-news-config mdadm os-prober sosreport"
|
||||
- "apt-get -y autoremove --purge"
|
||||
- "apt-get -y clean"
|
||||
- "bash -c 'rm /home/ubuntu/.ssh/authorized_keys; exit 0'"
|
||||
- "bash -c 'find /var/log -type f | while read f; do echo -ne >$f; done; exit 0'"
|
||||
- "bash -c 'rm -rf /var/lib/cloud/*; exit 0'"
|
||||
- "curl -sSL https://git.giftfish.de/ston1th/cleanup/raw/branch/master/ubuntu_1804.sh >/tmp/cleanup.sh"
|
||||
- |
|
||||
bash -c '[ "$(sha256sum /tmp/cleanup.sh|cut -d" " -f1)" = "ecb2ae04cdd6b91fdc56a5db2015f401e474196b8eaaaf8e3aa5dc4b5e4c087d" ] && sh /tmp/cleanup.sh || echo "error: cleanup script hash does not match" >&2'
|
||||
power_state:
|
||||
mode: poweroff
|
||||
EOF
|
||||
|
||||
qm destroy 9001
|
||||
qm create 9001 --memory 2048 --net0 virtio,bridge=vmbr0
|
||||
qm stop 9001; qm destroy 9001
|
||||
qm create 9001 --name ubuntu-1804-min --memory 2048 --net0 virtio,bridge=vmbr0
|
||||
qm importdisk 9001 /tmp/ubuntu-18.04-minimal-cloudimg-amd64.img local
|
||||
qm set 9001 --scsihw virtio-scsi-pci --scsi0 local:9001/vm-9001-disk-0.raw
|
||||
qm set 9001 --ide0 local:cloudinit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue