jetbrains-infra / packer-builder-vsphere

Packer plugin for remote builds on VMware vSphere
Mozilla Public License 2.0
543 stars 175 forks source link

vsphere-iso: failed to load ks.cfg in RHEL 8 build #276

Closed ericxnhu closed 4 years ago

ericxnhu commented 4 years ago

Trying to use vspsher-iso to build a RHEL v8 template, the build failed at loading kickstart file.

The terminal output is like this:

==> rhel80-opcs-xfs-vsphere: Creating VM... ==> rhel80-opcs-xfs-vsphere: Customizing hardware... ==> rhel80-opcs-xfs-vsphere: Mount ISO images... ==> rhel80-opcs-xfs-vsphere: Creating floppy disk... rhel80-opcs-xfs-vsphere: Copying files flatly from floppy_files rhel80-opcs-xfs-vsphere: Copying file: ../centos/http/8/ks.cfg rhel80-opcs-xfs-vsphere: Done copying files from floppy_files rhel80-opcs-xfs-vsphere: Collecting paths from floppy_dirs rhel80-opcs-xfs-vsphere: Resulting paths from floppy_dirs : [] rhel80-opcs-xfs-vsphere: Done copying paths from floppy_dirs ==> rhel80-opcs-xfs-vsphere: Uploading created floppy image ==> rhel80-opcs-xfs-vsphere: Adding generated Floppy... ==> rhel80-opcs-xfs-vsphere: Set boot order temporary... ==> rhel80-opcs-xfs-vsphere: Power on VM... ==> rhel80-opcs-xfs-vsphere: Waiting 10s for boot... ==> rhel80-opcs-xfs-vsphere: Typing boot command... ==> rhel80-opcs-xfs-vsphere: Waiting for IP...

On vm console I got the following: " boot: linux inst.text inst.ks=hd:fd0:/ks.cfg Loading ... failed: No such file or directory boot: " After a while it would go back to manual install screen.

My build json file is like this: "........ "iso_paths": [ "[{{ user vsphere_datastore }}] ISO/rhel-8.0-x86_64-dvd.iso" ], "floppy_files": [ "../centos/http/8/ks.cfg" ], "boot_command": " linux inst.text inst.ks=hd:fd0:/ks.cfg ", "boot_wait": "10s", "convert_to_template": false ......"

The same json build file would work for rhel7.7 build: if I change "iso_paths" to "[{{ user vsphere_datastore }}] ISO/rhel-server-7.7-x86_64-dvd.iso", the build would go through.

Any thoughts?

bhundven commented 4 years ago

Rhel 8, and most newer distros don't have floppy support anymore. See the release notes.

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/8.0_release_notes/index

This applys to centos 8 as well.

ericxnhu commented 4 years ago

Got it, thanks!

ericxnhu commented 4 years ago

So how to use vsphere-iso to build rhel 8 image? I tried placing the ks.cfg on a nfs server, and pointing to it in boot command (like install.ks=nfs:.../ks.cfg), but it still couldn't load the file.

Thanks in advance.

Eric

On Thu, Oct 17, 2019 at 2:15 PM Bryan Hundven notifications@github.com wrote:

Rhel 8, and most newer distros don't have floppy support anymore. See the release notes.

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/8.0_release_notes/index

This applys to centos 8 as well.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jetbrains-infra/packer-builder-vsphere/issues/276?email_source=notifications&email_token=AIBNRRPO4P4W7L744S5VRNLQPCTUJA5CNFSM4JB5HY3KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBRBEAI#issuecomment-543298049, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIBNRRLJECR32TJ7YC63IM3QPCTUJANCNFSM4JB5HY3A .

Jammicus commented 4 years ago

We stuck it on a http server, so first we defined which folder we have placed our kickstart in locally:

   "http_directory": "http/kickstart",

Packer will then serve that directory and its contents on a http server. You can then in the boot command point to the http server and the kickstart using the following (Assuming your kickstart is called ks.cfg)

      "boot_command": [
        "<up><wait><tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort}}/ks.cfg <enter>"
      ]
superghi64 commented 4 years ago

This HTTP way is working fine with RHEL 7.x. but anyone has done it with RHEL 8.x? because it's not working!!!

snipervelli commented 4 years ago

Same for me http is working on CentOS 7 but not for CentOS 8.x. Can someone please post any working examples of their boot command. Or if anything was done to their KS file.

MarcoM65 commented 4 years ago

I had to use

genisoimage -o rhel8_ks.iso -V "OEMDRV" ks.cfg

and then place the iso where vsphere could reach it to attach with CDROM.

iacuser commented 4 years ago

I had to use

genisoimage -o rhel8_ks.iso -V "OEMDRV" ks.cfg

and then place the iso where vsphere could reach it to attach with CDROM.

Can you give a hint how the boot_command in the template should look like to use the generated rhel8_ks.iso?

MarcoM65 commented 4 years ago

@iacuser for boot command I just used the below

"variables": {
    "ks_iso": "[datastore] ISOs/rhel8_ks.iso",
"iso_paths": [
        "{{user `rhel_iso`}}",
    "{{user `vmtools_iso`}}",
        "{{user `ks_iso`}}"

...

"boot_command": "<enter> <enter>"

just to get through the bootup selection for installing. When it senses the Image it loads iso, reads the "OEMDRV" label and continues from there with kickstarter. hope that helps.

iacuser commented 4 years ago

@MarcoM65 This was indeed helpful thank you.

I had to adapt the boot command though, to make sure the correct kickstart file is used.

"boot_command": "<wait10><tab>linux inst.ks=hd:/dev/sr1:ks_rhel8.cfg<enter>"

yakhatape commented 3 years ago

On my side its working for RHEL8 with following boot command : "boot_command": [ "<up><wait><tab> text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks-rhel8-{{uservsphere_datacenter}}-integration.cfg ip={{usertemplate_ip}}::{{usertemplate_gateway}}:{{usertemplate_cidr}}:templaterhel8:ens192:none <enter>" ]

Hope this will help

wixregiga commented 2 years ago

This will probably help a bunch of people here. In order to use this on your local machine with vcenter, all you have to do is:

  1. specify the ks file that you want in cd_files
  2. download xorriso on your system
  3. make the cd_label = "OEMDRV"
  4. Somewhere in your boot_command do the following linux inst.ks=hd:/dev/sr1:<path_to_ks_file>
  5. OPTIONAL: http_content = null

Packer will add your kickstart file to the datastore in an iso or whatever you want to make and attach the image to the VM. If a CD has a label of OEMDRV then RHEL8 and above will use that images kickstart file to boot the current one. Let me know if this helped.