Commit a5de2ae4 authored by Finn's avatar Finn 🌵

Initial commit

parents
Pipeline #2913 failed with stage
in 11 minutes and 40 seconds
/packer_cache
http/user-data
*.qcow2
ssh_key
ssh_key.pub
build:
tags: [kvm]
stage: build
script:
- make
image-host: image-host/image-host.qcow2
ssh_key.pub: ssh_key
ssh_key:
ssh-keygen -t ed25519 -f ssh_key -qN ""
http/user-data: http/user-data.template ssh_key.pub
sed "s#SSH_KEY#$(shell cat ssh_key.pub)#g" http/user-data.template > http/user-data
image-host/image-host.qcow2: http/user-data
packer build -timestamp-ui image-host.json
# Image Host
A VM to host VM images. Uses nginx to serve them over http.
choose-mirror-bin mirror/http/proxy string
d-i apt-setup/use_mirror boolean true
d-i base-installer/kernel/override-image string linux-server
d-i clock-setup/utc boolean true
d-i clock-setup/utc-auto boolean true
d-i finish-install/reboot_in_progress note
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i grub-installer/bootdev string /dev/vda
d-i keymap select us
d-i mirror/country string manual
d-i mirror/http/directory string /debian
d-i mirror/http/hostname string http.debian.net
d-i mirror/http/proxy string
d-i partman-auto-lvm/guided_size string max
d-i partman-auto/choose_recipe select atomic
d-i partman-auto/method string lvm
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman/confirm_write_new_label boolean true
d-i passwd/root-login boolean false
d-i passwd/root-password-again password vagrant
d-i passwd/root-password password vagrant
d-i passwd/make-user boolean false
d-i passwd/username string vagrant
d-i pkgsel/include string openssh-server
d-i pkgsel/install-language-support boolean false
d-i pkgsel/update-policy select unattended-upgrades
d-i pkgsel/upgrade select full-upgrade
d-i time/zone string UTC
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
d-i preseed/late_command string sed -i '/^deb cdrom:/s/^/#/' /target/etc/apt/sources.list
apt-cdrom-setup apt-setup/cdrom/set-first boolean false
apt-mirror-setup apt-setup/use_mirror boolean true
popularity-contest popularity-contest/participate boolean false
tasksel tasksel/first multiselect standard, ubuntu-server
#cloud-config
ssh_authorized_keys:
- SSH_KEY
{
"description": "Image Host",
"builders": [
{
"disk_size": "20280",
"disk_interface": "virtio",
"headless": true,
"http_directory": "http",
"iso_checksum": "8dfb356f65af191152a76b831ac6e6a8a1c343582ee03f4166acb5ccdc788a3f",
"iso_checksum_type": "sha256",
"iso_url": "https://cloud.debian.org/images/cloud/buster/daily/20190928-30/debian-10-generic-amd64-daily-20190928-30.qcow2",
"disk_image": true,
"shutdown_command": "rm -rf ~/.ssh/authorized_keys && sudo shutdown -P now",
"ssh_username": "debian",
"ssh_private_key_file": "ssh_key",
"ssh_port": "22",
"ssh_wait_timeout": "10000s",
"type": "qemu",
"qemuargs": [[ "-m", "512M" ],[ "-smp", "2" ],["-smbios","type=1,serial=ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/;l={{ .Name }}"]],
"vm_name": "image-host.qcow2",
"output_directory": "image-host",
"format": "qcow2"
}
],
"provisioners": [
{
"type": "shell",
"scripts": [
"scripts/base-packages.sh",
"scripts/image-host.sh",
"scripts/clean.sh"
]
}, {
"type": "file",
"source": "files/nginx.conf",
"destination": "/etc/nginx/sites-enabled/image-host.conf"
}
]
}
#!/bin/sh
set -ex
echo "127.0.0.1 $(hostname)" | sudo tee -a /etc/hosts
sudo apt-get update
sudo apt-get full-upgrade -y
sudo apt-get install -y qemu-guest-agent
#!/bin/sh
set -ex
sudo cloud-init clean
sudo rm -rfv /var/lib/cloud/* /var/log/cloud-init*
#!/bin/bash
set -exuo pipefile
sudo apt-get install -y nginx rsync
sudo mkdir /var/www/images /var/lib/image-uploads
sudo useradd -d /var/lib/image-uploads image-uploads
sudo chown image-uploads /var/www/images /var/lib/image-uploads
sudo rm -rfv /etc/nginx/sites-enabled/*
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment