Automated provisioning (#3) - The Foreman, part 3 - Deploying a test machine
It's time to test out Foreman properly, and deploy a machine.
Preparation
Navigate to Hosts -> Provisioning Setup -> Operating Systems.
We see there's already an operating system - Debian 11.3 - which was created/discovered because our host machine runs it.
Open it up and have a look:
We'll add a partition table...
I go through the rest of the wizard, then hit Submit.
Deployment time
Time to deploy a machine.
Adding the machine in Proxmox
We need to create a machine in Proxmox and grab its MAC address to add to Foreman. We open Proxmox, right click a host we want to deploy on, then click Create VM.
Then we give it a name:
Since we'll be using Foreman to deploy this machine via PXE, we'll tell it "Do not use any media", then skip through to Disks.
We go with the default size disk (since we'll delete this machine later anyway), then go to the next tab.
We give it 4 CPU cores:
and 4GiB of memory...
Skipping through the Network tab, we confirm the VM looks good, but don't start it yet.
Now that the VM has been created, we go to its Hardware tab and open the settings for its network card.
From here, we copy its MAC address to the clipboard for later use.
Adding the machine in Foreman
Navigating to Hosts -> All Hosts, I then click Create Host
.
We'll call our new machine foreman-test01
Next, we'll pick the Operating System to deploy:
Then we click Interfaces, and Edit.
Here, we select our domain and subnet and paste the MAC address from earlier into the MAC Address field.
Then we hit Submit to create our machine, since we don't need to set or change any other settings.
Foreman begins creating the DHCP settings for our new machine.
And... fails.
Trying again, it works fine!
Now we boot our machine:
Not quite there yet.
We'll need to enable a provisioning template for a PXE loader.
Navigate to Provisioning Templates.
Then we open Preseed default PXELinux.
In the editor for Preseed default PXELinux, we click Association.
And click Debian 11.3 to move it to the "Selected items" column, then hit Submit.
Navigating back to the Operating System definition for Debian 11.3, we open the Templates tab, then select the Preseed default PXELinux
template in the new PXELinux template
dropdown, and Submit.
We navigate back to our newly defined host, and select PXELinux BIOS
as the PXE loader for it.
Let's try again. Turn our machine on:
This is because we also need a provisioning template for the host.
We go back to Provisioning Templates, search for "Preseed" (since it's Debian), open it up and associate it with the Debian operating system, just like before.
Once again, a new dropdown appears in our Operating Systems -> Debian 11.3 -> Templates tab... and we select the new Provisioning template.
Once that's done, we go back to our machine and try another boot... and...
We have liftoff!
Drat, we got so far. Nevertheless, the machine works after hitting Continue
.
Investigating /var/log/foreman/production.log
we find one more template we're missing:
2022-04-30T23:51:00 [I|app|e8a04347] Started GET "/unattended/finish?token=310795d1-0062-4f10-9321-1b7a74a25aed" for 10.1.202.55 at 2022-04-30 23:51:00 +0800
2022-04-30T23:51:00 [I|app|e8a04347] Processing by UnattendedController#host_template as TEXT
2022-04-30T23:51:00 [I|app|e8a04347] Parameters: {"token"=>"310795d1-0062-4f10-9321-1b7a74a25aed", "kind"=>"finish"}
2022-04-30T23:51:00 [E|app|e8a04347] unable to find finish template for foreman-test01.windowpa.in running Debian 11.3
2022-04-30T23:51:00 [I|app|e8a04347] Rendering text template
2022-04-30T23:51:00 [I|app|e8a04347] Rendered text template (Duration: 0.0ms | Allocations: 1)
2022-04-30T23:51:00 [I|app|e8a04347] Completed 404 Not Found in 59ms (Views: 0.5ms | ActiveRecord: 26.2ms | Allocations: 9233)
Once more, we do the dance:
And we reboot and re-deploy the machine. (Hint: While booting, hit Esc, then select iPXE).
We have a fresh Debian 11 machine, deployed completely automatically.
And so our Foreman journey has begun - next time, we'll try reinstalling Foreman without Puppet once more, with our own custom TLS/SSL certificates.