add alpine example for virtualbox-iso
This commit is contained in:
parent
c2b7f1bf80
commit
715c6d3a86
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
build {
|
||||||
|
name = "alpine"
|
||||||
|
description = <<EOF
|
||||||
|
This build creates alpine images for versions :
|
||||||
|
* v3.8
|
||||||
|
For the following builers :
|
||||||
|
* virtualbox-iso
|
||||||
|
EOF
|
||||||
|
|
||||||
|
// the common fields of the source blocks are defined in the
|
||||||
|
// source.builder-type.pkr.hcl files, here we only set the fields specific to
|
||||||
|
// the different versions of ubuntu.
|
||||||
|
source "source.virtualbox-iso.base-alpine-amd64" {
|
||||||
|
name = "3.8"
|
||||||
|
iso_url = local.iso_url_alpine_380
|
||||||
|
iso_checksum = "file:${local.iso_checksum_url_alpine_380}"
|
||||||
|
output_directory = "virtualbox_iso_alpine_380_amd64"
|
||||||
|
boot_command = local.alpine_380_floppy_boot_command
|
||||||
|
floppy_files = local.floppy_files
|
||||||
|
boot_wait = "10s"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
provisioner "shell" {
|
||||||
|
inline = ["echo hi"]
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
KEYMAPOPTS="us us"
|
||||||
|
HOSTNAMEOPTS="-n alpine"
|
||||||
|
INTERFACESOPTS="auto lo
|
||||||
|
iface lo inet loopback
|
||||||
|
|
||||||
|
auto eth0
|
||||||
|
iface eth0 inet dhcp
|
||||||
|
hostname alpine
|
||||||
|
"
|
||||||
|
TIMEZONEOPTS="-z UTC"
|
||||||
|
PROXYOPTS="none"
|
||||||
|
APKREPOSOPTS="http://mirror.yandex.ru/mirrors/alpine/v3.8/main"
|
||||||
|
SSHDOPTS="-c openssh"
|
||||||
|
NTPOPTS="-c none"
|
||||||
|
DISKOPTS="-m sys /dev/sda"
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
apk add libressl
|
||||||
|
apk add open-vm-tools
|
||||||
|
rc-update add open-vm-tools
|
||||||
|
/etc/init.d/open-vm-tools start
|
||||||
|
|
||||||
|
cat >/usr/local/bin/shutdown <<EOF
|
||||||
|
#!/bin/sh
|
||||||
|
poweroff
|
||||||
|
EOF
|
||||||
|
chmod +x /usr/local/bin/shutdown
|
||||||
|
|
||||||
|
sed -i "/#PermitRootLogin/c\PermitRootLogin yes" /etc/ssh/sshd_config
|
||||||
|
sed -i "/#PasswordAuthentication/c\PasswordAuthentication yes" /etc/ssh/sshd_config
|
||||||
|
mkdir ~/.ssh
|
||||||
|
# copy ssy key ?
|
|
@ -12,3 +12,14 @@ source "virtualbox-iso" "base-ubuntu-amd64" {
|
||||||
guest_additions_path = "VBoxGuestAdditions_{{.Version}}.iso"
|
guest_additions_path = "VBoxGuestAdditions_{{.Version}}.iso"
|
||||||
guest_additions_url = var.guest_additions_url
|
guest_additions_url = var.guest_additions_url
|
||||||
}
|
}
|
||||||
|
|
||||||
|
source "virtualbox-iso" "base-alpine-amd64" {
|
||||||
|
headless = var.headless
|
||||||
|
guest_os_type = "Linux26_64"
|
||||||
|
http_directory = local.http_directory
|
||||||
|
hard_drive_interface = "sata"
|
||||||
|
ssh_username = "root"
|
||||||
|
ssh_password = var.alpine_password
|
||||||
|
ssh_wait_timeout = "60m"
|
||||||
|
shutdown_command = "poweroff"
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
|
||||||
|
variable "alpine_password" {
|
||||||
|
type = string
|
||||||
|
default = "alpine"
|
||||||
|
}
|
||||||
|
|
||||||
|
locals {
|
||||||
|
iso_url_alpine_380 = "http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/x86_64/alpine-standard-3.8.0-x86_64.iso"
|
||||||
|
iso_checksum_url_alpine_380 = "http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/x86_64/alpine-standard-3.8.0-x86_64.iso.sha256"
|
||||||
|
floppy_files = [
|
||||||
|
"${local.http_directory}/alpine-answers",
|
||||||
|
"${local.http_directory}/alpine-setup.sh"
|
||||||
|
]
|
||||||
|
alpine_380_floppy_boot_command = [
|
||||||
|
"root<enter><wait>",
|
||||||
|
"mount -t vfat /dev/fd0 /media/floppy<enter><wait>",
|
||||||
|
"setup-alpine -f /media/floppy/alpine-answers<enter>",
|
||||||
|
"<wait5>",
|
||||||
|
"${var.alpine_password}<enter>",
|
||||||
|
"${var.alpine_password}<enter>",
|
||||||
|
"<wait5>",
|
||||||
|
"y<enter>",
|
||||||
|
"<wait40s>",
|
||||||
|
"reboot<enter>",
|
||||||
|
"<wait20s>",
|
||||||
|
"root<enter>",
|
||||||
|
"${var.alpine_password}<enter><wait>",
|
||||||
|
"mount -t vfat /dev/fd0 /media/floppy<enter><wait>",
|
||||||
|
"/media/floppy/alpine-setup.sh<enter>",
|
||||||
|
"reboot<enter>",
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue