No description
Find a file
2021-11-28 11:50:56 +01:00
docs added digitalocean cluster 2021-08-11 22:52:11 +02:00
patches added docs and new patch 2021-04-18 12:39:35 +02:00
vendor initial commit 2020-06-01 12:18:20 +02:00
.gitignore fixed pool search 2020-06-04 22:40:38 +02:00
client.go linter fixes 2021-11-07 11:57:25 +01:00
go.mod initial commit 2020-06-01 12:18:20 +02:00
go.sum initial commit 2020-06-01 12:18:20 +02:00
helper.go added clout init image docs 2020-11-01 20:09:16 +01:00
ipconfig.go added mtu 2021-04-17 19:56:27 +02:00
LICENSE initial commit 2020-06-01 12:18:20 +02:00
network.go added mtu 2021-04-17 19:56:27 +02:00
node.go migrate to integer ID 2021-11-28 11:50:56 +01:00
pool.go migrate to integer ID 2021-11-28 11:50:56 +01:00
README.md added minimal image 2021-09-18 21:07:42 +02:00
scheme.go migrate to integer ID 2021-11-28 11:50:56 +01:00
server.go migrate to integer ID 2021-11-28 11:50:56 +01:00
serverstatus.go addes error status 2021-04-10 17:59:37 +02:00
snippet.go added clout init image docs 2020-11-01 20:09:16 +01:00
task.go linter fixes 2021-11-07 11:57:25 +01:00
userdata.go linter fixes 2021-11-07 11:57:25 +01:00

pve-go

PVE-Go is a go library for the Proxmox VE API.

The design is based on the Hetzner Clound API implementation: https://github.com/hetznercloud/hcloud-go

Cloud-Init Image

How to prepare a cloud-init image.

Download the latest version of the base image to one of your proxmox nodes:

curl -sSL https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img >/tmp/bionic-server-cloudimg-amd64.img

Create a cloud-init config to bootstrap the template:

cat <<'EOF'> /var/lib/vz/snippets/9000_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/*; exit 0'"
power_state:
  mode: poweroff
EOF

Create the template VM:

qm destroy 9000
qm create 9000 --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
qm set 9000 --boot c --bootdisk scsi0
qm set 9000 --serial0 socket --vga serial0
qm set 9000 --cicustom "user=local:snippets/9000_bootstrap"
qm set 9000 --ipconfig0 ip=dhcp,ip6=dhcp

qm start 9000
sleep 10;while :; do qm status 9000|grep -q stopped && break; done
qm set 9000 --cicustom ""
qm set 9000 --ipconfig0 ""
qm template 9000

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
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

Minimal Cloud Image

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

cat <<'EOF'> /var/lib/vz/snippets/9001_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 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'"
power_state:
  mode: poweroff
EOF

qm destroy 9001
qm create 9001 --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
qm set 9001 --boot c --bootdisk scsi0
qm set 9001 --serial0 socket --vga serial0
qm set 9001 --cicustom "user=local:snippets/9001_bootstrap"
qm set 9001 --ipconfig0 ip=dhcp,ip6=dhcp

qm start 9001
sleep 10;while :; do qm status 9001|grep -q stopped && break; done
qm set 9001 --cicustom ""
qm set 9001 --ipconfig0 ""
qm template 9001