Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opensuse-leap-15-x86_64.pkrvars.hcl build for virtualbox issues #1491

Open
rubisher opened this issue Mar 17, 2023 · 6 comments
Open

opensuse-leap-15-x86_64.pkrvars.hcl build for virtualbox issues #1491

rubisher opened this issue Mar 17, 2023 · 6 comments

Comments

@rubisher
Copy link

The build of this opensuse-leap-15.4 box for VBox failed :(

Describe the problem

Here are my build notes:

$ packer build -on-error=ask -only=virtualbox-iso.vm -var-file=os_pkrvars/opensuse/opensuse-leap-15-x86_64.pkrvars.hcl -var-file=./customs/var-vb7-AHCI.pkr.hcl ./packer_templates
virtualbox-iso.vm: output will be in this color.

==> virtualbox-iso.vm: Retrieving Guest additions
==> virtualbox-iso.vm: Trying /usr/share/virtualbox/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: Trying /usr/share/virtualbox/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: /usr/share/virtualbox/VBoxGuestAdditions.iso => /usr/share/virtualbox/VBoxGuestAdditions.iso
==> virtualbox-iso.vm: Retrieving ISO
==> virtualbox-iso.vm: Trying https://download.opensuse.org/distribution/leap/15.4/iso/openSUSE-Leap-15.4-DVD-x86_64-Media.iso
==> virtualbox-iso.vm: Trying https://download.opensuse.org/distribution/leap/15.4/iso/openSUSE-Leap-15.4-DVD-x86_64-Media.iso?checksum=sha256%3A4683345f242397c7fd7d89a50731a120ffd60a24460e21d2634e783b3c169695
==> virtualbox-iso.vm: https://download.opensuse.org/distribution/leap/15.4/iso/openSUSE-Leap-15.4-DVD-x86_64-Media.iso?checksum=sha256%3A4683345f242397c7fd7d89a50731a120ffd60a24460e21d2634e783b3c169695 => /home/jlst/.cache/packer/6c899a4026d335cf7ede7a8a554a1846a2ad5e68.iso
==> virtualbox-iso.vm: Starting HTTP server on port 8945
==> virtualbox-iso.vm: Creating virtual machine...
==> virtualbox-iso.vm: Creating hard drive builds/packer-opensuse-15.4-x86_64-virtualbox/opensuse-15.4-amd64.vdi with size 65536 MiB...
==> virtualbox-iso.vm: Mounting ISOs...
    virtualbox-iso.vm: Mounting boot ISO...
==> virtualbox-iso.vm: Creating forwarded port mapping for communicator (SSH, WinRM, etc) (host port 2512)
==> virtualbox-iso.vm: Executing custom VBoxManage commands...
    virtualbox-iso.vm: Executing: modifyvm opensuse-15.4-amd64 --audio none --nat-localhostreachable1 on
    virtualbox-iso.vm: Executing: storagectl opensuse-15.4-amd64 --name SATA Controller --hostiocache on
==> virtualbox-iso.vm: Starting the virtual machine...
    virtualbox-iso.vm: The VM will be run headless, without a GUI. If you want to
    virtualbox-iso.vm: view the screen of the VM, connect via VRDP without a password to
    virtualbox-iso.vm: rdp://127.0.0.1:5914
==> virtualbox-iso.vm: Waiting 10s for boot...
==> virtualbox-iso.vm: Typing the boot command...
==> virtualbox-iso.vm: Using SSH communicator to connect: 127.0.0.1
==> virtualbox-iso.vm: Waiting for SSH to become available...
==> virtualbox-iso.vm: 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 keyboard-interactive], no supported methods remain
==> virtualbox-iso.vm: 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 keyboard-interactive], no supported methods remain
==> virtualbox-iso.vm: Step "StepConnect" failed
==> virtualbox-iso.vm: [c] Clean up and exit, [a] abort without cleanup, or [r] retry step (build may fail even if retry succeeds)? r
==> virtualbox-iso.vm: Using SSH communicator to connect: 127.0.0.1

As I monitor at the same time the "Show" of the VirtualBox console of this VM, it looks still starting up when the "StepConnect" failed, though?
SS_BENTO-OS-LEAP-15 4

As you may have noticed, I used the option "-on-error=ask" to have more time to analyze the status of the VM, also that let enough time to the boot to complete:
SS_BENTO-OS-LEAP-15 4_2

and now that the login prompt is available, I can verify at this moment that the NIC is well up and the IP is well configured by DHCP and even an "$ ssh [email protected]" works successfully .
Then at the 'ask' prompt , I type 'r' to retry and the process continue to build the image near the end ...
but unfortunately it failed a second time for this other reason:

==> virtualbox-iso.vm: + echo 'dd exit code 1 is suppressed'
==> virtualbox-iso.vm: + /sbin/mkswap -U 7cca87ee-1ea8-4780-88ea-43cdee6357b0 /dev/sda2
    virtualbox-iso.vm: Setting up swapspace version 1, size = 512 MiB (536866816 bytes)
    virtualbox-iso.vm: no label, UUID=7cca87ee-1ea8-4780-88ea-43cdee6357b0
==> virtualbox-iso.vm: + sync
==> virtualbox-iso.vm: Gracefully halting virtual machine...
==> virtualbox-iso.vm: Preparing to export machine...
    virtualbox-iso.vm: Deleting forwarded port mapping for the communicator (SSH, WinRM, etc) (host port 2512)
==> virtualbox-iso.vm: Exporting virtual machine...
    virtualbox-iso.vm: Executing: export opensuse-15.4-amd64 --output builds/packer-opensuse-15.4-x86_64-virtualbox/opensuse-15.4-amd64.ovf
==> virtualbox-iso.vm: Provisioning step had errors: Running the cleanup provisioner, if present...
==> virtualbox-iso.vm: Cleaning up floppy disk...
==> virtualbox-iso.vm: Deregistering and deleting VM...
Build 'virtualbox-iso.vm' errored after 33 minutes 23 seconds: 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 keyboard-interactive], no supported methods remain

==> Wait completed after 33 minutes 23 seconds

==> Some builds didn't complete successfully and had errors:
--> virtualbox-iso.vm: 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 keyboard-interactive], no supported methods remain

==> Builds finished but no artifacts were created.

There is well an OVF available :

$ ll -h  builds/packer-opensuse-15.4-x86_64-virtualbox/
total 1009M
-rw-r--r-- 1 jlst users 1009M Mar 17 16:10 opensuse-15.4-amd64-disk001.vmdk
-rwx------ 1 jlst users  7.0K Mar 17 16:09 opensuse-15.4-amd64.ovf

(but I not yet learn how to use it to build the 'box' with it :()

PS: the additional '-var-file=./customs/var-vb7-AHCI.pkr.hcl' is just to speed a bit the pocess, it just contains:

$ more customs/var-vb7-AHCI.pkr.hcl 
vboxmanage = [
    [
      "modifyvm", "{{.Name}}",
      "--audio", "none",
      "--nat-localhostreachable1", "on",
    ]
    ,
    [
      "storagectl", "{{.Name}}",
      "--name", "SATA Controller",
      "--hostiocache", "on",
    ]
  ]

(but same issue occurs without it)

Software Version

the git log of today is:

$ git log -n1 | awk '$0 ~ /^commit/ {print substr($2,0,7)}'
768ccf1

and the other tools:

$ packer --version
1.8.6
$ vagrant --version
Vagrant 2.3.4
$ vboxmanage --version
7.0.6r155176

Replication Case

Just launch the same cmd (I do not yet try the bento cmd :()

Stacktrace

imho the above description contains enough, no? (but I can also supply the full screen session)

Possible Solution

Sorry not yet enough packer expertise .

@rubisher
Copy link
Author

Hey, it seems that I find a work-around:

==> virtualbox-iso.vm (vagrant): Creating Vagrant box for 'virtualbox' provider
    virtualbox-iso.vm (vagrant): Copying from artifact: builds/packer-opensuse-15.4-x86_64-virtualbox/opensuse-15.4-amd64-disk001.vmdk
    virtualbox-iso.vm (vagrant): Copying from artifact: builds/packer-opensuse-15.4-x86_64-virtualbox/opensuse-15.4-amd64.ovf
    virtualbox-iso.vm (vagrant): Renaming the OVF to box.ovf...
    virtualbox-iso.vm (vagrant): Compressing: Vagrantfile
    virtualbox-iso.vm (vagrant): Compressing: box.ovf
    virtualbox-iso.vm (vagrant): Compressing: metadata.json
    virtualbox-iso.vm (vagrant): Compressing: opensuse-15.4-amd64-disk001.vmdk
Build 'virtualbox-iso.vm' finished after 28 minutes 58 seconds.

==> Wait completed after 28 minutes 58 seconds

==> Builds finished. The artifacts of successful builds are:
--> virtualbox-iso.vm: 'virtualbox' provider box: ./packer_templates/../builds/opensuse-15.4-x86_64.virtualbox.box

The idea came from the reading back this message (in the first picture):
SS_BENTO-OS-LEAP-15 4_3

Also I suspected a problem linked to 'wicked' configuration and I find this blog https://kubic.opensuse.org/blog/2022-05-05-NetworkManager-Wicked/ also I manage to login the VM and just prefer to use yast to install NetworkManager & remove wicked & wicked-service and rebuild the autoyast.xml (cloning system?). I just copy it on my host to replace the previous one.
autoinst.xml

(Just noticed a short time of 10 second to select the default keymap? and [FAILED] message regarding the restart of NetworkManger but apparently harmless)

May be can we foreseen to build boxes like this and if want the final boxes configured with 'wicked' , we can swicth back to this at the end of the packer build?

Take care of you and your beloved, Rudy

@Stromweld
Copy link
Collaborator

I'll try to take a look at it more. As of right now though it may be a while as there are also many other builds failing on several providers. Prioritizing things for x86_64 virtualbox, parallels, vmware first then aarch64 parallels next.

@Stromweld
Copy link
Collaborator

ideally we'd get things to work with standard install as then customization after the fact would be up to the user/company and hopefully through tools like chef or another configuration management tool. For other OS's that switched to live CD's we've had to add to the cloudinit or xml files early steps to disable SSH as that is what causes the early packer login and failure as it tries to login to the installer OS and not the final installed OS.

@rubisher
Copy link
Author

Understand.
(Just a though, years ago I wrote a small script to setup my Debian VBox, I created a small floppy disk image in which I was copying my preseed file and associated scripts. I was attaching the image to the VBox and instruct boot cmd to grab its preseed file in this floppy. Not sure it would still works with a floppy img (afaik RHEL 8 doesn't support any more) but may be can we replace it by a second iso image?)

@Stromweld
Copy link
Collaborator

In the change log I have a TODO for looking into using cdrom_files for things like that. Hyper-V gen 2 also removes disk drives and it would eliminate network connection to host for http file share. It'd make things more compatible as well as hopefully faster.

@rubisher
Copy link
Author

Now that I reach to build my OpenSUSE-Tumbleweed box image, I take few minutes for a POC to only bootstrap the OS:

  • I create an iso image containing the packer_templates/http tree (so it could be usable for all distro)
$ sudo mount -o ro /var/tmp/Bento-autostart.iso /mnt 

$ find /mnt
/mnt
/mnt/debian
/mnt/debian/preseed.cfg
[...]
/mnt/opensuse/OS-Tumbleweed-autoinst-5.xml
[...]
/mnt/ubuntu/user-data
  • just create a custom config file to attache it the the VM:
    $ cat customs/var-vb7-AHCI.pkr.hcl
vboxmanage = [
    [
      "modifyvm", "{{.Name}}",
      "--audio", "none",
      "--nat-localhostreachable1", "on",
    ]
    ,
    [
      "storagectl", "{{.Name}}",
      "--name", "SATA Controller",
      "--hostiocache", "on",
    ]
    ,
    [
      "storageattach", "{{.Name}}",
      "--storagectl", "IDE Controller",
      "--port", "1",
      "--device", "0",
      "--type", "dvddrive",
      "--medium", "/var/tmp/Bento-autostart.iso",
    ]
  ]
  • chg my hcl file such that autoyast will use it "autoyast=device://dev/sr1/opensuse/OS-Tumbleweed-autoinst-5.xml"
  • Just try :
packer build -force -on-error=ask -only=virtualbox-iso.vm -var-file=os_pkrvars/opensuse/rudy-os-DVD-x86_64.pkrvars.hcl -var-file=./customs/var-vb7-AHCI.pkr.hcl ./packer_templates
[...]
==> virtualbox-iso.vm (vagrant): Creating Vagrant box for 'virtualbox' provider
    virtualbox-iso.vm (vagrant): Copying from artifact: builds/packer-opensuse-rolling-x86_64-virtualbox/opensuse-rolling-amd64-disk001.vmdk
    virtualbox-iso.vm (vagrant): Copying from artifact: builds/packer-opensuse-rolling-x86_64-virtualbox/opensuse-rolling-amd64.ovf
    virtualbox-iso.vm (vagrant): Renaming the OVF to box.ovf...
    virtualbox-iso.vm (vagrant): Compressing: Vagrantfile
    virtualbox-iso.vm (vagrant): Compressing: box.ovf
    virtualbox-iso.vm (vagrant): Compressing: metadata.json
    virtualbox-iso.vm (vagrant): Compressing: opensuse-rolling-amd64-disk001.vmdk
Build 'virtualbox-iso.vm' finished after 10 minutes 6 seconds.

==> Wait completed after 10 minutes 6 seconds

==> Builds finished. The artifacts of successful builds are:
--> virtualbox-iso.vm: 'virtualbox' provider box: ./packer_templates/../builds/opensuse-rolling-x86_64.virtualbox.box
osvbox (pts9)jlst@osvbox:/bento-rudy-work3 |\

osvbox (pts9)jlst@osvbox:/bento-rudy-work3 |\
$ ll ./packer_templates/../builds/opensuse-rolling-x86_64.virtualbox.box
-rw-r--r-- 1 jlst users 885426511 Mar 30 17:54 ./packer_templates/../builds/opensuse-rolling-x86_64.virtualbox.box

Just a first step : I still have to learn in more details how manage other steps.

Thx again for all kind support ;)
Rudy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants