Tips &amp Tricks » History » Version 9

« Previous - Version 9/10 (diff) - Next » - Current version
Hannes Schaller, 12/12/2013 11:56 AM
added notes about Rails console and exposing variables

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

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)