Tips & Tricks

This page is a collection of useful bits of information that are neither FAQ or Troubleshooting.

General Tips

Extending the partition layout for a host

If you need to extend a partition layout for a host you could load the preexisting layout in the "Custom partition layout" section:

<%= pxe_render(Ptable.find_by_name('RedHat Default').layout) %>
logvol /var --fstype ext4 --name=lv_var --vgname=vg00 --size=4096
logvol /opt --fstype ext4 --name=lv_opt --vgname=vg00 --size=512

Exposing Foreman variables to the ENC

You can enable "interpolate_erb_in_parameters" in the settings, which enables you to expose all Foreman Variables to the ENC.
Go to global parameters and add a new variable:
Name: vmlocation
Value: <%= @host.compute_resource_name %> (or <%= @host.compute_resource.to_label %> )

If you need you can check on the available variables through the Rails console or from the TemplateWriting.

Redhat-based Tips

Starting the Rails console

If you installed Foreman through the RedHat packages you can start the console through the following command:

cd ~foreman && sudo -u foreman scl enable ruby193 'RAILS_ENV=production rails c'

Debian-based Tips

Using apt-cache-ng

Using apt-cacher-ng to cache packages -

Generating /etc/network/interfaces

The Debian installer will overwrite the /etc/network/interfaces file in the target filesystem by default. If you generate this file using a late_command or Foreman's finish script, it will be overwritten. To avoid this, add:

rm -f /usr/lib/finish-install.d/55netcfg-copy-config

to your late_command. Please note that this cannot go in the the finish script, as it is executed in the target filesystem, and the file to remove is in the installer filesystem.

Deploying Windows via WDS

This assumes you're already using Foreman to deploy your linux hosts and want to add the ability to deploy a Windows host.

  • Syslinux >= 5.0 (note that 4.0x has bugs in the chainloader and we could not get it to work in our testing)
  • a DNS resolvable name on your WDS server (Note that syslinux does not check if the name is an IP when using pxechn.c32 - it assumes a name and does a DNS lookup.)

Create a pxe template and associate it with your Windows OS. The template should look something like this -

default Windows
label Windows
    kernel pxechn.c32
    append <NAME_OF_WDS>::\boot\x64\ -W

Replace <NAME_OF_WDS> with your Windows Deployment Server. You may also need to copy pxechn.c32 into your tftpboot directory. This is rather basic and will require you to attach to the VM console and click through the steps you've setup. You can then automate your WDS server as much as you want, and pxe booting to your foreman-enabled PXE service will simply chain off control over to WDS.

Remember to grab the Foreman http at the end of your deployment, or Foreman will keep it in a 'build' state!

Tips for other OSes

  • Automated Archlinux installs (coming soon ;P)