Chapter 5. Preparing templates for provisioning


Satellite provides the following default template types:

  • Provisioning templates
  • Partition tables

You can use the default templates or create custom templates.

Provisioning templates are implemented with parameters that you can configure as host parameters to affect the provisioning process. You can also add custom steps to certain templates by creating custom pre or post snippets and thus customize the provisioning process further without editing the default templates.

Thanks to partition tables implemented as templates, you can create custom, even dynamic, partition tables.

When you do not edit the default templates, maintenance is easier and you get the benefit of updates to the templates from Red Hat.

5.1. Provisioning templates

A provisioning template defines the way Satellite Server installs an operating system on a host.

Red Hat Satellite includes many template examples. In the Satellite web UI, navigate to Hosts > Templates > Provisioning Templates to view them. You can create a template or clone a template and edit the clone. For help with templates, navigate to Hosts > Templates > Provisioning Templates > Create Template > Help.

Templates supported by Red Hat are indicated by a Red Hat icon.

To hide unsupported templates, in the Satellite web UI navigate to Administer > Settings. On the Provisioning tab, set the value of Show unsupported provisioning templates to false and click Submit. You can also filter out the supported templates by making the following query "supported = true".

If you clone a supported template, the cloned template will be unsupported.

Templates accept the Embedded Ruby (ERB) syntax. For more information, see Template Writing Reference in Managing hosts.

You can download provisioning templates. Before you can download the template, you must create a debug certificate. For more information, see Creating an Organization Debug Certificate in Administering Red Hat Satellite.

You can synchronize templates between Satellite Server and a Git repository or a local directory. For more information, see Synchronizing template repositories in Administering Red Hat Satellite.

To view the history of changes applied to a template, navigate to Hosts > Templates > Provisioning Templates, select one of the templates, and click History. Click Revert to override the content with the previous version. You can also revert to an earlier change. Click Show Diff to see information about a specific change:

  • The Template Diff tab displays changes in the body of a provisioning template.
  • The Details tab displays changes in the template description.
  • The History tab displays the user who made a change to the template and date of the change.

5.2. Kinds of provisioning templates

There are various kinds of provisioning templates:

Provision

The main template for the provisioning process. For example, a Kickstart template. For more information about Kickstart syntax and commands, see the following resources:

PXELinux, PXEGrub, PXEGrub2
PXE-based templates that deploy to the template Capsule associated with a subnet to ensure that the host uses the installer with the correct kernel options. For BIOS provisioning, select PXELinux template. For UEFI provisioning, select PXEGrub2.
Finish

Post-configuration scripts to execute using an SSH connection when the main provisioning process completes. You can use Finish templates only for image-based provisioning in virtual or cloud environments that do not support user_data. Do not confuse an image with a foreman discovery ISO, which is sometimes called a Foreman discovery image. An image in this context is an install image in a virtualized environment for easy deployment.

When a finish script successfully exits with the return code 0, Red Hat Satellite treats the code as a success and the host exits the build mode.

Note that there are a few finish scripts with a build mode that uses a call back HTTP call. These scripts are not used for image-based provisioning, but for post configuration of operating-system installations such as Debian, Ubuntu, and BSD. Red Hat does not support provisioning of operating systems other than Red Hat Enterprise Linux.

user_data

Post-configuration scripts for providers that accept custom data, also known as seed data. You can use the user_data template to provision virtual machines in cloud or virtualised environments only. This template does not require Satellite to be able to reach the host; the cloud or virtualization platform is responsible for delivering the data to the image.

Ensure that the image that you want to provision has the software to read the data installed and set to start during boot. For example, cloud-init, which expects YAML input, or ignition, which expects JSON input.

cloud_init

Some environments, such as VMWare, either do not support custom data or have their own data format that limits what can be done during customization. In this case, you can configure a cloud-init client with the foreman plugin, which attempts to download the template directly from Satellite over HTTP or HTTPS. This technique can be used in any environment, preferably virtualized.

Ensure that you meet the following requirements to use the cloud_init template:

  • Ensure that the image that you want to provision has the software to read the data installed and set to start during boot.
  • A provisioned host is able to reach Satellite from the IP address that matches the host’s provisioning interface IP.

    Note that cloud-init does not work behind NAT.

Bootdisk
Templates for PXE-less boot methods.
Kernel Execution (kexec)

Kernel execution templates for PXE-less boot methods.

Note

Kernel Execution is a Technology Preview feature. Technology Preview features are not fully supported under Red Hat Subscription Service Level Agreements (SLAs), may not be functionally complete, and are not intended for production use. However, these features provide early access to upcoming product innovations, enabling customers to test functionality and provide feedback during the development process.

Script
An arbitrary script not used by default but useful for custom tasks.
ZTP
Zero Touch Provisioning templates.
POAP
PowerOn Auto Provisioning templates.
iPXE
Templates for iPXE or gPXE environments to use instead of PXELinux.

5.3. Creating provisioning templates

A provisioning template defines the way Satellite Server installs an operating system on a host. Use this procedure to create a new provisioning template.

Procedure

  1. In the Satellite web UI, navigate to Hosts > Templates > Provisioning Templates and click Create Template.
  2. In the Name field, enter a name for the provisioning template.
  3. Fill in the rest of the fields as required. The Help tab provides information about the template syntax and details the available functions, variables, and methods that can be called on different types of objects within the template.

CLI procedure

  1. Before you create a template with the CLI, create a plain text file that contains the template. This example uses the ~/my-template file.
  2. Create the template using the hammer template create command and specify the type with the --type option:

    $ hammer template create \
    --file ~/my-template \
    --locations "My_Location" \
    --name "My_Provisioning_Template" \
    --organizations "My_Organization" \
    --type provision
    Copy to Clipboard Toggle word wrap

5.4. Cloning provisioning templates

A provisioning template defines the way Satellite Server installs an operating system on a host. Use this procedure to clone a template and add your updates to the clone.

Procedure

  1. In the Satellite web UI, navigate to Hosts > Templates > Provisioning Templates.
  2. Find the template that you want to use.
  3. Click Clone to duplicate the template.
  4. In the Name field, enter a name for the provisioning template.
  5. Select the Default checkbox to set the template to associate automatically with new organizations or locations.
  6. In the Template editor field, enter the body of the provisioning template. You can also use the Template file browser to upload a template file.
  7. In the Audit Comment field, enter a summary of changes to the provisioning template for auditing purposes.
  8. Click the Type tab and if your template is a snippet, select the Snippet checkbox. A snippet is not a standalone provisioning template, but a part of a provisioning template that can be inserted into other provisioning templates.
  9. From the Type list, select the type of the template. For example, Provisioning template.
  10. Click the Association tab and from the Applicable Operating Systems list, select the names of the operating systems that you want to associate with the provisioning template.
  11. Optionally, click Add combination and select a host group from the Host Group list or an environment from the Environment list to associate provisioning template with the host groups and environments.
  12. Click the Organizations and Locations tabs to add any additional contexts to the template.
  13. Click Submit to save your provisioning template.

5.5. Running custom code during host provisioning

You can run custom code before or after provisioning the host by creating a custom provisioning snippet.

Prerequisites

  • Check your provisioning template to ensure that it supports the custom snippets you want to use.

    You can view all provisioning templates under Hosts > Templates > Provisioning Templates.

Procedure

  1. In the Satellite web UI, navigate to Hosts > Templates > Provisioning Templates.
  2. Click Create Template.
  3. In the Name field, enter a name for your custom provisioning snippet. The name must start with the name of a provisioning template that supports including custom provisioning snippets:

    • Append custom pre to the name of a provisioning template to run code before provisioning a host.
    • Append custom post to the name of a provisioning template to run code after provisioning a host.
  4. On the Type tab, select Snippet.
  5. Click Submit to create your custom provisioning snippet.

CLI procedure

  1. Create a plain text file that contains your custom snippet.
  2. Create the template using hammer:

    $ hammer template create \
    --file "/path/to/My_Snippet" \
    --locations "My_Location" \
    --name "My_Template_Name_custom_pre" \ --organizations "_My_Organization" \
    --type snippet
    Copy to Clipboard Toggle word wrap

You can use Custom Post snippets to call external APIs from within the provisioning template directly after provisioning a host.

Kickstart default finish custom post Example for Red Hat Enterprise Linux

echo "Calling API to report successful host deployment"

yum install -y curl ca-certificates

curl -X POST \
-H "Content-Type: application/json" \
-d '{"name": "<%= @host.name %>", "operating_system": "<%= @host.operatingsystem.name %>", "status": "provisioned",}' \
"https://api.example.com/"
Copy to Clipboard Toggle word wrap

5.7. Associating templates with operating systems

You can associate templates with operating systems in Satellite. The following example adds a provisioning template to an operating system entry. To use the CLI instead of the Satellite web UI, see the CLI procedure.

Procedure

  1. In the Satellite web UI, navigate to Hosts > Templates > Provisioning Templates.
  2. Select a provisioning template.
  3. On the Association tab, select all applicable operating systems.
  4. Click Submit to save your changes.

CLI procedure

  1. Optional: View all templates:

    $ hammer template list
    Copy to Clipboard Toggle word wrap
  2. Optional: View all operating systems:

    $ hammer os list
    Copy to Clipboard Toggle word wrap
  3. Associate a template with an operating system:

    $ hammer template add-operatingsystem \
    --id My_Template_ID \
    --operatingsystem-id My_Operating_System_ID
    Copy to Clipboard Toggle word wrap

5.8. Creating partition tables

A partition table is a type of template that defines the way Satellite Server configures the disks available on a new host. A Partition table uses the same ERB syntax as provisioning templates. Red Hat Satellite contains a set of default partition tables to use, including a Kickstart default. You can also edit partition table entries to configure the preferred partitioning scheme, or create a partition table entry and add it to the operating system entry.

To use the CLI instead of the Satellite web UI, see the CLI procedure.

Procedure

  1. In the Satellite web UI, navigate to Hosts > Templates > Partition Tables.
  2. Click Create Partition Table.
  3. In the Name field, enter a name for the partition table.
  4. Select the Default checkbox if you want to set the template to automatically associate with new organizations or locations.
  5. Select the Snippet checkbox if you want to identify the template as a reusable snippet for other partition tables.
  6. From the Operating System Family list, select the distribution or family of the partitioning layout. For example, Red Hat Enterprise Linux, CentOS, and Fedora are in the Red Hat family.
  7. In the Template editor field, enter the layout for the disk partition.

    The format of the layout must match that for the intended operating system. For example, Red Hat Enterprise Linux requires a layout that matches a Kickstart file, such as:

    zerombr
    clearpart --all --initlabel
    autopart
    Copy to Clipboard Toggle word wrap

    For more information, see Section 5.10, “Dynamic partition example”.

    You can also use the file browser in the template editor to import the layout from a file.

  8. In the Audit Comment field, add a summary of changes to the partition layout.
  9. Click the Organizations and Locations tabs to add any other provisioning contexts that you want to associate with the partition table. Satellite adds the partition table to the current provisioning context.
  10. Click Submit to save your partition table.

CLI procedure

  1. Create a plain text file, such as ~/My_Partition_Table, that contains the partition layout.

    The format of the layout must match that for the intended operating system. For example, Red Hat Enterprise Linux requires a layout that matches a Kickstart file, such as:

    zerombr
    clearpart --all --initlabel
    autopart
    Copy to Clipboard Toggle word wrap

    For more information, see Section 5.10, “Dynamic partition example”.

  2. Create the installation medium using the hammer partition-table create command:

    $ hammer partition-table create \
    --file "~/My_Partition_Table" \
    --locations "My_Location" \
    --name "My_Partition_Table" \
    --organizations "My_Organization" \
    --os-family "Redhat" \
    --snippet false
    Copy to Clipboard Toggle word wrap

Satellite contains partition tables that encrypt the disk of your host by using Linux Unified Key Setup (LUKS) during host provisioning. Encrypted disks on hosts protect data at rest. Optionally, you can also bind the disk to a Tang server through Clevis for decryption during boot.

Associate the partition table with your operating system entry. Then, you assign the partition table to your host group or select it manually during provisioning.

Prerequisites

  • Your host has access to the AppStream repository to install clevis during provisioning.

Procedure

  1. In the Satellite web UI, navigate to Hosts > Provisioning Setup > Operating Systems.
  2. Select your Red Hat Enterprise Linux entry.
  3. On the Partition Table tab, associate Kickstart default encrypted with your operating system entry.
  4. Create a host group that uses the Kickstart default encrypted partition table. For more information, see Working with host groups in Managing hosts.
  5. Decrypt the disk of your host during boot time by using one of the following options:

    • LUKS encryption: Add the host parameter disk_enc_passphrase as type string and your cleartext passphrase of the LUKS container as the value.
    • Clevis and Tang: Add the host parameter disk_enc_tang_servers as type array and your list of Tang servers (example: ["1.2.3.4"] or ["server.example.com", "5.6.7.8"]).

      If you set disk_enc_tang_servers, do not set disk_enc_passphrase because the passphrase slot is removed from the LUKS container after provisioning.

5.10. Dynamic partition example

Using an Anaconda Kickstart template, the following section instructs Anaconda to erase the whole disk, automatically partition, enlarge one partition to maximum size, and then proceed to the next sequence of events in the provisioning process:

zerombr
clearpart --all --initlabel
autopart <%= host_param('autopart_options') %>
Copy to Clipboard Toggle word wrap

Dynamic partitioning is executed by the installation program. Therefore, you can write your own rules to specify how you want to partition disks according to runtime information from the node, for example, disk sizes, number of drives, vendor, or manufacturer.

If you want to provision servers and use dynamic partitioning, add the following example as a template. When the #Dynamic entry is included, the content of the template loads into a %pre shell scriplet and creates a /tmp/diskpart.cfg that is then included into the Kickstart partitioning section.

#Dynamic (do not remove this line)

MEMORY=$((`grep MemTotal: /proc/meminfo | sed 's/^MemTotal: *//'|sed 's/ .*//'` / 1024))
if [ "$MEMORY" -lt 2048 ]; then
    SWAP_MEMORY=$(($MEMORY * 2))
elif [ "$MEMORY" -lt 8192 ]; then
    SWAP_MEMORY=$MEMORY
elif [ "$MEMORY" -lt 65536 ]; then
    SWAP_MEMORY=$(($MEMORY / 2))
else
    SWAP_MEMORY=32768
fi

cat <<EOF > /tmp/diskpart.cfg
zerombr
clearpart --all --initlabel
part /boot --fstype ext4 --size 200 --asprimary
part swap --size "$SWAP_MEMORY"
part / --fstype ext4 --size 1024 --grow
EOF
Copy to Clipboard Toggle word wrap
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat