ESXi provisioning

Problem:
I get the following error while ESXi is installing:

Error (see log for more info):
File (http://foreman.*****.de/unattended/provision) connection failed. Made 5 attempts.
HTTP Error 404: Not found

Expected outcome:
Pulling the provisioning template from foreman.

Foreman and Proxy versions:
1.20

Foreman and Proxy plugin versions:

Other relevant data:
Used this howto:
https://theforeman.org/2018/08/deploying-esxi-through-foreman.ht

Ping from the “new ESXi Server” to foreman.*****.de work’s.

Debian installations are working fine.

Any suggestions?

Check for any errors on the foreman side, in /var/log/foreman/production.log - see if the request to that endpoint gets through and if there are any further messages there.

Hello, i just get the following error:
unattended: unable to find a host that matches the request from 10.208.213.18

Which makes sense because at my ESXi boot.cfg there is just
kernelopt=ks=http://foreman.******.de/unattended/provision

You might want to use tokens for this.
I’m not familiar with the tutorial, but I’d try to make boot.cfg a proper Foreman template so the URL includes the build token (token=whatever as a url parameter so Foreman can identify the request).

Yeah, i dont get this tutorial…
I am using tokens right now.
Working fine.
My only problem is the dhcp server (choose bootloader).

I’m afraid a proper fix requires changes to Foreman code.
Are you aware of https://github.com/theforeman/foreman/pull/3998/files? This might include all the necessary changes.

1 Like

This is a mess, we’d appreciate some work in Foreman core to allow smooth ESXi provisioning. New template kinds might be necessary, these changes are not huge but it must be done by somebody who understands how PXE work in VMWare. Patches welcome.

1 Like

I have a question referring to /usr/share/foreman/app/models/concerns/pxe_loader_support.rb.
There is the “all_loaders_map”.
I don’t get the function of the option in foreman where i can choose out of this all_loaders_map a matching PXE loader.
In my dhcpd config i got filename “pxelinux.0”. If i switch the PXE loader at Foreman, nothing happens.
So… Do i understand this Foreman option wrong in general?

This maps exactly to DHCP option “filename”, if you change this value Foreman should orchestrate a DHCP deletion and creation to update this value on your DHCP server. We had a bug in older versions and this was not working properly, but I am sure that 1.20 should be good now.

Where can i check the updated value after changing it in Foreman?

Syslog looks like
Jan 14 11:09:52 foreman in.tftpd[10577]: RRQ from 10.208.213.14 filename pxelinux.0 Jan 14 11:09:52 foreman in.tftpd[10577]: tftp: client does not accept options Jan 14 11:09:52 foreman in.tftpd[10578]: RRQ from 10.208.213.14 filename pxelinux.0 Jan 14 11:09:52 foreman in.tftpd[10579]: RRQ from 10.208.213.14 filename ldlinux.c32 Jan 14 11:09:52 foreman in.tftpd[10580]: RRQ from 10.208.213.14 filename pxelinux.cfg/423aadf4-acef-80d4-a8e0-ca625141af66 Jan 14 11:09:52 foreman in.tftpd[10581]: RRQ from 10.208.213.14 filename pxelinux.cfg/01-00-50-56-ba-35-25 Jan 14 11:09:52 foreman in.tftpd[10582]: RRQ from 10.208.213.14 filename ../boot/ESXi-6.0.0/mboot.c32

dhcp.leases file, not it’s a append-only file. Old entry will be deleted via “deleted” statement and new one appended.

There is only one entry:

lease 10.208.213.14 {
  starts 3 2019/01/16 12:41:22;
  ends 3 2019/01/16 12:51:22;
  cltt 3 2019/01/16 12:41:22;
  binding state active;
  next binding state free;
  rewind binding state free;
  hardware ethernet 00:50:56:ba:35:25;
  set vendor-class-identifier = "PXEClient:Arch:00000:UNDI:002001";
}

How do you switch it then? Using UI?

Enable debug mode and pastebin the relevant transaction from production.log there should be details about orchestration - Foreman should schedule DHCP orchestration change.

Yeah i switch using the ui.

2019-01-17T12:20:23 [I|app|] Started PATCH "/hosts/48" for 10.208.1.159 at 2019-01-17 12:20:23 +0100
2019-01-17T12:20:23 [I|app|7961f] Processing by HostsController#update as */*
2019-01-17T12:20:23 [I|app|7961f]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"D+0G4cymPkVScxfbq83ky/FqGEVc/5tqlKJG/7h2BI33gjBYUKaRisJ5hXWYcVROileLkx7X0PnblPv+18IAlw==", "host"=>{"name"=>"mac005056ba3525", "hostgroup_id"=>"", "environment_id"=>"", "puppet_proxy_id"=>"", "puppet_ca_proxy_id"=>"", "ansible_role_ids"=>[""], "managed"=>"true", "progress_report_id"=>"[FILTERED]", "interfaces_attributes"=>{"0"=>{"_destroy"=>"0", "mac"=>"00:50:56:ba:35:25", "identifier"=>"ens32", "name"=>"mac005056ba3525", "domain_id"=>"1", "subnet_id"=>"1", "ip"=>"10.208.213.16", "ip6"=>"", "managed"=>"1", "primary"=>"1", "provision"=>"1", "execution"=>"1", "tag"=>"", "attached_to"=>"", "id"=>"54"}}, "architecture_id"=>"1", "operatingsystem_id"=>"8", "medium_id"=>"13", "ptable_id"=>"95", "pxe_loader"=>"PXELinux Alt BIOS", "disk"=>"", "is_owned_by"=>"4-Users", "enabled"=>"1", "model_id"=>"1", "comment"=>"", "overwrite"=>"false"}, "id"=>"48"}
2019-01-17T12:20:23 [I|app|7961f] Current user set to admin (admin)
2019-01-17T12:20:23 [D|app|7961f] Current organization set to none
2019-01-17T12:20:23 [D|app|7961f] Current location set to none
2019-01-17T12:20:23 [I|aud|7961f] Host::Base (48) update event on pxe_loader None, PXELinux Alt BIOS
2019-01-17T12:20:23 [I|app|7961f] Redirected to https://foreman.server.de/hosts/mac005056ba3525.server.de
2019-01-17T12:20:23 [D|app|7961f] Current location set to none
2019-01-17T12:20:23 [D|app|7961f] Current organization set to none
2019-01-17T12:20:23 [I|app|7961f] Completed 302 Found in 127ms (ActiveRecord: 15.4ms)
2019-01-17T12:20:23 [I|app|] Started GET "/hosts/mac005056ba3525.server.de" for 10.208.1.159 at 2019-01-17 12:20:23 +0100
2019-01-17T12:20:23 [I|app|95550] Processing by HostsController#show as */*
2019-01-17T12:20:23 [I|app|95550]   Parameters: {"id"=>"mac005056ba3525.server.de"}
2019-01-17T12:20:23 [I|app|95550] Current user set to admin (admin)
2019-01-17T12:20:23 [I|app|95550]   Rendering hosts/show.html.erb within layouts/application
2019-01-17T12:20:23 [I|app|95550]   Rendered hosts/show.html.erb within layouts/application (20.7ms)
2019-01-17T12:20:23 [I|app|95550]   Rendered layouts/_application_content.html.erb (0.6ms)
2019-01-17T12:20:23 [I|app|95550]   Rendering layouts/base.html.erb
2019-01-17T12:20:23 [I|app|95550]   Rendered layouts/base.html.erb (18.6ms)
2019-01-17T12:20:23 [I|app|95550] Completed 200 OK in 52ms (Views: 38.8ms | ActiveRecord: 4.6ms)
2019-01-17T12:20:23 [I|app|] Started GET "/hosts/mac005056ba3525.server.de/overview" for 10.208.1.159 at 2019-01-17 12:20:23 +0100
2019-01-17T12:20:23 [I|app|] Started GET "/hosts/mac005056ba3525.server.de/templates" for 10.208.1.159 at 2019-01-17 12:20:23 +0100
2019-01-17T12:20:23 [I|app|2cc40] Processing by HostsController#overview as HTML
2019-01-17T12:20:23 [I|app|2cc40]   Parameters: {"id"=>"mac005056ba3525.server.de"}
2019-01-17T12:20:23 [I|app|2cc40] Current user set to admin (admin)
2019-01-17T12:20:23 [I|app|] Started GET "/hosts/mac005056ba3525.server.de/runtime?range=7" for 10.208.1.159 at 2019-01-17 12:20:23 +0100
2019-01-17T12:20:23 [I|app|] Started GET "/hosts/mac005056ba3525.server.de/nics" for 10.208.1.159 at 2019-01-17 12:20:23 +0100
2019-01-17T12:20:23 [I|app|] Started GET "/hosts/mac005056ba3525.server.de/resources?range=7" for 10.208.1.159 at 2019-01-17 12:20:23 +0100
2019-01-17T12:20:23 [I|app|2ad40] Processing by HostsController#nics as HTML
2019-01-17T12:20:23 [I|app|2ad40]   Parameters: {"id"=>"mac005056ba3525.server.de"}
2019-01-17T12:20:23 [I|app|ce569] Processing by HostsController#runtime as HTML
2019-01-17T12:20:23 [I|app|ce569]   Parameters: {"range"=>"7", "id"=>"mac005056ba3525.server.de"}
2019-01-17T12:20:23 [I|app|d4e08] Processing by HostsController#resources as HTML
2019-01-17T12:20:23 [I|app|2ad40] Current user set to admin (admin)
2019-01-17T12:20:23 [I|app|d4e08]   Parameters: {"range"=>"7", "id"=>"mac005056ba3525.server.de"}
2019-01-17T12:20:23 [I|app|99f6c] Processing by HostsController#templates as HTML
2019-01-17T12:20:23 [I|app|99f6c]   Parameters: {"id"=>"mac005056ba3525.server.de"}
2019-01-17T12:20:23 [I|app|d4e08] Current user set to admin (admin)
2019-01-17T12:20:23 [I|app|ce569] Current user set to admin (admin)
2019-01-17T12:20:23 [I|app|99f6c] Current user set to admin (admin)
2019-01-17T12:20:23 [I|app|2cc40]   Rendered hosts/_overview.html.erb (28.5ms)
2019-01-17T12:20:23 [I|app|2cc40] Completed 200 OK in 52ms (Views: 19.1ms | ActiveRecord: 17.1ms)
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [I|app|ce569]   Rendered hosts/_runtime.html.erb (18.3ms)
2019-01-17T12:20:23 [I|app|ce569] Completed 200 OK in 49ms (Views: 3.2ms | ActiveRecord: 33.6ms)
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [I|app|d4e08]   Rendered hosts/_resources.html.erb (23.6ms)
2019-01-17T12:20:23 [I|app|d4e08] Completed 200 OK in 65ms (Views: 39.3ms | ActiveRecord: 17.4ms)
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current location set to none
2019-01-17T12:20:23 [D|app|99f6c] Current organization set to none
2019-01-17T12:20:23 [I|app|99f6c]   Rendered hosts/_templates.html.erb (5.1ms)
2019-01-17T12:20:23 [I|app|99f6c] Completed 200 OK in 106ms (Views: 5.2ms | ActiveRecord: 46.8ms)
2019-01-17T12:20:24 [I|app|2ad40]   Rendered hosts/_nics.html.erb (250.1ms)
2019-01-17T12:20:24 [I|app|2ad40] Completed 200 OK in 274ms (Views: 240.7ms | ActiveRecord: 24.8ms)

Looks good for me.

Can you share what values you have for the None and PXELinux Alt BIOS options? The code makes the decision on values, if they change (via boot_filename) DHCP redeployment is orchestrated:

  def dhcp_update_required?
    # IP Address / name changed, or 'rebuild' action is triggered and DHCP record on the smart proxy is not present/identical.
    return true if ((old.ip != ip) || (old.hostname != hostname) || provision_mac_addresses_changed? || (old.subnet != subnet) || (operatingsystem.boot_filename(old.host) != operatingsystem.boot_filename(self.host)) ||
                    (!old.build? && build? && !all_dhcp_records_valid?))

I just tested this with develop branch and it works, the UI shows me a warning page about “DHCP conflict” but once I click Overwrite it works fine:

host paul-janvier.home.lan {
  dynamic;
  deleted;
}
host paul-janvier.home.lan {
  dynamic;
  hardware ethernet 52:54:00:89:14:54;
  fixed-address 192.168.99.175;
        supersede server.filename = "pxelinux.0";
        supersede server.next-server = c0:a8:64:01;
        supersede host-name = "paul-janvier.home.lan";
}
host paul-janvier.home.lan {
  dynamic;
  deleted;
}
host paul-janvier.home.lan {
  dynamic;
  hardware ethernet 52:54:00:89:14:54;
  fixed-address 192.168.99.175;
        supersede server.filename = "pxelinux.efi";
        supersede server.next-server = c0:a8:64:01;
        supersede host-name = "paul-janvier.home.lan";
}

The None option is the default set by Foreman.
Where can i check the values? Or what do u mean with bootfile? The files in the tftp directory?

You need to have a Subnet associated with your host and this Subnet must have a DHCP Proxy set and that proxy must have a DHCP feature set.

Oh… wasn’t enabled.

# Enable DHCP management
#Can be true, false, or http/https to enable just one of the protocols
:enabled: true

Foreman-Proxy restartet. DHCP features is now enabled.

Still no new entry in leases file after changing the PXE Loader at the Foreman UI.

Do i need more Foreman-Proxy plugins?