While new to Packer and Kickstart scripts, I am trying to automate the setup of CentOS 7 (eventually 8) boxes in a VSphere cluster. My Packer code is calling a Kickstart script to complete the setup, but running into issues getting networking working. As each node in the ESX cluster is 6.5.X, I see the Guest IP hack isn't required.
When I run "packer build --debug" with PACLOG=1 for more verbosity, I see my code fails to complete the .Waiting for IP..." step:
==> vsphere-iso: Adding generated Floppy...
==> vsphere-iso: Set boot order...
==> vsphere-iso: Power on VM...
==> vsphere-iso: Waiting 10s for boot...
==> vsphere-iso: Typing boot command...
2020/06/09 18:40:15 packer-builder-vsphere-iso plugin: Special code '<esc>' found, replacing with: CodeEscape
2020/06/09 18:40:15 packer-builder-vsphere-iso plugin: Waiting 1 second
2020/06/09 18:40:20 packer-builder-vsphere-iso plugin: Special code '<enter>' found, replacing with: CodeReturnEnter
2020/06/09 18:40:20 packer-builder-vsphere-iso plugin: Waiting 1 second
2020/06/09 18:40:21 packer-builder-vsphere-iso plugin: [INFO] Waiting for IP, up to total timeout: 30m0s, settle timeout: 5s
==> vsphere-iso: Waiting for IP...
==> vsphere-iso: Post "https://<server name>.com/sdk": EOF
==> vsphere-iso: Step "StepWaitForIp" failed
Running the installer with or without a GUI installer in the VM, I see that Networking is not configured in the VM(adapter is up but no IP). As the adapter name is not consistent, I am trying to let Packer use any connected adapters, and use DHCP to ease mass deployments. I have tried "network --onboot yes --device=link --activate" and "network --onboot yes --activate" as well as other combinations. Each time a file is created under /etc/sysconfig/network-scripts/, but network is still not established.
I replaced all variables in my Packer JSON with the hard-coded variables, but get the same results.
As validation I also can see the temporary VM listed as a VM belonging to the network in VSphere, and it has a valid MAC.
I have also tried to ensure that the open-vm-tools package is installed, but it did not help.
Has anyone ran across this issue?
Builders section from packer file:
"builders": [
{
"type": "vsphere-iso",
"vcenter_server": "{{user `vsphere-server`}}",
"username": "{{user `vsphere-user`}}",
"password": "{{user `vsphere-password`}}",
"insecure_connection": "true",
"datacenter": "{{user `vsphere-datacenter`}}",
"cluster": "{{user `vsphere-cluster`}}",
"network": "{{user `vsphere-network`}}",
"host": "{{user `vsphere-host`}}",
"datastore": "{{user `vsphere-datastore`}}",
"vm_name": "{{user `vm-name`}}",
"notes": "Build via Packer",
"guest_os_type": "centos7_64Guest",
"boot_wait": "10s",
"boot_order": "disk,cdrom,floppy",
"communicator": "ssh",
"ssh_username": "root",
"ssh_password": "server",
"CPUs": "{{user `vm-cpu-num`}}",
"RAM": "{{user `vm-mem-size`}}",
"RAM_reserve_all": false,
"disk_controller_type": "pvscsi",
"disk_size": "{{user `vm-disk-size`}}",
"disk_thin_provisioned": true,
"network_card": "vmxnet3",
"convert_to_template": true,
"iso_urls": ["{{user `iso-url`}}"],
"iso_checksum": "{{user `iso-checksum`}}",
"iso_checksum_type": "{{user `iso-checksum-type`}}",
"floppy_files": ["ks.cfg"],
"boot_command": [
"<esc><wait>",
"linux inst.text ks=hd:fd0:/ks.cfg<enter><wait>"
KS.cfg:
```# Install a fresh new system (optional)
install
# Specify installation method to use for installation
# To use a different one comment out the 'url' one below, update
# the selected choice with proper options & un-comment it
cdrom
# Set language to use during installation and the default language to use on the installed system (required)
lang en_US.UTF-8
# Set system keyboard type / layout (required)
keyboard --vckeymap=us --xlayouts='us'
firstboot --disable
# Configure network information for target system and activate network devices in the installer environment (optional)
# --onboot enable device at a boot time
# --device device to be activated and / or configured with the network command
# --bootproto method to obtain networking configuration for device (default dhcp)
# --noipv6 disable IPv6 on this device
network --onboot yes --bootproto dhcp --noipv6
#network --bootproto=dhcp --onboot=yes --device=link --noipv6 --activate
# Set the system's root password (required)
# Plaintext password is: server
rootpw --iscrypted $6$rhel6usgcb$aS6oPGXcPKp3OtFArSrhRwu6sN8q2.yEGY7AIwDOQd23YCtiz9c5mXbid1BzX9bmXTEZi.hCzTEXFosVBI5ng0
# Configure firewall settings for the system (optional)
# --enabled reject incoming connections that are not in response to outbound requests
# --ssh allow sshd service through the firewall
# firewall --enabled --ssh
firewall --disabled
# Set up the authentication options for the system (required)
# --enableshadow enable shadowed passwords by default
# --passalgo hash / crypt algorithm for new passwords
# See the manual page for authconfig for a complete list of possible options.
authconfig --enableshadow --passalgo=sha512
# State of SELinux on the installed system (optional)
# Defaults to enforcing
selinux --permissive
# Set the system time zone (required)
timezone --utc America/Chicago
# Specify how the bootloader should be installed (required)
# Plaintext password is: password
bootloader --location=mbr --append="crashkernel=auto rhgb quiet" --password=$6$rhel6usgcb$kOzIfC4zLbuo3ECp1er99NRYikN419wxYMmons8Vm/37Qtg0T8aB9dKxHwqapz8wWAFu
autopart --type=lvm
# Initialize all disks
clearpart --linux --initlabel
services --enabled=NetworkManager,sshd
# Packages selection
%packages --ignoremissing
Require @Base
@Base
@minimal
# End of %packages section
%post
#sudo yum upgrade -y
yum -y install open-vm-tools
yum -y install sudo
systemctl enable vmtoolsd
systemctl start vmtoolsd
systemctl enable sshd
systemctl start sshd
%end
# Reboot after the installation is complete (optional)
# --eject attempt to eject CD or DVD media before rebooting
reboot --eject