mirror of https://github.com/hashicorp/packer
Merge pull request #9570 from hashicorp/azr-more-examples
HCL2: More examples for vsphere & vmware ( esxi )pull/9630/head
commit
21287fee58
@ -0,0 +1,42 @@
|
||||
|
||||
build {
|
||||
name = "alpine"
|
||||
description = <<EOF
|
||||
This build creates alpine images for versions :
|
||||
* v3.12
|
||||
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.12"
|
||||
iso_url = local.iso_url_alpine_312
|
||||
iso_checksum = "file:${local.iso_checksum_url_alpine_312}"
|
||||
output_directory = "virtualbox_iso_alpine_312_amd64"
|
||||
boot_command = local.alpine_312_floppy_boot_command
|
||||
boot_wait = "10s"
|
||||
}
|
||||
|
||||
source "source.vsphere-iso.base-alpine-amd64" {
|
||||
name = "3.12"
|
||||
vm_name = "alpine-3.12"
|
||||
iso_url = local.iso_url_alpine_312
|
||||
iso_checksum = "file:${local.iso_checksum_url_alpine_312}"
|
||||
boot_command = local.alpine_312_floppy_boot_command_vsphere
|
||||
boot_wait = "10s"
|
||||
}
|
||||
|
||||
source "source.vmware-iso.esxi-base-alpine-amd64" {
|
||||
name = "3.12-from-esxi"
|
||||
iso_url = local.iso_url_alpine_312
|
||||
iso_checksum = "file:${local.iso_checksum_url_alpine_312}"
|
||||
boot_command = local.alpine_312_floppy_boot_command_vsphere
|
||||
}
|
||||
|
||||
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://mirrors.dotsrc.org/alpine/v3.8/main"
|
||||
SSHDOPTS="-c openssh"
|
||||
NTPOPTS="-c none"
|
||||
DISKOPTS="-m sys /dev/sda"
|
||||
@ -0,0 +1,21 @@
|
||||
#!/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 ?
|
||||
|
||||
/etc/init.d/sshd restart
|
||||
@ -0,0 +1,22 @@
|
||||
KEYMAPOPTS="us us"
|
||||
HOSTNAMEOPTS="-n alpine"
|
||||
INTERFACESOPTS="auto lo
|
||||
iface lo inet loopback
|
||||
|
||||
auto eth0
|
||||
iface eth0 inet static
|
||||
address 147.75.201.6
|
||||
netmask 255.255.255.248
|
||||
network 147.75.201.0
|
||||
broadcast 147.75.201.7
|
||||
gateway 147.75.201.1
|
||||
"
|
||||
DNSOPTS="-d example.com 8.8.8.8"
|
||||
TIMEZONEOPTS="-z UTC"
|
||||
PROXYOPTS="none"
|
||||
APKREPOSOPTS="http://dl-cdn.alpinelinux.org/alpine/v3.12/main
|
||||
http://dl-cdn.alpinelinux.org/alpine/v3.8/main
|
||||
"
|
||||
SSHDOPTS="-c openssh"
|
||||
NTPOPTS="-c none"
|
||||
DISKOPTS="-m sys /dev/sda"
|
||||
@ -0,0 +1,56 @@
|
||||
|
||||
variable "alpine_password" {
|
||||
type = string
|
||||
default = "alpine"
|
||||
}
|
||||
|
||||
locals {
|
||||
iso_url_alpine_312 = "http://dl-cdn.alpinelinux.org/alpine/v3.12/releases/x86_64/alpine-virt-3.12.0-x86_64.iso"
|
||||
iso_checksum_url_alpine_312 = "http://dl-cdn.alpinelinux.org/alpine/v3.12/releases/x86_64/alpine-virt-3.12.0-x86_64.iso.sha256"
|
||||
floppy_files_alpine = [
|
||||
"${local.http_directory}/alpine-answers",
|
||||
"${local.http_directory}/alpine-setup.sh"
|
||||
]
|
||||
|
||||
alpine_312_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>",
|
||||
]
|
||||
|
||||
floppy_files_alpine_vsphere = [
|
||||
"${local.http_directory}/alpine-vsphere-answers",
|
||||
"${local.http_directory}/alpine-setup.sh"
|
||||
]
|
||||
|
||||
alpine_312_floppy_boot_command_vsphere = [
|
||||
"root<enter><wait1s>",
|
||||
"mount -t vfat /dev/fd0 /media/floppy<enter><wait1s>",
|
||||
"setup-alpine -f /media/floppy/alpine-vsphere-answers<enter><wait3s>",
|
||||
"${var.alpine_password}<enter>",
|
||||
"${var.alpine_password}<enter>",
|
||||
"<wait6s>",
|
||||
"y<enter>",
|
||||
"<wait12s>",
|
||||
"reboot<enter>",
|
||||
"<wait12s>",
|
||||
"root<enter>",
|
||||
"${var.alpine_password}<enter><wait>",
|
||||
"mount -t vfat /dev/fd0 /media/floppy<enter><wait>",
|
||||
"/media/floppy/alpine-setup.sh<enter>",
|
||||
"<wait55s>",
|
||||
]
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue