Packer - Vsphere-iso - Centos 8

2.1k views Asked by At

Am using the following JSON and KS.cfg to build the centos 8 templates. But facing an error with floppy disks (which am not using in the config). Have tried changing the boot sequence but no luck. Also not finding an example for the centos 8 Json for vsphere-iso builder. Can someone help me with this?

CentOS 8 JSON

{
  "variables": {
   "vsphere_uid": "Null",
   "vsphere_passwd": "Null",
   "vm_superuser_passwd" : "Null",
   "vsphere_vm_name": "Null",
   "bastion_host": "",
   "bastion_user": "",
   "bastion_password":"Null",
   "datacenter": "",
   "cluster": "",
   "datastore": "",
   "network": "",
   "iso_paths": ""
   },

  "builders": [
    {
      "type": "vsphere-iso",

      "vcenter_server":      "{{user `vsphere_server` }}",
      "username":            "{{user `vsphere_uid` }}",
      "password":            "{{user `vsphere_passwd` }}",
      "insecure_connection": "true",
      "datacenter": "{{user `datacenter` }}",
      "cluster": "{{user `cluster` }}",
      "datastore": "{{user `datastore` }}",
      "network": "{{user `network` }}",
      "vm_name": "{{user `vsphere_vm_name` }}",

      "guest_os_type": "centos7_64Guest",

      "ssh_username": "admin",
      "ssh_password": "{{user `vm_superuser_passwd` }}",
      "ssh_bastion_host": "{{user `bastion_host` }}",
      "ssh_bastion_username": "{{user `bastion_user` }}",
      "ssh_bastion_agent_auth": true,

      "CPUs":             2,
      "RAM":              5120,
      "RAM_reserve_all": false,

      "convert_to_template": true,

      "disk_controller_type":  "pvscsi",
      "disk_size":        102400,
      "disk_thin_provisioned": true,
      "network_card": "vmxnet3",
      "http_directory" :  "httpks",
      "iso_paths": [
        "[nfs] centos/CentOS-8.2.2004-x86_64-minimal.iso"
      ],
      "iso_checksum": "e15fb0e51726de0a4128448b9bd63e7b",
      "iso_checksum_type": "md5",
      "boot_command": "<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg <enter><wait>"
          }
  ]

}

Error is :

dracut-pre-udev{585}: modprobe: FATAL: Module floppy not found in directory /lib/modules/4.18.0-193.2l8.x86_64

— 
2020/09/17 05:17:40 ui: ask: ==> vsphere-iso: Pausing after run of step 'StepConfigParams'. Press enter to continue. 
2020/09/17 05:17:40 packer-builder-vsphere-iso.linux: 
2020/09/17 05:17:40 No floppy files specified. Floppy disk will not be made. 
2020/09/17 05:17:40 ui: ask: ==> vsphere-iso: Pausing after run of step 'StepCreateFloppy'. Press enter to continue. 
2020/09/17 05:17:40 ui: ask: ==> vsphere-iso: Pausing after run of step 'StepAddFloppy'. Press enter to continue.
 — Dracut-initqueue: warning : could not boot Entering Emergency mode. 


Kindly assist

3

There are 3 answers

0
user2066657 On

You will have found out by now, but for those searching after-the-fact:

The OS roll no longer includes a floppy device driver, so you will need to use another source for the KS configuration. inst.ks uses the same format as inst.repo, and most people will use an HTTP source.

0
eephillip On

Working cdrom alternative using cd_files

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

packer 1.6.6

Relevant snippet

...
"type": "vsphere-iso",
"guest_os_type": "centos8_64Guest",
"cd_files": [
    "{{template_dir}}/ks.cfg",
],
"boot_command": [
    '<up>'
    'e',
    '<down><down><end><wait>',
    ' text ks=cdrom:/dev/sr1:/ks.cfg'
    '<leftCtrlOn>x<leftCtrlOff>',
],
...
0
Bailey On

I’ve had similar issues with vsphere-iso packer build using the wrong IP for the HTTP directory especially when I was on my company’s VPN vs being hardwired. Thus, it was continually stuck at 'Waiting for IP' & received the same dracut-init errors. The issue for me was the order of priority that packer uses to determine what interface to use for the HTTP directory which contains my kickstarter file.

How we solved this, is that we actually have a shell wrapper that calls packer. Within that script, we ask the user for an IP that the HTTP directory should be accessed at. I use ifconfig and look at the 10. IP in the list. The shell script passes on that environmental variable to my packer's build.json Its not the cleanest solution, but Ive been using this fix for months. let me know if your still having issues and i can post some code.