RHCOS // FHCOS provisioned for openshift

Rebased, thanks!

I know this is an old topic - but can I get a clear understanding of the ability to provision Fedora CoreOS nodes with Foreman.

I follow the detail in this thread, I see the changes made adding the Fedora CoreOS installation media and family type, I see the CoreOS bug that’s been closed to enable the call back, and understand (perhaps wrongly) that Foreman can’t generate ignition files at this time.

However, when I look at the pxe templates they all say ‘this does not support Fedora Core OS’
there is no provisioning template that supports Fedora CoreOS, or a snippet to say pass in the name of an ignition file etc.

So while I see the parts mentioned in this thread, I cannot see a way to do a basic vanilla Fedora CoreOS node provision despite the OS url, family type etc being added.

Hi,

Managed to be able to provision a recent rhcos (411.86.202207150124-0) and fcos (35.20220327.3.0) to automate a OCP/OKD 4.11 installation via foreman.

It depends on an external VM which we call ocpwks, a Ubuntu 20.04 in this case but can be anything.

Services on okdwks:

  • nginx which publishes:
    • a directory to contain the bootstrap/master/worker ignition files
    • a directory to contain the cos--live-rootfs.x86_64.img

Steps to make it work:

  • Create a custom boot directory in you smart proxy.
    i.e. --foreman-proxy-tftp-dirs /var/lib/tftpboot/custom_boot in your proxy
  • Generate a custom coreos initramfs with the post-install script that calls back foreman after installation.
    • Get the foreman_callback.sh script attached to the reply.
    • Download the initramfs for your rhcos/fcos
    • Use coreos-installer to generate a new initramfs with the foreman_callback.sh as a post-install step
      docker run -v /tmp/:/workdir quay.io/coreos/coreos-installer:release pxe customize --post-install /workdir/foreman_callback.sh -o /workdir/source_initramfs /workdir/dest_initramfs
      Ref: Customizing installation - coreos/coreos-installer
  • Copy coreos kernel + dest_initramfs to custom boot directory in you smart proxy
  • Define a custom PXE template to use the custom boot kernel/initrd and properly associate this template to your desired OS. Sample in cos_pxelinux_custom_boot.erb.
  • Define proper host parameters in foreman to use the PXE template

Hope this helps!

If unclear I can add more details.

– It appears I can’t upload files. Here is the content:

foreman_callback.sh

#! /bin/sh

# Curls the foreman built url. 
#
# Fetched by the Kernel arguments provided at boot.

FOREMAN_BUILT_URL=`dmesg | grep -i kern | grep "Kernel command line" | awk -F 'FOREMAN_BUILT_URL=' '{print $2}' | cut -f 1 -d " "`

/usr/bin/curl -o /dev/null --noproxy \* -H 'Content-Type: text/plain' --silent $FOREMAN_BUILT_URL

cos_pxelinux_custom_boot.erb:

<%#
kind: PXELinux
name: CoreOS PXELinux Custom Boot
model: ProvisioningTemplate
oses:
- FedoraCoreOS
- RedHatCoreOS
description: |
  PXE Template for Fedora/RedHat CoreOS with custom kernel/initrd locations

  kernel and initrd paths are provided by host parameters.

  Parameters:
  coreos_rootfs_url           url to get the CoreOS rootfs
  coreos_kernel_args          kernel arguments to pass to the initramfs
  coreos_ignition_urlprefix   complete url for the ignition, minus the filename
  coreos_ignition_filename    filename part of the ignition url

  kernel_path                 location of the kernel
  initrd_path                 location of the initrd

-%>
DEFAULT coreos

LABEL coreos
    KERNEL <%= host_param('kernel_path') %>
    APPEND initrd=<%= host_param('initrd_path') %> coreos.live.rootfs_url=<%= host_param('coreos_rootfs_url') %> FOREMAN_BUILT_URL=<%= foreman_url('built') %> <%= host_param('coreos_kernel_args') %> coreos.inst.ignition_url=<%= host_param('coreos_ignition_urlprefix') %><%= host_param('coreos_ignition_filename') %>
1 Like

Will try to do a tutorial in the proper section with more details.

There are probably neater ways to do the “custom boot” part, i.e. point to a kernel/initramfs not fetched by foreman but user uploaded/generated, and accessible from tftp for PXE booting.

And add a couple of samples.

1 Like

Hello,

we used the tftp and http server, which foreman uses, so we didnt needed an extra vm which provides the ignition files and the rhcos install files.

We have also a mixed env. our compute nodes are plain baremetal, our infra and control plane nodes are on vmware, foreman was the ideal tool to handle both of those deployment architectures.

best regards,
Elias