Code Monkey home page Code Monkey logo

vmware-samples / packer-examples-for-vsphere Goto Github PK

View Code? Open in Web Editor NEW
756.0 756.0 303.0 3.56 MB

Packer Examples for vSphere

Home Page: https://vmware-samples.github.io/packer-examples-for-vsphere/

License: Other

Shell 11.00% HCL 88.40% PowerShell 0.49% Dockerfile 0.04% Makefile 0.07%
cloud-foundation hashicorp hashicorp-packer hcl2 machine-images packer packer-examples packer-templates packer-vsphere vmware vmware-cloud vmware-vsphere vsphere-iso

packer-examples-for-vsphere's People

Contributors

alcorwalter avatar aseques avatar burnsjared0415 avatar davidrobson avatar dependabot[bot] avatar dhoppe avatar dsi-benthomas avatar evilaliv3 avatar gcblack avatar jameskilbynet avatar jm2k69 avatar joisika avatar keys1234249 avatar metabsd avatar necarnot avatar rcroft-work avatar roshankathawate avatar sestegra avatar sophware avatar tenthirtyam avatar tintinhamans avatar ukushisanet avatar username-is-already-taken2 avatar virtualistic avatar wfyanmnm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

packer-examples-for-vsphere's Issues

[BUG] [redhat-linux-8] Unable to find a match: epel-release

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

VMware vSphere

7.0 Update 2

HashiCorp Packer

1.7.6

HashiCorp Packer Plugin for VMware vSphere

1.0.1

Guest Operating System

Ubuntu 20.04

Environment Details

Used ISO is rhel-8.4-x86_64-dvd.iso

Description

When building Red Hat Enerprise Linux 8 Server for VMware vSphere, an error occurs during the Installing additional packages step.

Expected Behavior

Successfully finish build

Actual Behavior

Error occurs because epel-release not found.

Steps to Reproduce

  • Download rhel-8.4-x86_64-dvd.iso
  • Copy ISO to datastore
  • Launch ./build.sh and select redhat-linux-8

Log Fragments and Files

==> vsphere-iso.linux-redhat-linux: + echo '> Installing additional packages ...'
    vsphere-iso.linux-redhat-linux: > Installing additional packages ...
==> vsphere-iso.linux-redhat-linux: + sudo dnf install -y epel-release curl wget git vim net-tools unzip ca-certificates
    vsphere-iso.linux-redhat-linux: Updating Subscription Management repositories.
    vsphere-iso.linux-redhat-linux: Last metadata expiration check: 0:03:22 ago on Sun 03 Oct 2021 07:45:10 PM UTC.
    vsphere-iso.linux-redhat-linux: No match for argument: epel-release
    vsphere-iso.linux-redhat-linux: Package curl-7.61.1-18.el8_4.1.x86_64 is already installed.
    vsphere-iso.linux-redhat-linux: Package ca-certificates-2021.2.50-80.0.el8_4.noarch is already installed.
==> vsphere-iso.linux-redhat-linux: Error: Unable to find a match: epel-release
==> vsphere-iso.linux-redhat-linux: Provisioning step had errors: Running the cleanup provisioner, if present...
==> vsphere-iso.linux-redhat-linux: Power off VM...
==> vsphere-iso.linux-redhat-linux: Destroying VM...
Build 'vsphere-iso.linux-redhat-linux' errored after 11 minutes 28 seconds: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]

Screenshots

No response

Additional Context

No response

[BUG] Ubuntu 20.04 install not passing boot manager

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Project Version

22.03 (Default)

VMware vSphere

7.0 U2

HashiCorp Packer

1.8.0

HashiCorp Packer Plugin for VMware vSphere

1.0.3

Guest Operating System

Ubuntu Server 20.04 LTS

Environment Details

I am running Packer in a VM which is attached to the same network as the network I want to use when building images.
There is a DHCP server running in that VM network.

Description

When running ./build.sh and I select option 2 (Ubuntu 20.04 LTS), the VM gets created, I see in the logs that the USB device is typing, however it is not progressing past the "Boot Manager"

Expected Behavior

It should continue building (was looking at this repo via https://www.youtube.com/watch?v=0IvLnwqXFtM).

Actual Behavior

It hangs at "Boot Manager"

Steps to Reproduce

I ran the commands from the README.md. The ISO is being mounted properly by the way.

Log Fragments and Files

CONFIRM: Build a Ubuntu Server 20.04 LTS Template for VMware vSphere?

Continue? (y/n)
y
Building a Ubuntu Server 20.04 LTS Template for VMware vSphere...
Initializing HashiCorp Packer and required plugins...
Starting the build....
vsphere-iso.linux-ubuntu: output will be in this color.

==> vsphere-iso.linux-ubuntu: Creating VM...
==> vsphere-iso.linux-ubuntu: Customizing hardware...
==> vsphere-iso.linux-ubuntu: Adding SATA controller...
==> vsphere-iso.linux-ubuntu: Mounting ISO images...
==> vsphere-iso.linux-ubuntu: Adding configuration parameters...
==> vsphere-iso.linux-ubuntu: Starting HTTP server on port 8072
==> vsphere-iso.linux-ubuntu: Set boot order...
==> vsphere-iso.linux-ubuntu: Power on VM...
==> vsphere-iso.linux-ubuntu: Waiting 5s for boot...
==> vsphere-iso.linux-ubuntu: HTTP server is working at http://10.13.37.225:8072/
==> vsphere-iso.linux-ubuntu: Typing boot command...
==> vsphere-iso.linux-ubuntu: Waiting for IP...

Screenshots

image

image

Before the Boot Manager I see this:

image

Additional Context

Selecting "EFI Virtual Disk" will refresh the Boot Manager
Selecting "EFI VMware Virtual SATA CDRom Drive" will refresh the Boot Manager
Selecting "Boot normally" will show the following:
image

How to use it on one ESXI without a data center and a cluster?

How to use it on one ESXI without a data center and a cluster? if you leave the values of the variables empty, then an error.

CONFIRM: Build a Ubuntu Server 20.04 LTS Template for VMware vSphere.

Continue? (y/n)
y
Building a Ubuntu Server 20.04 LTS Template for VMware vSphere ...
Initializing Hashicorp Packer and required plugins ...
Applying the HashiCorp Packer Build ...
Error: 1 error(s) occurred:

* 'host' or 'cluster' is required

  on ubuntu-server-20-04-lts.pkr.hcl line 345:
  (source code not available)



==> Wait completed after 6 microseconds

==> Builds finished but no artifacts were created.
Done.

Add support for AlmaLinux

Description

Add enhancement to support builds of AlmaLinux.

Use Case(s)

With the change of CentOS Linux from an enterprise-stable operating system to an upstream development branch of RHEL, new projects have rushed to fill the gap left in its wake.

AlmaLinux is built and maintained by the developers at CloudLinux, a company that provides server hosting and Linux software. It's a company experienced with RHEL forks, having built and maintained their in-house distro called CloudLinux OS, a fork itself, for more than a decade. Going forward, CloudLinux promises to involve the community as much as possible when it comes to the direction of the distro.

Rocky Linux (recently added to this repo as a build) is headed up by Gregory Kurtzer, the original founder of CentOS. Rocky Linux is community-driven, and doesn't have the commercial developers on payroll the way AlmaLinux does. Depending on your point of view, this could be either a good or bad thing. One could also argue that if Kurtzer would have had CentOS' interests in mind in the first place, it wouldn't have been swallowed up by Red Hat and undergone the change in direction.

AlmaLinux and Rocky Linux naturally have a lot of similarities, but have some big differences in how they're maintained. Both distros are expected to be viable replacements for CentOS, and it probably won't make a huge difference which one you use. Being that they're both binary compatible with RHEL, you could theoretically switch between Alma and Rocky if it ever became necessary.

Potential References

The build should be very similar to RHEL and Rocky.

Add support for a SLES 15 machine image

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Description

Add SLES 15 machone image.

Use Case(s)

Any company that has standardized on SUSE Linux Enterprise Server 15.

Potential Configuration

Add SLES with the same options as other *nix distro's.

References

No response

[BUG] photon-4.0-ca7c9e933.iso timeout on `Waiting for SSH to become available...`

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Project Version

main

VMware vSphere

7.0 Update 2

HashiCorp Packer

1.7.6

HashiCorp Packer Plugin for VMware vSphere

1.0.1

Guest Operating System

Ubuntu 20.04

Environment Details

Used ISO is photon-4.0-ca7c9e933.iso

Description

When building VMware Photon OS 4 Template for VMware vSphere, SSH timeout occurs.

Expected Behavior

Successfully finish build

Actual Behavior

Build timeout

Steps to Reproduce

Log Fragments and Files

vsphere-iso.linux-photon: output will be in this color.

==> vsphere-iso.linux-photon: Creating VM...
==> vsphere-iso.linux-photon: Customizing hardware...
==> vsphere-iso.linux-photon: Adding SATA controller...
==> vsphere-iso.linux-photon: Mounting ISO images...
==> vsphere-iso.linux-photon: Adding configuration parameters...
==> vsphere-iso.linux-photon: Starting HTTP server on port 8041
==> vsphere-iso.linux-photon: Set boot order...
==> vsphere-iso.linux-photon: Power on VM...
==> vsphere-iso.linux-photon: Waiting 2s for boot...
==> vsphere-iso.linux-photon: HTTP server is working at http://172.19.36.72:8041/
==> vsphere-iso.linux-photon: Typing boot command...
==> vsphere-iso.linux-photon: Waiting for IP...
==> vsphere-iso.linux-photon: IP address: 172.19.36.43
==> vsphere-iso.linux-photon: Using SSH communicator to connect: 172.19.36.43
==> vsphere-iso.linux-photon: Waiting for SSH to become available...

Screenshots

No response

Additional Context

No SSH service is running in the installed OS.

ps -aef | grep ssh returns nothing.

2 errors at the end of build

Packer 1.7.4
Vsphere: 7.0.2

Build successfully, but at the end of the build, there were two errors, just wondering what the messages mean?

`==> vsphere-iso.linux--server: Importing VM OVF template linux--server-20-04-lts to Content Library...
==> vsphere-iso.linux--server: Destroying VM...
==> vsphere-iso.linux--server: Running post-processor: (type manifest)
Build 'vsphere-iso.linux--server' errored after 8 minutes 12 seconds: 2 error(s) occurred:

  • Post-processor failed: Unable to write ../../../manifests/2021-09-03 00:24 UTC-linux--server-20-04-lts.json: open ../../../manifests/2021-09-03 00:24 UTC-linux--server-20-04-lts.json: The system cannot find the path specified.
  • Error destroying builder artifact: reading body msgpack decode error [pos 992]: reflect.Set: value of type map[interface {}]interface {} is not assignable to type error; bad artifact: []string(nil)

==> Wait completed after 8 minutes 12 seconds

==> Some builds didn't complete successfully and had errors:
--> vsphere-iso.linux--server: 2 error(s) occurred:

  • Post-processor failed: Unable to write ../../../manifests/2021-09-03 00:24 UTC-linux--server-20-04-lts.json: open ../../../manifests/2021-09-03 00:24 UTC-linux--server-20-04-lts.json: The system cannot find the path specified.
  • Error destroying builder artifact: reading body msgpack decode error [pos 992]: reflect.Set: value of type map[interface {}]interface {} is not assignable to type error; bad artifact: []string(nil)

==> Builds finished but no artifacts were created.
Done.
`

[ENHANCEMENT] Add option to bind IP address for Packer HTTP server with Linux builds

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Description

Currently, when the build starts, the boot command references the {{ .HTTPIP }} variable, which Packers sets as what ever the IP of the first interface is.
Adding this variable allows you to specify which IP address the build will use to get it's kickstart file from.

Use Case(s)

Packer build servers that service multiple separate networks or just have multiple interfaces.

Potential Configuration

  1. Create a new variable in โ€˜builds > linux > centos-linux-8 > variables.pkr.hcl file:
    variable "common_http_bind_address" {
    type = string
    description = "Force build to use this IP to download the kickstart file."
    }

  2. Define the variable in โ€˜builds > common.pkvars.hclโ€™ file under the โ€œBoot and Provisioning Settingsโ€ '
    common_http_bind_address = "192.2.0.201"

  3. Modify the "boot_command" in the 'builds > linux > centos-linux-8 > linux-centos-linux.pkr.hclโ€™ to use the new variable
    boot_command = ["up", "e", "<down><down><end><wait>", "text inst.ks=http://${var.common_http_bind_address}:{{ .HTTPPort }}/ks.cfg", "<enter><wait><leftCtrlOn>x<leftCtrlOff>"]

References

This could be used for all builds that require the ks file to be retrieved from the http server.

[ENHANCEMENT] Allow Packer to be launched from any directory

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Description

Use the flexibiliy of path.cwd and path.root when using build.sh to allow Packer to be launched from any directory

See https://www.packer.io/docs/templates/hcl_templates/path-variables for definition of these variables.

Use Case(s)

Launch packer command from whatever directory that contains custom certificates, scripts and output manifests.

Potential Configuration

  • No change in basic configuration
  • Enable advanced customization

References

No response

Update the description of vsphere_folder variable.

When filing a bug, please include the following information.

Description

The description for the vsphere_folder variable should be updated to reflect folder vs cluster.

Current:

variable "vsphere_folder" {
  type        = string
  description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')"
}

Expected Behavior

variable "vsphere_folder" {
  type        = string
  description = "The name of the target vSphere folder. (e.g. 'sfo-w01-fd-templates')"
}

Actual Behavior

N/A

Steps to Reproduce

N/A

VMware vSphere Version

7.0.2

HashiCorp Packer Version

1.0.6

Simplified Packer Build or Variables File(s)

N/A

Guest Operating System and Environment Details

Guest Operating System

Log Fragments and crash.log Files

Additional Context

[ENHANCEMENT] Rename the directory used for guest operating configuration data

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Description

Rename the directory used for guest operating configuration data for multi-use.

Use Case(s)

  • Common Name
  • Implementation Independent

Potential Configuration

  • build/data/
  • build/config/
source_content = {
    "/meta-data" = file("data/meta-data")
    "/user-data" = templatefile("data/user-data.pkrtpl.hcl", { build_username = var.build_username, build_password_encrypted = var.build_password_encrypted, vm_guest_os_language = var.vm_guest_os_language, vm_guest_os_keyboard = var.vm_guest_os_keyboard, vm_guest_os_timezone = var.vm_guest_os_timezone })
  }

References

No response

[ENHANCEMENT] Add Ubuntu 22.04 LTS

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Description

New Ubuntu LTS will be released soon.

Use Case(s)

Use Ubuntu LTS 22.04.

Potential Configuration

Add builds/linux/ubuntu/22.04 build folder.

References

No response

Add support for CentOS Stream 8

Description

The future of the CentOS Project is CentOS Stream, and over the next year weโ€™ll be shifting focus from CentOS Linux, the rebuild of Red Hat Enterprise Linux (RHEL), to CentOS Stream, which tracks just ahead of a current RHEL release.

Read the rest of the announcement.

Use Case(s)

CentOS Linux 8, as a rebuild of RHEL 8, will end at the end of 2021. CentOS Stream continues after that date, serving as the upstream development branch of Red Hat Enterprise Linux.

Potential Configuration

# Maintainer: [email protected]
# Packer template for CentOS Stream 8.
# https://www.packer.io/docs/builders/vsphere/vsphere-iso

##################################################################################
# PACKER
##################################################################################

packer {
  required_version = ">= 1.7.3"
}

##################################################################################
# VARIABLES
##################################################################################

# Credentials.

variable "vcenter_username" {
  type    = string
  description = "The username to login to the vCenter Server instance. (e.g. [email protected])"
  default = ""
  sensitive = true
}

variable "vcenter_password" {
  type      = string
  description = "The password for the login to the vCenter Server instance."
  default = ""
  sensitive = true
}

variable "build_username" {
  type    = string
  description = "The username to login to the guest operating system. (e.g. rainpole)"
  default = ""
  sensitive = true
}

variable "build_password" {
  type    = string
  description = "The password to login to the guest operating system."
  default = ""
  sensitive = true
}

# vSphere Objects

variable "vcenter_insecure_connection" {
  type    = bool
  description = "Do not validate vCenter Server TLS certificate."
  default = true
}

variable "vcenter_server" {
  type    = string
  description = "The fully qualified domain name or IP address of the vCenter Server instance. (e.g. 'sfo-w01-vc01.sfo.rainpole.io')"
  default = ""
}

variable "vcenter_datacenter" {
  type    = string
  description = "The name of the target vSphere datacenter. (e.g. 'sfo-w01-dc01')"
  default = ""
}

variable "vcenter_cluster" {
  type    = string
  description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-cl01')"
  default = ""
}

variable "vcenter_datastore" {
  type    = string
  description = "The name of the target vSphere datastore. (e.g. 'sfo-w01-cl01-vsan01')"
  default = ""
}

variable "vcenter_network" {
  type    = string
  description = "The name of the target vSphere network segment. (e.g. 'sfo-w01-dhcp')"
  default = ""
}

variable "vcenter_folder" {
  type    = string
  description = "The name of the target vSphere cluster. (e.g. 'sfo-w01-fd-templates')"
  default = ""
}

variable "vcenter_content_library" {
  type    = string
  description = "The name of the target vSphere content library, if used. (e.g. 'sfo-w01-cl01-lib01')"
  default = ""
}

# ISO Objects

variable "iso_datastore" {
  type    = string
  description = "The name of the source vSphere datastore for ISO images. (e.g. 'sfo-w01-cl01-nfs01')"
  default = ""
  }

variable "iso_path" {
  type    = string
  description = "The path on the source vSphere datastore for ISO images. (e.g. 'iso')"
  default = ""
  }

variable "iso_file" {
  type    = string
  description = "The file name of the ISO image. (e.g. 'iso-centos-stream-8.iso')"
  default = ""
}

variable "iso_checksum" {
  type    = string
  description = "The SHA-512 checkcum of the ISO image. (e.g. Result of 'shasum -a 512 iso-centos-stream-8.iso')"
  default = ""
}

# HTTP Endpoint for Kickstart

variable "http_directory" {
  type    = string
  description = "The HTTP endpoint directory path. (e.g. ../../../configs/linux/centos-server/)"
  default = ""
}

variable "http_file" {
  type    = string
  description = "The guest operating system kickstart file. (e.g. ks.cfg)"
  default = ""
}

# Virtual Machine Settings

variable "vm_guest_os_family" {
  type    = string
  description = "The guest operatiing system family. Used for naming and VMware tools. (e.g.'linux')"
  default = ""
}

variable "vm_guest_os_vendor" {
  type    = string
  description = "The guest operatiing system vendor. Used for naming . (e.g. 'centos')"
  default = ""
}

variable "vm_guest_os_member" {
  type    = string
  description = "The guest operatiing system member. Used for naming. (e.g. 'stream')"
  default = ""
}

variable "vm_guest_os_version" {
  type    = string
  description = "The guest operatiing system version. Used for naming. (e.g. '8')"
  default = ""
}

variable "vm_guest_os_type" {
  type    = string
  description = "The guest operating system type, also know as guestid. (e.g. 'centos8_64Guest')"
  default = ""
}

variable "vm_version" {
  type    = number
  description = "The vSphere virtual hardware version. Refer to https://kb.vmware.com/kb/1003746. (e.g. '18')"
  default = 18
}

variable "vm_firmware" {
  type    = string
  description = "The virtual machine firmware. (e.g. 'bios' or 'efi')"
  default = "bios"
}

variable "vm_cdrom_type" {
  type    = string
  description = "The virtual machine CD-ROM type. (e.g. 'sata', or 'ide')"
  default = "sata"
}

variable "vm_cpu_sockets" {
  type    = number
  description = "The number of virtual CPUs sockets. (e.g. '2')"
  default = 2
}

variable "vm_cpu_cores" {
  type    = number
  description = "The number of virtual CPUs cores per socket. (e.g. '1')"
  default = 1
}

variable "vm_mem_size" {
  type    = number
  description = "The size for the virtual memory in MB. (e.g. '2048')"
  default = 2048
}

variable "vm_disk_size" {
  type    = number
  description = "The size for the virtual disk in MB. (e.g. '40960')"
  default = 40960
}

variable "vm_disk_controller_type" {
  type    = list(string)
  description = "The virtual disk controller types in sequence. (e.g. 'pvscsi')"
  default = ["pvscsi"]
}

variable "vm_network_card" {
  type    = string
  description = "The virtual network card type. (e.g. 'vmxnet3' or 'e1000e')"
  default = "vmxnet3"
}

variable "vm_boot_wait" {
  type    = string
  description = "The time to wait before boot. "
  default = "2s"
}

variable "shell_scripts" {
  type    = list(string)
  description = "A list of script and their relative paths to transfer and execute using SSH."
  default = []
}

##################################################################################
# LOCALS
##################################################################################

locals { 
  buildtime = formatdate("YYYY-MM-DD hh:mm ZZZ", timestamp())
  }

##################################################################################
# SOURCE
##################################################################################

source "vsphere-iso" "linux-centos-stream" {
  vcenter_server       = var.vcenter_server
  username             = var.vcenter_username
  password             = var.vcenter_password
  datacenter           = var.vcenter_datacenter
  cluster              = var.vcenter_cluster
  datastore            = var.vcenter_datastore
  folder               = var.vcenter_folder
  insecure_connection  = var.vcenter_insecure_connection
  tools_upgrade_policy = true
  remove_cdrom         = true
  convert_to_template  = true
  guest_os_type        = var.vm_guest_os_type
  vm_version           = var.vm_version
  notes                = "Built by HashiCorp Packer on ${local.buildtime}."
  vm_name              = "${var.vm_guest_os_family}-${var.vm_guest_os_vendor}-${var.vm_guest_os_member}-${var.vm_guest_os_version}"
  firmware             = var.vm_firmware
  CPUs                 = var.vm_cpu_sockets
  cpu_cores            = var.vm_cpu_cores
  CPU_hot_plug         = false
  RAM                  = var.vm_mem_size
  RAM_hot_plug         = false
  cdrom_type           = var.vm_cdrom_type
  disk_controller_type = var.vm_disk_controller_type
  storage {
    disk_size             = var.vm_disk_size
    disk_controller_index = 0
    disk_thin_provisioned = true
  }
  network_adapters {
    network      = var.vcenter_network
    network_card = var.vm_network_card
  }
  iso_paths                = ["${ var.iso_datastore }${ var.iso_path }/${ var.iso_file }"]
  iso_checksum             = "sha512:var.iso_checksum"
  http_directory           = var.http_directory
  boot_order               = "disk,cdrom"
  boot_wait                = var.vm_boot_wait
  boot_command             = ["<tab>","text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/${var.http_file}","<enter><wait>"]
  ip_wait_timeout          = "20m"
  ssh_password             = var.build_password
  ssh_username             = var.build_username
  ssh_port                 = 22
  ssh_timeout              = "20m"
  ssh_handshake_attempts   = "20"
  shutdown_command         = "echo '${var.build_password}' | sudo -S -E shutdown -P now"
  shutdown_timeout         = "15m"
  /*
  Comment or remove the option below to exclude the use of the vSphere content library.
  - If ovf = true - the virtual machine image is exported to the target content library.
  - If destroy = true - the virtual machine image is destroyed after a successfully exported the target content library
  - By default, the target name is the vm_name unless name = "foo" is provided.
  - The content library item is updated if the target name is the same. 
  */
  content_library_destination {
    library = var.vcenter_content_library
    ovf     = true
    destroy = true
  }
}

##################################################################################
# BUILD
##################################################################################

build {
  sources = ["source.vsphere-iso.linux-centos-server"]
  /*
  Uses the File Provisioner to copy the public key.
  - The Shell Provisioner will execute a script that imports the public key to authorized_keys to the build user.
  */ 
  provisioner "file" {
    destination = "/tmp/id_ecdsa.pub"
    source = "../../../keys/id_ecdsa.pub"
  }
  /*
  Uses the File Provisioner to copy the .crt certificate for the Root Certificate Authority.
  - The Shell Provisioner will execute a script that imports the certificate to the Certificate Authority Trust.
  */ 
   provisioner "file" {
    destination = "/tmp/root-ca.crt"
    source = "../../../certificates/root-ca.crt"
  }
  // Uses the Shell Provisioner to execute a series of inline commands defined in the variables
  provisioner "shell" {
    execute_command = "echo '${var.build_password}' | {{.Vars}} sudo -E -S sh -eux '{{.Path}}'"
    environment_vars = [
      "BUILD_USERNAME=${var.build_username}"
    ]
    scripts = var.shell_scripts
  }
}

and

# Maintainer: [email protected]
# Packer template for CentOS Stream 8.

##################################################################################
# VARIABLES
##################################################################################

# HTTP Endpoint for Kickstart

http_directory = "../../../configs/linux/centos-server"
http_file      = "ks-v8.cfg"

# Virtual Machine Settings

vm_guest_os_family          = "linux" 
vm_guest_os_vendor          = "centos"
vm_guest_os_member          = "stream" 
vm_guest_os_version         = "8" 
vm_guest_os_type            = "centos8_64Guest" 
vm_version                  = 18
vm_firmware                 = "bios"
vm_cdrom_type               = "sata"
vm_cpu_sockets              = 2
vm_cpu_cores                = 1
vm_mem_size                 = 2048
vm_disk_size                = 40960
vm_disk_controller_type     = ["pvscsi"]
vm_network_card             = "vmxnet3"
vm_boot_wait                = "2s"

# ISO Objects

iso_file     = "iso-linux-centos-stream-8.iso"
iso_checksum = "552cf5dcdc9d3db41791a2b3bbbd18335d75607ca54e7aa8bf28a6ea1d49ce914a55da0bd839123aa96654b7de6db65cc786beb71e6233982ea96ce456a47035"

# Scripts

shell_scripts = ["../../../scripts/linux/centos-stream-cleanup.sh"]

Community Note

Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the maintainers prioritize this request.

Please do not leave "+1" or "me too" comments. These generate noise for issue followers and do not help prioritize the request.

[ENHANCEMENT] Add a configurable build script

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Description

The current build script is difficult to maintain when adding or sorting builds.

Use Case(s)

The build script is configurable with a configuration file.

Potential Configuration

  • Build configuration file to generate build script

References

No response

CPU <> Sockets

I am trying to configure the vsphere template that i have for example 4 CPUs.
image

Can you advice?

Update all guestOS types for machine images in this repository to use only their "(Recommended)" firmware settings based on vSphere version support in this repository.

Description

Update all guestOS types for machine images in this repository to use only their "(Recommended)" firmware settings based on vSphere version support in this repository.

efi-secure

  • Windows Server 2019 - vm_guest_os_type = "windows2019srv_64Guest"
  • Windows Server 2016 - vm_guest_os_type = "windows9Server64Guest"
  • Red Hat Enterprise Linux 8 Server - vm_guest_os_type = "rhel8_64Guest"
  • CentOS Stream 8 Server - vm_guest_os_type = "centos8_64Guest"
  • CentOS Linux 8 Server - vm_guest_os_type = "centos8_64Guest"
  • AlmaLinux 8 Server - vm_guest_os_type = "centos8_64Guest"

bios

  • VMware Photon OS 4 - vm_guest_os_type = "vmwarePhoton64Guest"
  • VMware Photon OS 3 - vm_guest_os_type = "vmwarePhoton64Guest"
  • Red Hat Enterprise Linux 7 Server - vm_guest_os_type = "rhel7_64Guest"
  • Ubuntu Server 20.04 LTS - vm_guest_os_type = "ubuntu64Guest"
  • Ubuntu Server 18.04 LTS - vm_guest_os_type = "ubuntu64Guest"
  • CentOS Linux 7 Server - vm_guest_os_type = "centos7_64Guest"
  • Rocky Linux 8 Server - vm_guest_os_type = "centos8_64Guest"

Note: Rocky Linux 8 Server will not boot into EFI even though it is centos8_64Guest

Use Case(s)

Ensure all machine images use the recommended firmware based on vSphere version support in this repository.

Community Note

Please vote on this issue by adding a ๐Ÿ‘ reaction to the original issue to help the maintainers prioritize this request.

Please do not leave "+1" or "me too" comments. These generate noise for issue followers and do not help prioritize the request.

Ubuntu autoinstall

Nice repo !

I am trying to make Packer1.7+vSphere7.0.2 working together to create image of Ubuntu 2004, for some reason, it was waiting for getting IP address from DHCP, then after times out (no IP received) , the installation part started, but it wont auto install, it stopped at language selection screen.

Any details on how to make it work around these points?

Thanks

[ENHANCEMENT] Simply manifest output

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Description

In the README.md, Packer manifests are in manifests folder.

manifests - manifests created after the completion of each build.

However, the current manifests are stored (and not ignored by GItHub) in an output directory relative to the running build.

To do so, use Packer path variable to output manifest in /manifests folder.

Use Case(s)

Store manifests in a central location for the user.

Potential Configuration

  • Move manifests back to the /manifests directory.
  • Place a .gitkeep in the /manifests directory.
  • Add a .gitignore to the /manifests directory that ignores .json output.

References

No response

Photon OS 3.0 builds fail due to incorrect package repo

When filing a bug, please include the following information.

Description

VMware recently migrated Photon OS to a new package repository and for existing 3.x ISO images, users must point to the new repo which is now located at packages.vmware.com (previously hosted on bintray)

Expected Behavior

Successfully complete tdnf -y update along installing any other packages

Actual Behavior

Failed to retrieve updates as the package repository is incorrect

==> vsphere-iso.linux-photon-server: Error: 401 when downloading https://dl.bintray.com/vmware/photon_release_3.0_x86_64/repodata/repomd.xml
==> vsphere-iso.linux-photon-server: . Please check repo url.
==> vsphere-iso.linux-photon-server: Error: Failed to synchronize cache for repo 'VMware Photon Linux 3.0(x86_64)' from 'https://dl.bintray.com/vmware/photon_release_3.0_x86_64'
==> vsphere-iso.linux-photon-server: Error: 401 when downloading https://dl.bintray.com/vmware/photon_updates_3.0_x86_64/repodata/repomd.xml
==> vsphere-iso.linux-photon-server: . Please check repo url.
==> vsphere-iso.linux-photon-server: Error: Failed to synchronize cache for repo 'VMware Photon Linux 3.0(x86_64) Updates' from 'https://dl.bintray.com/vmware/photon_updates_3.0_x86_64'
==> vsphere-iso.linux-photon-server: Error: 401 when downloading https://dl.bintray.com/vmware/photon_extras_3.0_x86_64/repodata/repomd.xml
==> vsphere-iso.linux-photon-server: . Please check repo url.
==> vsphere-iso.linux-photon-server: Error: Failed to synchronize cache for repo 'VMware Photon Extras 3.0(x86_64)' from 'https://dl.bintray.com/vmware/photon_extras_3.0_x86_64'
==> vsphere-iso.linux-photon-server: Error(1011) : No matching packages

Steps to Reproduce

Run the default VMware Photon OS 3 build

VMware vSphere Version

vSphere 7.0 Update 1 Build 16858589

HashiCorp Packer Version

1.6.5

Simplified Packer Build or Variables File(s)

N/A

Guest Operating System and Environment Details

Photon OS 3.0 Rev 2 - photon-3.0-a0f216d.iso

https://packages.vmware.com/photon/3.0/Rev2/iso/Update2/photon-3.0-a0f216d.iso

Guest Operating System

N/A

Log Fragments and crash.log Files

N/A

Additional Context

N/A

Network disconnected in Ubuntu

Description

After creating a virtual machine from the Ubuntu 20.04 template. The network adapter in the cloned virtual machine is in the disconnected status. (There is no network assigned to this virtual machine.)

Steps to Reproduce
Create a template with Ubuntu 20.04.
Create VM from Template.

VMware vSphere Version
7.0.2

HashiCorp Packer Version
Packer version: 1.7.3 [go1.16.5 darwin amd64]

Guest Operating System and Environment Details
MacOS 11.4

Guest Operating System
Ubuntu Server 20.04.2 LTS

[BUG] Parallel package upgrades for Ubuntu 20.04

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

VMware vSphere

Any

HashiCorp Packer

1.7.5

HashiCorp Packer Plugin for VMware vSphere

1.0.1

Guest Operating System

macOS Big Sur 11.6 (Intel)

Environment Details

No response

Description

During image building, cloud-init (from user-data) and provisionner (from build target) are launching apt update/upgrade at the same time.

Expected Behavior

Package update/upgrade should be done once.

Actual Behavior

Package update/upgrade are launched in parallel:

  • One is launched from cloud-init
  user-data:
    disable_root: false
    package_update: true
    package_upgrade: true
    package_reboot_if_required: true
  • Another is launched with provisionner script
### Update the guest operating system. ###
echo '> Updating the guest operating system ...'
sudo apt-get update
sudo apt-get upgrade -y

Steps to Reproduce

Build Ubuntu 20.04 image

Log Fragments and Files

==> vsphere-iso.linux-ubuntu-server: Provisioning with shell script: ../../../scripts/linux/ubuntu-server-2x.sh
==> vsphere-iso.linux-ubuntu-server: + export BUILD_USERNAME
==> vsphere-iso.linux-ubuntu-server: + export BUILD_KEY
    vsphere-iso.linux-ubuntu-server: > Updating the guest operating system ...
==> vsphere-iso.linux-ubuntu-server: + export ANSIBLE_USERNAME
==> vsphere-iso.linux-ubuntu-server: + export ANSIBLE_KEY
==> vsphere-iso.linux-ubuntu-server: + echo > Updating the guest operating system ...
==> vsphere-iso.linux-ubuntu-server: + sudo apt-get update
    vsphere-iso.linux-ubuntu-server: Hit:1 http://lu.archive.ubuntu.com/ubuntu focal InRelease
    vsphere-iso.linux-ubuntu-server: Hit:2 http://lu.archive.ubuntu.com/ubuntu focal-updates InRelease
    vsphere-iso.linux-ubuntu-server: Hit:3 http://lu.archive.ubuntu.com/ubuntu focal-backports InRelease
    vsphere-iso.linux-ubuntu-server: Hit:4 http://lu.archive.ubuntu.com/ubuntu focal-security InRelease
    vsphere-iso.linux-ubuntu-server: Reading package lists...
==> vsphere-iso.linux-ubuntu-server: + sudo apt-get upgrade -y
==> vsphere-iso.linux-ubuntu-server: E: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 2078 (apt-get)
==> vsphere-iso.linux-ubuntu-server: E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
==> vsphere-iso.linux-ubuntu-server: Script exited with non-zero exit status: 100.Allowed exit codes are: [0]

Screenshots

No response

Additional Context

I suggest (and I can create PR for) to remove packages update/upgrade from cloud-init's user-data, because I didn't find any KISS solution to know when cloud-init ends.

So, the resulting user-data would be as follow.

  user-data:
    disable_root: false

[BUG] Building Ubuntu 18 fails - cant find /install/vmlinuz

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Project Version

21.11 (Default)

VMware vSphere

7.0 Update 2

HashiCorp Packer

1.7.8

HashiCorp Packer Plugin for VMware vSphere

1.0.2

Guest Operating System

Ubuntu Server 18.04.6

Environment Details

No response

Description

Building failes

Expected Behavior

Building is successful

Actual Behavior

Building failes

Steps to Reproduce

Build

Log Fragments and Files

No response

Screenshots

image

Additional Context

rh

Option to use static IP assignment during machine image builds.

Community Note

Description:

Please add an option in the examples to support static IP addresses during machine image builds.

Use Case(s):

DHCP is not always available within the datacenter environment.

Potential Configuration:

None offered.

Potential References:

None offered.

when i run the build getting error below

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Project Version

main

VMware vSphere

6.7

HashiCorp Packer

1.7.10

HashiCorp Packer Plugin for VMware vSphere

1.0.3

Guest Operating System

RHEL 7.9

Environment Details

when i run the build getting - error creating vm: A component of the virtual machine is not accessible on the host.

Description

Build 'vsphere-iso.linux-rhel' errored after 87 milliseconds 506 microseconds: error creating vm: A component of the virtual machine is not accessible on the host.

Expected Behavior

Build 'vsphere-iso.linux-rhel' errored after 87 milliseconds 506 microseconds: error creating vm: A component of the virtual machine is not accessible on the host.

Actual Behavior

Build 'vsphere-iso.linux-rhel' errored after 87 milliseconds 506 microseconds: error creating vm: A component of the virtual machine is not accessible on the host.

Steps to Reproduce

just run the build

Log Fragments and Files

No response

Screenshots

No response

Additional Context

No response

SSH settings in ubuntu "user data" file

The current settings for ssh in [user data] file for ubuntu is below

ssh: install-server: true authorized-keys: - ecdsa-sha2-nistp521 ............. allow-pw: true

according to doc here

allow-pw should set to false if authorized-key is in use.

Please verify

[ENHANCEMENT] Support for a Packer host behind a proxy.

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Description

Discussed in #39

Use Case(s)

Discussed in #39

Potential Configuration

ssh_proxy_host (string) - A SOCKS proxy host to use for SSH connection

ssh_proxy_port (int) - A port of the SOCKS proxy. Defaults to 1080.

ssh_proxy_username (string) - The optional username to authenticate with the proxy server.

ssh_proxy_password (string) - The optional password to use to authenticate with the proxy server.

References

https://www.packer.io/docs/builders/vsphere/vsphere-iso#ssh_proxy_host

[BUG] Possible IP address collision on the DHCP/DNS server when building all Windows images at the same time

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

VMware vSphere

7.0 Update 2

HashiCorp Packer

1.7.6

HashiCorp Packer Plugin for VMware vSphere

1.0.1

Guest Operating System

macOS Big Sur (Intel)

Environment Details

No response

Description

When building multiple images from the same configuration (i.e. windows-server-*) at the same time, the DHCP server receives the same hostname for each created VM.

Expected Behavior

Packer could create the VMs with different names.

Actual Behavior

Packer creates the VMs with the same name.

Steps to Reproduce

  • Launch build.sh script
  • Select Windows Server * - All option

Log Fragments and Files

No response

Screenshots

No response

Additional Context

No response

[BUG] Missing "manifest" directory after git clone

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

VMware vSphere

7.0 Update 2

HashiCorp Packer

1.7.4

HashiCorp Packer Plugin for VMware vSphere

1.0.1

Guest Operating System

CentOS 8.4

Environment Details

No response

Description

Hello, and thank you for this wonderful work.

Nothing serious, but when git cloning this repo, the manifest directory is missing at the root level (probably because git does not allow empty dirs).
Maybe you could add a ".placehoder" file in the manifest dir and commit it?

Expected Behavior

A packer run should be able to write its manifest in the end.

Actual Behavior

Missing manifest dir leads to everything working fine (the template is generated), but as the manifest can not be written, the whole operation appears as a failure, and the template is cleaned (too bad).

Steps to Reproduce

Just clone the repo, adjust according to the README, launch it, and witness the sad end.

Log Fragments and Files

[...]
Build 'vsphere-iso.linux-ubuntu-server' errored after 5 minutes 40 seconds: 1 error(s) occurred:

  • Post-processor failed: Unable to write ../../../manifests/2021-09-15 13:43 UTC-linux-ubuntu-server-20-04-lts.json: open ../../../manifests/2021-09-15 13:43 UTC-linux-ubuntu-server-20-04-lts.json: no such file or directory

Screenshots

No response

Additional Context

No response

Add support for a Debian 11 machine image

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Description

Hello,

here i'm proposing the addition of a templated for Debian/Linux.

I'm already in an advanced state of creation of the configuration for the latest LTS: Debian 11

I would kindly ask your support for advancing in the configuration as i'm encountering a strange issue with the keyboard input at installation startup.

I've produced myself a complete and working boot_command that i am already using with packer+vsphere with the official packer examples, but when i plug what i developed on your work and spin up the server, after ISO boot, the boot_command seems to not be input correctly (maybe due to some keyboard misconfiguration)

Do you have any advice that could help me debugging it futherly?

Use Case(s)

Potential Configuration

References

[ENHANCEMENT] Update ISO file to 20.04.4 on Ubuntu 20.04 build

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Description

Ubuntu 20.04.4 has been released, so update ISO file on Ubuntu 20.04 build.

Use Case(s)

Use Ubuntu 20.04.4 ISO file

Potential Configuration

Update iso_file and iso_checksum in `builds/linux/ubuntu/20-04-lts/linux-ubuntu.auto.pkrvars.hcl.

References

No response

Stopped at "Waiting for SSH to become available....

When filing a bug, please include the following information.

Description
Stopped at "Waiting for SSH to become available.... then times out with error

"Error waiting for SSH: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain""

Steps to Reproduce

VMware vSphere Version

vSphere 7.0.2

HashiCorp Packer Version

Packer 1.7.3

Simplified Packer Build or Variables File(s)

I only changed the credential in pakvar.hcl to connect to my vCenter, which works fine.
I replaced "authorized-keys" value in [user data] file and replaced the key in [keys] folder
Nothing else changed, I kept build_username & build_password unchanged.

Guest Operating System and Environment Details

Ubuntu 20.04
Environment was untouched from var file

Log Fragments and crash.log Files

2021/07/14 23:41:40 packer.exe plugin: [INFO] Attempting SSH connection to 10.10.110.235:22...
2021/07/14 23:41:40 packer.exe plugin: [DEBUG] reconnecting to TCP connection for SSH
2021/07/14 23:41:40 packer.exe plugin: [DEBUG] handshaking with SSH
2021/07/14 23:41:44 packer.exe plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2021/07/14 23:41:44 packer.exe plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2021/07/14 23:41:51 packer.exe plugin: [INFO] Attempting SSH connection to 10.10.110.235:22...
2021/07/14 23:41:51 packer.exe plugin: [DEBUG] reconnecting to TCP connection for SSH
2021/07/14 23:41:51 packer.exe plugin: [DEBUG] handshaking with SSH
2021/07/14 23:41:53 packer.exe plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2021/07/14 23:41:53 packer.exe plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2021/07/14 23:42:00 packer.exe plugin: [INFO] Attempting SSH connection to 10.10.110.235:22...
2021/07/14 23:42:00 packer.exe plugin: [DEBUG] reconnecting to TCP connection for SSH
2021/07/14 23:42:00 packer.exe plugin: [DEBUG] handshaking with SSH
2021/07/14 23:42:03 packer.exe plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2021/07/14 23:42:03 packer.exe plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2021/07/14 23:42:10 packer.exe plugin: [INFO] Attempting SSH connection to 10.10.110.235:22...
2021/07/14 23:42:10 packer.exe plugin: [DEBUG] reconnecting to TCP connection for SSH
2021/07/14 23:42:10 packer.exe plugin: [DEBUG] handshaking with SSH
2021/07/14 23:42:14 packer.exe plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2021/07/14 23:42:14 packer.exe plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2021/07/14 23:42:14 ui error: ==> vsphere-iso.linux--server: Error waiting for SSH: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain
2021/07/14 23:42:14 ui: ask: ==> vsphere-iso.linux--server: Pausing before cleanup of step 'StepWaitForIp'. Press enter to continue.
2021/07/14 23:42:14 ui: ask: ==> vsphere-iso.linux--server: Pausing before cleanup of step 'StepBootCommand'. Press enter to continue.
2021/07/14 23:42:20 ui: ask: ==> vsphere-iso.linux--server: Pausing before cleanup of step 'StepRun'. Press enter to continue.
2021/07/14 23:42:21 ui: ==> vsphere-iso.linux--server: Power off VM...

Additional Context

while waiting for SSH to become available, i can ping the vm, i was trying to ssh into the vm directly by using

build_username = "rainpole"
build_password = "R@in!$aG00dThing."

Access was denied, "You dont have permission to connect"

[BUG] Typo in `autounattend.pkrtpl.hcl`

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

VMware vSphere

7.0 Update 2

HashiCorp Packer

1.7.6

HashiCorp Packer Plugin for VMware vSphere

1.0.1

Guest Operating System

macOS Big Sur (intel)

Environment Details

No response

Description

The letter e is present in the autounattend.pkrtpl.hcl template.

<SystemLocale>e${vm_guest_os_language}</SystemLocale>

Expected Behavior

N/A

Actual Behavior

N/A

Steps to Reproduce

N/A

Log Fragments and Files

No response

Screenshots

No response

Additional Context

No response

Problem deploying Windows templates

Discussed in https://github.com/rainpole/packer-vsphere/discussions/119

Originally posted by na2626 October 11, 2021
Hello,
I'm trying to build some windows server templates but the process fails with error:
`CONFIRM: Build Microsoft Windows Server 2022 Datacenter Templates for VMware vSphere.

Continue? (y/n)
y
Building Microsoft Windows Server 2022 Datacenter Templates for VMware vSphere ...
Initializing Hashicorp Packer and required plugins ...
Starting the HashiCorp Packer build ...
Error: Failed preparing post-processor-block "manifest" ""

on /home/my-user/packer/projects/-vsphere-templates/builds/windows/windows-server-2022/windows-server.pkr.hcl line 428:
(source code not available)

/home/my-user/packer/projects/-vsphere-templates/builds/windows/windows-server-2022/windows-server.pkr.hcl:433,37-54:
Unsupported attribute; This object does not have an attribute named
"ansible_username".

Error: Failed preparing post-processor-block "manifest" ""

on /home/my-user/packer/projects/-vsphere-templates/builds/windows/windows-server-2022/windows-server.pkr.hcl line 428:
(source code not available)

/home/my-user/packer/projects/-vsphere-templates/builds/windows/windows-server-2022/windows-server.pkr.hcl:433,37-54:
Unsupported attribute; This object does not have an attribute named
"ansible_username".

==> Wait completed after 2 microseconds

==> Builds finished but no artifacts were created.
`

Any ideas to try to solve the issue?

Thank you very much for your great work!

Kind regards

[Bug] v21.09.x Ubuntu Server 20.04 IP changes after reboot causing failures

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

VMware vSphere

7.0.2

HashiCorp Packer

1.7.4

HashiCorp Packer Plugin for VMware vSphere

1.0.1

Guest Operating System

Ubuntu 20.04

Environment Details

Building ubunto 20.04 image
vSphere 7.0.2
Packer 1.7.4
Terraform 1.0.7
Remote PC: Win10
Everything is in the same subnet: 172.16.2.x including: DNS, DHCP, vCetner, ESXI & Win10PC

Description

The previous release worked fine till today. I built images 20 days ago, but failed today, nothing changed....It failed at below

"sudo apt-get upgrade y"
"APT-GET upgrade could not get lock /var/lib/dpkg/lock-frontend. It is held by process 1935 (apt-get)"

So I downloaded the new release to try it out. the issue is DHCP IP address changes after server reboot.
==> vsphere-iso.linux-ubuntu-server: HTTP server is working at http://172.16.2.200:8078/ ==> vsphere-iso.linux-ubuntu-server: Typing boot command... ==> vsphere-iso.linux-ubuntu-server: Waiting for IP... ==> vsphere-iso.linux-ubuntu-server: IP address: 172.16.2.249 ==> vsphere-iso.linux-ubuntu-server: Using SSH communicator to connect: 172.16.2.249 ==> vsphere-iso.linux-ubuntu-server: Waiting for SSH to become available...

First I got an IP 172.16.2.249, then waiting for SSH to connect, there was no response after a long time waiting, so I logged in and checked the IP, turned out the server got a different IP address. 172.16.2.250

I tired 3 times, all the same issue.

Expected Behavior

Expected behavior:

Stay with the same IP

Actual Behavior

Server got a different IP after reboot

Steps to Reproduce

I only changed the vcenter variables in the code, everything else remained the same.

Log Fragments and Files

==> vsphere-iso.linux-ubuntu-server: Creating VM...
==> vsphere-iso.linux-ubuntu-server: Customizing hardware...
==> vsphere-iso.linux-ubuntu-server: Adding SATA controller...
==> vsphere-iso.linux-ubuntu-server: Mounting ISO images...
==> vsphere-iso.linux-ubuntu-server: Adding configuration parameters...
==> vsphere-iso.linux-ubuntu-server: Starting HTTP server on port 8078
==> vsphere-iso.linux-ubuntu-server: Set boot order...
==> vsphere-iso.linux-ubuntu-server: Power on VM...
==> vsphere-iso.linux-ubuntu-server: Waiting 5s for boot...
==> vsphere-iso.linux-ubuntu-server: HTTP server is working at http://172.16.2.200:8078/
==> vsphere-iso.linux-ubuntu-server: Typing boot command...
==> vsphere-iso.linux-ubuntu-server: Waiting for IP...
==> vsphere-iso.linux-ubuntu-server: IP address: 172.16.2.249
==> vsphere-iso.linux-ubuntu-server: Using SSH communicator to connect: 172.16.2.249
==> vsphere-iso.linux-ubuntu-server: Waiting for SSH to become available...
==> vsphere-iso.linux-ubuntu-server: Timeout waiting for SSH.
==> vsphere-iso.linux-ubuntu-server: Power off VM...
==> vsphere-iso.linux-ubuntu-server: Destroying VM...
Build 'vsphere-iso.linux-ubuntu-server' errored after 31 minutes 12 seconds: Timeout waiting for SSH.

==> Wait completed after 31 minutes 12 seconds

==> Some builds didn't complete successfully and had errors:
--> vsphere-iso.linux-ubuntu-server: Timeout waiting for SSH.

==> Builds finished but no artifacts were created.
Done.

Screenshots

No response

Additional Context

No response

[BUG] Almalinux deployment fails to find ansible python interpreter

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Project Version

22.03 (Default)

VMware vSphere

7.0 Update 2

HashiCorp Packer

1.8.0

HashiCorp Packer Plugin for VMware vSphere

1.0.3

Guest Operating System

Almalinux 8

Environment Details

Cloned repo to a fresh Ubuntu 20.04 LTS deployment, ran through the pre-reqs

Alma ISO variables

// Removable Media Settings
iso_path           = "_isos/linux"
iso_file           = "AlmaLinux-8.5-x86_64-dvd.iso"
iso_checksum_type  = "md5"
iso_checksum_value = "f83ac836e4f4279ef903f1028263640c"

Description

I've been running through each of the OS Template deployments, and so far everything has been going fine. However, I've gotten to Almalinux and while Rocky deployed without any issues, Almalinux is failing to find the ansible python interpreter at the hardcoded path of /usr/bin/python3

I believe it needs to point to /usr/libexec/platform-python instead

Expected Behavior

Deployment finishes successfully

Actual Behavior

Deployment fails when gathering facts for Ansible configuration

   vsphere-iso.linux-almalinux: TASK [Gathering Facts] *********************************************************
    vsphere-iso.linux-almalinux: fatal: [default]: FAILED! => {"<sensitive>_facts": {}, "changed": false, "failed_modules": {"setup": {"failed": true, "module_stderr": "/bin/sh: /usr/bin/python3: No such file or directory\nShared connection to 127.0.0.1 closed.\r\n", "module_stdout": "", "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error", "rc": 127}}, "msg": "The following modules failed to execute: setup\n"}

Steps to Reproduce

  1. Clone repo
  2. Upload ISOs
  3. Create config files
  4. Start Build script
  5. Select Almalinux

Log Fragments and Files

Building an AlmaLinux OS 8 Template for VMware vSphere...
Initializing HashiCorp Packer and required plugins...
Starting the build....
vsphere-iso.linux-almalinux: output will be in this color.

==> vsphere-iso.linux-almalinux: Creating VM...
==> vsphere-iso.linux-almalinux: Customizing hardware...
==> vsphere-iso.linux-almalinux: Adding SATA controller...
==> vsphere-iso.linux-almalinux: Mounting ISO images...
==> vsphere-iso.linux-almalinux: Adding configuration parameters...
==> vsphere-iso.linux-almalinux: Starting HTTP server on port 8050
==> vsphere-iso.linux-almalinux: Set boot order...
==> vsphere-iso.linux-almalinux: Power on VM...
==> vsphere-iso.linux-almalinux: Waiting 2s for boot...
==> vsphere-iso.linux-almalinux: HTTP server is working at http://172.16.38.102:8050/
==> vsphere-iso.linux-almalinux: Typing boot command...
==> vsphere-iso.linux-almalinux: Waiting for IP...
==> vsphere-iso.linux-almalinux: IP address: 172.16.38.164
==> vsphere-iso.linux-almalinux: Using SSH communicator to connect: 172.16.38.164
==> vsphere-iso.linux-almalinux: Waiting for SSH to become available...
==> vsphere-iso.linux-almalinux: Connected to SSH!
==> vsphere-iso.linux-almalinux: Provisioning with Ansible...
    vsphere-iso.linux-almalinux: Setting up proxy adapter for Ansible....
==> vsphere-iso.linux-almalinux: Executing Ansible: <sensitive>-playbook -e packer_build_name="linux-almalinux" -e packer_builder_type=vsphere-iso -e packer_http_addr=172.16.38.102:8050 --ssh-extra-args '-o IdentitiesOnly=yes' --extra-vars display_skipped_hosts=false --extra-vars BUILD_USERNAME=<sensitive> --extra-vars BUILD_SECRET=***** --extra-vars ANSIBLE_USERNAME=<sensitive> --extra-vars ANSIBLE_SECRET=***** -e <sensitive>_ssh_private_key_file=/tmp/<sensitive>-key2890125948 -i /tmp/packer-provisioner-<sensitive>1495634203 /home/localadmin/packer-examples-for-vsphere/<sensitive>/main.yml
    vsphere-iso.linux-almalinux:
    vsphere-iso.linux-almalinux: PLAY [all] *********************************************************************
    vsphere-iso.linux-almalinux:
    vsphere-iso.linux-almalinux: TASK [Gathering Facts] *********************************************************
    vsphere-iso.linux-almalinux: fatal: [default]: FAILED! => {"<sensitive>_facts": {}, "changed": false, "failed_modules": {"setup": {"failed": true, "module_stderr": "/bin/sh: /usr/bin/python3: No such file or directory\nShared connection to 127.0.0.1 closed.\r\n", "module_stdout": "", "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error", "rc": 127}}, "msg": "The following modules failed to execute: setup\n"}
    vsphere-iso.linux-almalinux:
    vsphere-iso.linux-almalinux: PLAY RECAP *********************************************************************
    vsphere-iso.linux-almalinux: default                    : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0
    vsphere-iso.linux-almalinux:
==> vsphere-iso.linux-almalinux: Provisioning step had errors: Running the cleanup provisioner, if present...
==> vsphere-iso.linux-almalinux: Power off VM...
==> vsphere-iso.linux-almalinux: Destroying VM...
Build 'vsphere-iso.linux-almalinux' errored after 10 minutes 24 seconds: Error executing Ansible: Non-zero exit status: exit status 2

==> Wait completed after 10 minutes 24 seconds

==> Some builds didn't complete successfully and had errors:
--> vsphere-iso.linux-almalinux: Error executing Ansible: Non-zero exit status: exit status 2

==> Builds finished but no artifacts were created.

Screenshots

No response

Additional Context

No response

Packer 1.8.0 on linux interprets boot_command "up" as letters "u" and "p" rather than an up-arrow kepress

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Project Version

main

VMware vSphere

vSphere Client version 6.7.0.50000

HashiCorp Packer

1.8.0

HashiCorp Packer Plugin for VMware vSphere

1.0.3

Guest Operating System

RHEL and Variants

Environment Details

No response

Description

Packer "types" in the two letters, "u" and "p" rather than interpret the intent as the up-arrow. Changing to "" solve the problem.

https://github.com/vmware-samples/packer-examples-for-vsphere/blob/main/builds/linux/rocky/8/linux-rocky.pkr.hcl#L93

Expected Behavior

When the ISO is booting and the grub/install menu is presented, the up-arrow is expected so that the kernel line can be modified.

Actual Behavior

The two letters, "u" and "p" are sent literally.

Steps to Reproduce

A standard packer build against centos and RHEL 8 is what I tested.

Log Fragments and Files

No response

Screenshots

No response

Additional Context

No response

Update the Ubuntu 22.04 LTS machine image for the generally available release

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Description

Update the initial Ubuntu 22.04 LTS example to support the planned GA release on 27 April 2022.

Also test support as the Packer host.

Use Case(s)

Support the GA release.

Potential Configuration

Use and test existing from preview release of Ubuntu 22.04.

References

No response

Almalinux and Windows, Static IP

Hi,

i tried to create the templates with a static ip, without success.
Can you help me to create templates (almalinux, windows 2016 and windows 2019) at creation with a static ip?

stopped at "waiting for ssh"

See below message, my build stopped at "ssh", it wont go any further.

==> vsphere-iso.linux-<sensitive>-server: IP address: 10.30.7.109
==> vsphere-iso.linux-<sensitive>-server: Using SSH communicator to connect: 10.30.7.109
==> vsphere-iso.linux-<sensitive>-server: Waiting for SSH to become available...

By any chance if there is way to see more information for debugging?

[BUG] Setting the `build_password` using `set-envvars.sh`

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Project Version

main

VMware vSphere

7.0 Update 2

HashiCorp Packer

v1.8.0

HashiCorp Packer Plugin for VMware vSphere

v1.0.3

Guest Operating System

Any Supported

Environment Details

The current packer templates seem to not use the build_password variable so that the only password read by packer is the one that the user provides in the install script

I've noticed this situation while working on creating a Debian template starting from the existing template for Ubuntu 18.04.

In order to fix this issue and use the build_password variable provided within the set-envvars.sh script the following instruction should be added to the templates:

build_password = var.build_password

Description

Expected Behavior

Actual Behavior

Steps to Reproduce

Run a build setting a password buid_password in the config file as "password"
Run the set-envvars.sh script and set the password to "different_password"
Run the build.

Result: the password used by packer will be "password" and not "different_password" as expected.

Log Fragments and Files

No response

Screenshots

No response

Additional Context

[BUG] Symbol error in file scripts/linux/ubuntu-server-2x.sh

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Project Version

main

VMware vSphere

7.0.3

HashiCorp Packer

1.7.8

HashiCorp Packer Plugin for VMware vSphere

v1.0.2

Guest Operating System

Ubuntu 20.04

Environment Details

ubuntu 20.04

Description

Symbol error in file scripts/linux/ubuntu-server-2x.sh

Expected Behavior

STDOUT have no error

Actual Behavior

==> vsphere-iso.linux-ubuntu-server: + cloud-init ...
==> vsphere-iso.linux-ubuntu-server: usage: /usr/bin/cloud-init [-h] [--version] [--file FILES] [--debug] [--force]
==> vsphere-iso.linux-ubuntu-server:                            {init,modules,single,query,dhclient-hook,features,analyze,devel,collect-logs,clean,status}
==> vsphere-iso.linux-ubuntu-server:                            ...
==> vsphere-iso.linux-ubuntu-server: /usr/bin/cloud-init: error: argument subcommand: invalid choice: '...' (choose from 'init', 'modules', 'single', 'query', 'dhclient-hook', 'features', 'analyze', 'devel', 'collect-logs', 'clean', 'status')
==> vsphere-iso.linux-ubuntu-server: + GRUB ...
==> vsphere-iso.linux-ubuntu-server: /tmp/script_1190.sh: 1: GRUB: not found

Steps to Reproduce

./build.sh

Log Fragments and Files

=> vsphere-iso.linux-ubuntu-server: + sudo sed -i s/.*PubkeyAuthentication.*/PubkeyAuthentication yes/ /etc/ssh/sshd_config
==> vsphere-iso.linux-ubuntu-server: + echo > Restarting the SSH daemon. ...
    vsphere-iso.linux-ubuntu-server: > Restarting the SSH daemon. ...
==> vsphere-iso.linux-ubuntu-server: + sudo systemctl restart sshd
==> vsphere-iso.linux-ubuntu-server: + echo > Disabling and clean tmp ...
==> vsphere-iso.linux-ubuntu-server: + sudo sed -i s/D/#&/ /usr/lib/tmpfiles.d/tmp.conf
    vsphere-iso.linux-ubuntu-server: > Disabling and clean tmp ...
==> vsphere-iso.linux-ubuntu-server: + echo > Creating the clean script ...
    vsphere-iso.linux-ubuntu-server: > Creating the clean script ...
==> vsphere-iso.linux-ubuntu-server: + cloud-init ...
==> vsphere-iso.linux-ubuntu-server: usage: /usr/bin/cloud-init [-h] [--version] [--file FILES] [--debug] [--force]
==> vsphere-iso.linux-ubuntu-server:                            {init,modules,single,query,dhclient-hook,features,analyze,devel,collect-logs,clean,status}
==> vsphere-iso.linux-ubuntu-server:                            ...
==> vsphere-iso.linux-ubuntu-server: /usr/bin/cloud-init: error: argument subcommand: invalid choice: '...' (choose from 'init', 'modules', 'single', 'query', 'dhclient-hook', 'features', 'analyze', 'devel', 'collect-logs', 'clean', 'status')
==> vsphere-iso.linux-ubuntu-server: + GRUB ...
==> vsphere-iso.linux-ubuntu-server: /tmp/script_1190.sh: 1: GRUB: not found
==> vsphere-iso.linux-ubuntu-server: + sudo cat
==> vsphere-iso.linux-ubuntu-server: + echo > Changing the permissions on /home/$BUILD_USERNAME/clean.sh ...
==> vsphere-iso.linux-ubuntu-server: + sudo chmod +x /home/<sensitive>/clean.sh
    vsphere-iso.linux-ubuntu-server: > Changing the permissions on /home/$BUILD_USERNAME/clean.sh ...
==> vsphere-iso.linux-ubuntu-server: + echo > Running the clean script ...
    vsphere-iso.linux-ubuntu-server: > Running the clean script ...
==> vsphere-iso.linux-ubuntu-server: + sudo /home/<sensitive>/clean.sh

Screenshots

No response

Additional Context

### Prepare cloud-init ###
echo `> Preparing cloud-init ...`

### Modify GRUB ###
echo `> Modifying GRUB ...`

Linux and UEFI

Hi,

I tried to install Almalinux and Ubuntu with the KS config with efi, but i dont get it to work.
Any suggestions?

[ENHANCEMENT] Add Windows 10 Professional

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

Description

Implement Windows 10 Pro image

Use Case(s)

wsl is only available on Windows 10.

In order to test wsl automation scripts, I need Windows 10 image for the CI.

Potential Configuration

N/A

References

No response

[BUG] content_library block should be null when common_template_conversion is true

Code of Conduct

  • I have read and agree to the project's Code of Conduct.

VMware vSphere

Any

HashiCorp Packer

1.7.5

HashiCorp Packer Plugin for VMware vSphere

1.0.1

Guest Operating System

macOS Big Sur 11.6 (Intel)

Environment Details

My current Terraform workflow is using VM template stored in VM folder tree.
So, I need to convert to VM without storing it to content library.

Description

In Packer documentation (see https://www.packer.io/docs/builders/vsphere/vsphere-iso#convert_to_template)

The import doesn't work if convert_to_template is set to true

Expected Behavior

When convert_to_template is set to true, content_library_destination block should be removed.

Actual Behavior

Packer returns an error when trying to push VM template to content library.

Steps to Reproduce

Set convert_to_template is set to true

Log Fragments and Files

=> vsphere-iso.linux-ubuntu-server: Importing VM template linux-ubuntu-server-20-04-lts1632170716 to Content Library...
==> vsphere-iso.linux-ubuntu-server: Failed to import template linux-ubuntu-server-20-04-lts1632170716: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"error_type":"INVALID_ARGUMENT","messages":[{"args":["vm-15548"],"default_message":"The provided source virtual machine ID vm-15548 is from a virtual machine template, which is not supported.","id":"com.vmware.vdcs.vmtx-main.invalid_source_vm_template_not_supported"}]}}
==> vsphere-iso.linux-ubuntu-server: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"error_type":"INVALID_ARGUMENT","messages":[{"args":["vm-15548"],"default_message":"The provided source virtual machine ID vm-15548 is from a virtual machine template, which is not supported.","id":"com.vmware.vdcs.vmtx-main.invalid_source_vm_template_not_supported"}]}}
==> vsphere-iso.linux-ubuntu-server: Step "StepImportToContentLibrary" failed
==> vsphere-iso.linux-ubuntu-server: [c] Clean up and exit, [a] abort without cleanup, or [r] retry step (build may fail even if retry succeeds)?
Cancelling build after receiving interrupt
==> vsphere-iso.linux-ubuntu-server: Provisioning step had errors: Running the cleanup provisioner, if present...
==> vsphere-iso.linux-ubuntu-server: Power off VM...
==> vsphere-iso.linux-ubuntu-server: Destroying VM...
==> vsphere-iso.linux-ubuntu-server: Deleting cd_files image from remote datastore ...
Build 'vsphere-iso.linux-ubuntu-server' errored after 10 minutes 35 seconds: 400 Bad Request: {"type":"com.vmware.vapi.std.errors.invalid_argument","value":{"error_type":"INVALID_ARGUMENT","messages":[{"args":["vm-15548"],"default_message":"The provided source virtual machine ID vm-15548 is from a virtual machine template, which is not supported.","id":"com.vmware.vdcs.vmtx-main.invalid_source_vm_template_not_supported"}]}}

Screenshots

No response

Additional Context

I suggest (and I can create PR for) to update code as follow

  • Set common_content_library_name default to null
  • Create dynamic block for content_library_destination
  dynamic "content_library_destination" {
    for_each = var.common_content_library_name != null ? [1] : []
    content {
      library = var.common_content_library_name
      ovf     = var.common_content_library_ovf
      destroy = var.common_content_library_destroy
    }
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.