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.

Opening the Operating Systems panel in Foreman.

We see there's already an operating system - Debian 11.3 - which was created/discovered because our host machine runs it.

Debian 11 came "pre-loaded", kind of. Handy.

Open it up and have a look:

Opening the Debian 11 operating system definition in Foreman.

We'll add a partition table...

Adding a partition table. I clicked "Preseed default LVM", adding it to the right column.
Adding installation media. I clicked "Debian mirror" to add it to the column on the right.

I go through the rest of the wizard, then hit Submit.

Successfully updated Debian 11.3, just what we want to see.

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.

Opening the VM creation wizard in Proxmox.

Then we give it a name:

Giving our machine 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.

Telling Proxmox not to use any special boot media.

We go with the default size disk (since we'll delete this machine later anyway), then go to the next tab.

We'll go with the default 32GiB disk.

We give it 4 CPU cores:

Giving our machine 4 CPU cores.

and 4GiB of memory...

Setting memory to 4GiB.

Skipping through the Network tab, we confirm the VM looks good, but don't start it yet.

Finalising settings for the VM.

Now that the VM has been created, we go to its Hardware tab and open the settings for its network card.

Navigating to the Hardware tab and selecting the network card.

From here, we copy its MAC address to the clipboard for later use.

Copying the MAC address for our machine's network card.

Adding the machine in Foreman

Navigating to Hosts -> All Hosts, I then click Create Host.

We'll call our new machine foreman-test01

Configuring foreman-test01 through the Hosts tab.

Next, we'll pick the Operating System to deploy:

Setting Operating System settings for our new host.

Then we click Interfaces, and Edit.

Opening the settings for our interface.

Here, we select our domain and subnet and paste the MAC address from earlier into the MAC Address field.

Selecting interface/network settings for the new machine.

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.

Here we go...

And... fails.

Womp womp.

Trying again, it works fine!

Nice!

Now we boot our machine:

We're close, I can feel it.

Not quite there yet.

We'll need to enable a provisioning template for a PXE loader.

Navigate to Provisioning Templates.

Navigating to the Provisioning Templates section.

Then we open Preseed default PXELinux.

Searching for "Preseed default PXELinux" in the list of provisioning templates.

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.

Associating Debian 11.3 with this template.

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.

Selecting Preseed default PXELinux from the dropdown.

We navigate back to our newly defined host, and select PXELinux BIOS as the PXE loader for it.

Selecting PXELinux BIOS as our PXE loader.

Let's try again. Turn our machine on:

PXELinux successfully loads!
...but we don't make it through the install.

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.

Selecting the "Preseed default" provisioning template.

Once again, a new dropdown appears in our Operating Systems -> Debian 11.3 -> Templates tab... and we select the new Provisioning template.

Selecting "Preseed default" in our new dropdown

Once that's done, we go back to our machine and try another boot... and...

Much more success!

We have liftoff!

Getting closer...
A few minutes later...
The base system is installed.
Now we need a few packages.
So close!
And yet...

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:

Hopefully the last time we need to do this for now.

And we reboot and re-deploy the machine. (Hint: While booting, hit Esc, then select iPXE).

Success!

We have a fresh Debian 11 machine, deployed completely automatically.

A successfully deployed machine.

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.