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 Copy linkLink copied to clipboard!
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 Copy linkLink copied to clipboard!
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:
- Automated installation workflow in Automatically installing RHEL 9
- Automated installation workflow in Automatically installing RHEL 8
- Kickstart Syntax Reference in the Red Hat Enterprise Linux 7 Installation Guide
- 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, orignition, 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
foremanplugin, 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_inittemplate:- 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.
NoteKernel 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
iPXEorgPXEenvironments to use instead of PXELinux.
5.3. Creating provisioning templates Copy linkLink copied to clipboard!
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
- In the Satellite web UI, navigate to Hosts > Templates > Provisioning Templates and click Create Template.
- In the Name field, enter a name for the provisioning template.
- 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
-
Before you create a template with the CLI, create a plain text file that contains the template. This example uses the
~/my-templatefile. Create the template using the
hammer template createcommand and specify the type with the--typeoption:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.4. Cloning provisioning templates Copy linkLink copied to clipboard!
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
- In the Satellite web UI, navigate to Hosts > Templates > Provisioning Templates.
- Find the template that you want to use.
- Click Clone to duplicate the template.
- In the Name field, enter a name for the provisioning template.
- Select the Default checkbox to set the template to associate automatically with new organizations or locations.
- 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.
- In the Audit Comment field, enter a summary of changes to the provisioning template for auditing purposes.
- 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.
- From the Type list, select the type of the template. For example, Provisioning template.
- 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.
- 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.
- Click the Organizations and Locations tabs to add any additional contexts to the template.
- Click Submit to save your provisioning template.
5.5. Running custom code during host provisioning Copy linkLink copied to clipboard!
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
- In the Satellite web UI, navigate to Hosts > Templates > Provisioning Templates.
- Click Create Template.
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 preto the name of a provisioning template to run code before provisioning a host. -
Append
custom postto the name of a provisioning template to run code after provisioning a host.
-
Append
- On the Type tab, select Snippet.
- Click Submit to create your custom provisioning snippet.
CLI procedure
- Create a plain text file that contains your custom snippet.
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
$ hammer template create \ --file "/path/to/My_Snippet" \ --locations "My_Location" \ --name "My_Template_Name_custom_pre" \ --organizations "_My_Organization" \ --type snippetCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.6. Custom provisioning snippet example for Red Hat Enterprise Linux Copy linkLink copied to clipboard!
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
5.7. Associating templates with operating systems Copy linkLink copied to clipboard!
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
- In the Satellite web UI, navigate to Hosts > Templates > Provisioning Templates.
- Select a provisioning template.
- On the Association tab, select all applicable operating systems.
- Click Submit to save your changes.
CLI procedure
Optional: View all templates:
hammer template list
$ hammer template listCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: View all operating systems:
hammer os list
$ hammer os listCopy to Clipboard Copied! Toggle word wrap Toggle overflow Associate a template with an operating system:
hammer template add-operatingsystem \ --id My_Template_ID \ --operatingsystem-id My_Operating_System_ID
$ hammer template add-operatingsystem \ --id My_Template_ID \ --operatingsystem-id My_Operating_System_IDCopy to Clipboard Copied! Toggle word wrap Toggle overflow
5.8. Creating partition tables Copy linkLink copied to clipboard!
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
- In the Satellite web UI, navigate to Hosts > Templates > Partition Tables.
- Click Create Partition Table.
- In the Name field, enter a name for the partition table.
- Select the Default checkbox if you want to set the template to automatically associate with new organizations or locations.
- Select the Snippet checkbox if you want to identify the template as a reusable snippet for other partition tables.
- 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.
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
zerombr clearpart --all --initlabel autopartCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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.
- In the Audit Comment field, add a summary of changes to the partition layout.
- 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.
- Click Submit to save your partition table.
CLI procedure
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
zerombr clearpart --all --initlabel autopartCopy to Clipboard Copied! Toggle word wrap Toggle overflow For more information, see Section 5.10, “Dynamic partition example”.
Create the installation medium using the
hammer partition-table createcommand:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.9. Associating partition tables with disk encryption Copy linkLink copied to clipboard!
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
AppStreamrepository to installclevisduring provisioning.
Procedure
- In the Satellite web UI, navigate to Hosts > Provisioning Setup > Operating Systems.
- Select your Red Hat Enterprise Linux entry.
-
On the Partition Table tab, associate
Kickstart default encryptedwith your operating system entry. -
Create a host group that uses the
Kickstart default encryptedpartition table. For more information, see Working with host groups in Managing hosts. Decrypt the disk of your host during boot time by using one of the following options:
-
LUKS encryption: Add the host parameter
disk_enc_passphraseas type string and your cleartext passphrase of the LUKS container as the value. Clevis and Tang: Add the host parameter
disk_enc_tang_serversas 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 setdisk_enc_passphrasebecause the passphrase slot is removed from the LUKS container after provisioning.
-
LUKS encryption: Add the host parameter
5.10. Dynamic partition example Copy linkLink copied to clipboard!
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') %>
zerombr
clearpart --all --initlabel
autopart <%= host_param('autopart_options') %>
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.