I've now got a basic setup for deploying machines via Foreman in Proxmox, but it's a little click-intensive. What if I could create the machine in Foreman and it automatically created the machines in Proxmox?
Enter foreman-fog-proxmox. Somewhat strangely named due to its origins, it adds Proxmox as a "compute resource" in Foreman.
Installing it is easy:
wings@foreman01:~$ sudo apt-get install ruby-foreman-fog-proxmox [sudo] password for wings: Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: ruby-foreman-deface The following NEW packages will be installed: ruby-foreman-deface ruby-foreman-fog-proxmox 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 524 kB of archives. After this operation, 9,849 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://deb.theforeman.org plugins/3.2 amd64 ruby-foreman-deface all 1.5.3-1 [69.3 kB] Get:2 http://deb.theforeman.org plugins/3.2 amd64 ruby-foreman-fog-proxmox all 0.14.0-2 [455 kB] Fetched 524 kB in 2s (345 kB/s) Selecting previously unselected package ruby-foreman-deface. (Reading database ... 104225 files and directories currently installed.) Preparing to unpack .../ruby-foreman-deface_1.5.3-1_all.deb ... Unpacking ruby-foreman-deface (1.5.3-1) ... Selecting previously unselected package ruby-foreman-fog-proxmox. Preparing to unpack .../ruby-foreman-fog-proxmox_0.14.0-2_all.deb ... Unpacking ruby-foreman-fog-proxmox (0.14.0-2) ... Setting up ruby-foreman-deface (1.5.3-1) ... [DEPRECATED] The `--no-prune` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set --local no_prune 'true'`, and stop using this flag Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine. Setting up ruby-foreman-fog-proxmox (0.14.0-2) ... [DEPRECATED] The `--no-prune` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set --local no_prune 'true'`, and stop using this flag Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
Once installed, restarting Foreman (
sudo systemctl restart foreman.service) is enough to make it appear:
Now we need to add some hosts - navigate to Infrastructure -> Compute Resources, and click Create Compute Resource.
We're given a form to fill out, and given the choice of user/auth tokens or session tickets for authentication. Unfortunately user tokens seems to give an error of "ERF42-4050 [Foreman::Exception]: Proxmox version Unknown is not semver suitable" at present (Foreman 3.2.0, Proxmox VE 7.1-8), so I had to change to session tickets.
I added four of my Proxmox hosts, leaving out one underspecced machine that I don't particularly want to deploy to.
Time to test a machine deployment.
Create a host, and we notice four new hosts have appeared under "Deploy On".
Continuing into the wizard:
There appears to be a bug of sorts - to get to the Interfaces section, I had to "Submit" before filling it out, which then dumped me into the Interfaces section (previously a 500 error).
Alas, while we get close to deploying a machine, we don't get all the way there.
I tried some experimental patches from this GitHub PR - https://github.com/theforeman/foreman_fog_proxmox/pull/223 - hoping they'll help.
...with some success!
It's clear the plugin needs a few fixes for Proxmox 7.1 (and possibly Foreman 3.2) but it does work.
I later found you only need one compute resource (and it's simpler that way), as the API exposes all Proxmox nodes even if you only have the one resource, so I removed all but one.
That's it for now. I might update this post if I'm able to resolve those remaining issues.