Failed to detach ISO image from CDROM drive from VMware

Problem:
Provisioning of VMware machines is stuck after upgrading from 2.0.3 to 2.1.4.
At the end of the install process (Ubuntu 18.04/20.04) pressed wants to eject the disk.

Expected outcome:
Works as in version 2.0.3

Foreman and Proxy versions:
Foreman 2.1.4

Foreman and Proxy plugin versions:
foreman-vmware.noarch 2.1.4-1.el7

Distribution and version:
CentOS Linux release 7.9.2009 (Core)

Other relevant data:
/var/log/foreman-proxy/
Failed to detach ISO image from CDROM drive of instance x.y.net: GenericVmConfigFault: Connection control operation failed for disk ‘ide0:0’.

(The VMware setup has not been changed.)

@Bernhard_Suttner implemented a change recently, can you comment please?

@lzap Any workaround for the moment? Can I replace a file with an old one? This is really a show stopper for us. Any help would be appreciated :slight_smile:

Does the user have permissions to do detach action? This can be as simple as VMWare misconfiguration, previously Foreman did not do this API call.

As a workaround you can probably comment out compute_resource.iso_detach(uuid) in Bootdisk codebase.

Even if the Foreman user has the role ‘administrator’ it does not work.
I comment out ‘compute_resource.iso_detach(uuid)’ in line 59 of
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_bootdisk-17.0.2/app/models/concerns/foreman_bootdisk/orchestration/compute.rb
I did a new build but the problem still occurs :frowning:
Is this the correct file at all?
Do I have to restart something?

You have to restart Foreman of course.

Which vmware version do you use?

are you able to detach the iso image in the vmware administration ui?

VMware vSphere 6

Only if I force it:
The guest operating system has locked the CD-ROM door and is probably using the CD-ROM, which can prevent the guest from recognizing media changes. If possible, eject the CD-ROM from inside the guest before disconnecting. Disconnect anyway and override the lock?

yes therefore the kickstart template (or any other provisioning template) includes the eject in case of bootdisk deployment now.

I already added
d-i cdrom-detect/eject boolean true
but that did not fix the problem.

d-i cdrom-detect/eject boolean true
d-i finish-install/reboot_in_progress note

# Verbose output and no boot splash screen.
d-i debian-installer/quiet boolean false
d-i debian-installer/splash boolean false

# Wait for two seconds in grub
d-i grub-installer/timeout string 2

# really, really dist-upgrade
d-i preseed/late_command string in-target apt-get update ; \
                                in-target apt-get -y dist-upgrade ; \
                                in-target apt-get -y autoremove ; \
                                in-target apt-get autoclean ; \
                                in-target apt-get clean; \
                                wget -Y off <%= @static ? "'#{foreman_url('finish')}&static=true'" : foreman_url('finish') %> -O /target/tmp/finish.sh && in-target chmod +x /tmp/finish.sh && in-target /tmp/finish.sh

This is not a Ubuntu/Debian preseed problem.
I tried to install CentOS. Which has worked fine the whole time.
But after the upgrade and I have the same problem.

Last message:
“Informing Foreman that we are built”

and vSphere Center shows:

The guest operating system has locked the CD-ROM door and is probably using the CD-ROM, which can prevent the guest from recognizing media changes. If possible, eject the CD-ROM from inside the guest before disconnecting. Disconnect anyway and override the lock?

I found someone with the same problem:

I switched to the default templates and this fixed the problem but only for CentOS.

Does someone know what must be changed/added in/to the preseed provisioning template to eject properly?

# This will prevent the installer from ejecting the CD during the reboot,
# which is useful in some situations.
#d-i cdrom-detect/eject boolean false

I just realized we have eject commands in most of post/finish templates except Preseed. Try this:

https://github.com/theforeman/foreman/pull/8180

Just add the command into Preseed Finish template and try gain.

Yes, the finish template is the correct place.
An hour ago I added a plain
/usr/bin/eject
before the 3 sed commands and this works for me :+1:
I already deployed a couple of machines :slight_smile:

Can you please head over to the github PR and confirm the change I am proposing works for you?

1 Like

I added it to the finish template.
<%= snippet ‘eject_cdrom’ -%>

Error:
The specified snippet ‘eject_cdrom’ does not exist, or is not a snippet…

Where can I get the snippet?

Everything is in the PR, for a quick test you can just add those commands instead of snippet. For more info:

I created the snippet and called it in the template.
Problem solved :slight_smile: