mirror of https://github.com/hashicorp/packer
Vsphere example update (#10574)
* fix ubuntu json template example * add hcl template example * add hcl alpine example * add hcl versions of alpine and macos; update macos json * add hcl version of windows template, call fix on windows jsonpull/10576/head
parent
ef4afafde9
commit
ba1ad9ea15
@ -0,0 +1,44 @@
|
||||
# "timestamp" template function replacement
|
||||
locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }
|
||||
|
||||
# source blocks are analogous to the "builders" in json templates. They are used
|
||||
# in build blocks. A build block runs provisioners and post-processors on a
|
||||
# source. Read the documentation for source blocks here:
|
||||
# https://www.packer.io/docs/templates/hcl_templates/blocks/source
|
||||
source "vsphere-iso" "autogenerated_1" {
|
||||
CPUs = 1
|
||||
RAM = 512
|
||||
RAM_reserve_all = true
|
||||
boot_command = ["root<enter><wait>", "mount -t vfat /dev/fd0 /media/floppy<enter><wait>", "setup-alpine -f /media/floppy/answerfile<enter>", "<wait5>", "jetbrains<enter>", "jetbrains<enter>", "<wait5>", "y<enter>", "<wait10><wait10><wait10><wait10>", "reboot<enter>", "<wait10><wait10>", "root<enter>", "jetbrains<enter><wait>", "mount -t vfat /dev/fd0 /media/floppy<enter><wait>", "/media/floppy/SETUP.SH<enter>"]
|
||||
boot_wait = "15s"
|
||||
disk_controller_type = ["pvscsi"]
|
||||
floppy_files = ["${path.root}/answerfile", "${path.root}/setup.sh"]
|
||||
guest_os_type = "other3xLinux64Guest"
|
||||
host = "esxi-1.vsphere65.test"
|
||||
insecure_connection = true
|
||||
iso_paths = ["[datastore1] ISO/alpine-standard-3.8.2-x86_64.iso"]
|
||||
network_adapters {
|
||||
network_card = "vmxnet3"
|
||||
}
|
||||
password = "jetbrains"
|
||||
ssh_password = "jetbrains"
|
||||
ssh_username = "root"
|
||||
storage {
|
||||
disk_size = 1024
|
||||
disk_thin_provisioned = true
|
||||
}
|
||||
username = "root"
|
||||
vcenter_server = "vcenter.vsphere65.test"
|
||||
vm_name = "alpine-${local.timestamp}"
|
||||
}
|
||||
|
||||
# a build block invokes sources and runs provisioning steps on them. The
|
||||
# documentation for build blocks can be found here:
|
||||
# https://www.packer.io/docs/templates/hcl_templates/blocks/build
|
||||
build {
|
||||
sources = ["source.vsphere-iso.autogenerated_1"]
|
||||
|
||||
provisioner "shell" {
|
||||
inline = ["ls /"]
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
# "timestamp" template function replacement
|
||||
locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") }
|
||||
|
||||
# source blocks are analogous to the "builders" in json templates. They are used
|
||||
# in build blocks. A build block runs provisioners and post-processors on a
|
||||
# source. Read the documentation for source blocks here:
|
||||
# https://www.packer.io/docs/templates/hcl_templates/blocks/source
|
||||
source "vsphere-clone" "example_clone" {
|
||||
communicator = "none"
|
||||
host = "esxi-1.vsphere65.test"
|
||||
insecure_connection = "true"
|
||||
password = "jetbrains"
|
||||
template = "alpine"
|
||||
username = "root"
|
||||
vcenter_server = "vcenter.vsphere65.test"
|
||||
vm_name = "alpine-clone-${local.timestamp}"
|
||||
}
|
||||
|
||||
# a build block invokes sources and runs provisioning steps on them. The
|
||||
# documentation for build blocks can be found here:
|
||||
# https://www.packer.io/docs/templates/hcl_templates/blocks/build
|
||||
build {
|
||||
sources = ["source.vsphere-clone.example_clone"]
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
# source blocks are analogous to the "builders" in json templates. They are used
|
||||
# in build blocks. A build block runs provisioners and post-processors on a
|
||||
# source. Read the documentation for source blocks here:
|
||||
# https://www.packer.io/docs/templates/hcl_templates/blocks/source
|
||||
source "vsphere-iso" "example_osx" {
|
||||
CPUs = 1
|
||||
RAM = 4096
|
||||
boot_command = ["<enter><wait5>", "<leftCtrlOn><f2><leftCtrlOff>u<enter>t<enter><wait5>", "/Volumes/setup/setup.sh<enter>"]
|
||||
boot_wait = "4m"
|
||||
cdrom_type = "sata"
|
||||
configuration_parameters = {
|
||||
"ich7m.present" = "TRUE"
|
||||
"smc.present" = "TRUE"
|
||||
}
|
||||
guest_os_type = "darwin16_64Guest"
|
||||
host = "esxi-mac.vsphere65.test"
|
||||
insecure_connection = "true"
|
||||
iso_checksum = "file:///${path.root}/setup/out/sha256sums"
|
||||
iso_paths = ["[datastore-mac] ISO/macOS 10.13.3.iso", "[datastore-mac] ISO/VMware Tools/10.2.0/darwin.iso"]
|
||||
iso_urls = ["${path.root}/setup/out/setup.iso"]
|
||||
network_adapters {
|
||||
network_card = "e1000e"
|
||||
}
|
||||
password = "jetbrains"
|
||||
ssh_password = "jetbrains"
|
||||
ssh_username = "jetbrains"
|
||||
storage {
|
||||
disk_size = 32768
|
||||
disk_thin_provisioned = true
|
||||
}
|
||||
usb_controller = ["usb"]
|
||||
username = "root"
|
||||
vcenter_server = "vcenter.vsphere65.test"
|
||||
vm_name = "macos-packer"
|
||||
}
|
||||
|
||||
# a build block invokes sources and runs provisioning steps on them. The
|
||||
# documentation for build blocks can be found here:
|
||||
# https://www.packer.io/docs/templates/hcl_templates/blocks/build
|
||||
build {
|
||||
sources = ["source.vsphere-iso.example_osx"]
|
||||
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
# source blocks are analogous to the "builders" in json templates. They are used
|
||||
# in build blocks. A build block runs provisioners and post-processors on a
|
||||
# source. Read the documentation for source blocks here:
|
||||
# https://www.packer.io/docs/templates/hcl_templates/blocks/source
|
||||
source "vsphere-iso" "example" {
|
||||
CPUs = 1
|
||||
RAM = 1024
|
||||
RAM_reserve_all = true
|
||||
boot_command = ["<enter><wait><f6><wait><esc><wait>",
|
||||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
|
||||
"<bs><bs><bs>", "/install/vmlinuz",
|
||||
" initrd=/install/initrd.gz", " priority=critical",
|
||||
" locale=en_US", " file=/media/preseed.cfg",
|
||||
"<enter>"]
|
||||
disk_controller_type = ["pvscsi"]
|
||||
floppy_files = ["${path.root}/preseed.cfg"]
|
||||
guest_os_type = "ubuntu64Guest"
|
||||
host = "esxi-1.vsphere65.test"
|
||||
insecure_connection = true
|
||||
iso_paths = ["[datastore1] ISO/ubuntu-16.04.3-server-amd64.iso"]
|
||||
network_adapters {
|
||||
network_card = "vmxnet3"
|
||||
}
|
||||
password = "jetbrains"
|
||||
ssh_password = "jetbrains"
|
||||
ssh_username = "jetbrains"
|
||||
storage {
|
||||
disk_size = 32768
|
||||
disk_thin_provisioned = true
|
||||
}
|
||||
username = "root"
|
||||
vcenter_server = "vcenter.vsphere65.test"
|
||||
vm_name = "example-ubuntu"
|
||||
}
|
||||
|
||||
# a build block invokes sources and runs provisioning steps on them. The
|
||||
# documentation for build blocks can be found here:
|
||||
# https://www.packer.io/docs/templates/hcl_templates/blocks/build
|
||||
build {
|
||||
sources = ["source.vsphere-iso.example"]
|
||||
|
||||
provisioner "shell" {
|
||||
inline = ["ls /"]
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
# source blocks are generated from your builders; a source can be referenced in
|
||||
# build blocks. A build block runs provisioner and post-processors on a
|
||||
# source. Read the documentation for source blocks here:
|
||||
# https://www.packer.io/docs/templates/hcl_templates/blocks/source
|
||||
source "vsphere-iso" "example_windows" {
|
||||
CPUs = 1
|
||||
RAM = 4096
|
||||
RAM_reserve_all = true
|
||||
communicator = "winrm"
|
||||
disk_controller_type = ["pvscsi"]
|
||||
floppy_files = ["${path.root}/setup/"]
|
||||
floppy_img_path = "[datastore1] ISO/VMware Tools/10.2.0/pvscsi-Windows8.flp"
|
||||
guest_os_type = "windows9_64Guest"
|
||||
host = "esxi-1.vsphere65.test"
|
||||
insecure_connection = "true"
|
||||
iso_paths = ["[datastore1] ISO/en_windows_10_multi-edition_vl_version_1709_updated_dec_2017_x64_dvd_100406172.iso", "[datastore1] ISO/VMware Tools/10.2.0/windows.iso"]
|
||||
network_adapters {
|
||||
network_card = "vmxnet3"
|
||||
}
|
||||
password = "jetbrains"
|
||||
storage {
|
||||
disk_size = 32768
|
||||
disk_thin_provisioned = true
|
||||
}
|
||||
username = "root"
|
||||
vcenter_server = "vcenter.vsphere65.test"
|
||||
vm_name = "example-windows"
|
||||
winrm_password = "jetbrains"
|
||||
winrm_username = "jetbrains"
|
||||
}
|
||||
|
||||
# a build block invokes sources and runs provisioning steps on them. The
|
||||
# documentation for build blocks can be found here:
|
||||
# https://www.packer.io/docs/templates/hcl_templates/blocks/build
|
||||
build {
|
||||
sources = ["source.vsphere-iso.example_windows"]
|
||||
|
||||
provisioner "windows-shell" {
|
||||
inline = ["dir c:\\"]
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue