Custom_package snippet usage help

Problem:
understand the correct usage of the custom_packages snippet in provisioning process

Expected outcome:
Ability to define package addition / removal based on OS version

Other relevant data:
I’m currently trying to understand how to correctly use/include the “custom_package” snippet from a kickstart template.

<%= snippet_if_exists(template_name + “custom_packages”) %>

is included in the default kickstart.
When I first read this I thought creating a snippet called “custom_packages” with contents such as

<% if rhel_compatible && os_major < 8 -%>
#default packages for EL8
-iwl6000-firmware
-iwl2030-firmware
-iwl1000-firmware
-iwl7260-firmware
-iwl6000g2a-firmware
-iwl5150-firmware
-iwl3160-firmware
-iwl2000-firmware
-iwl105-firmware
-iwl100-firmware
-iwl6050-firmware
-iwl5000-firmware
-iwl135-firmware

however it didn’t work.

When I re-read the kickstart default template, I realised that the line (template_name + “custom_packages”) isn’t just create custom_packages snippet it’s the template name AND custom_packages as the snippet name.

(I’m still not sure that’s correct).

If that’s true that means I’d have a snippet called “Kickstart Default custom_packages”
that doesn’t feel right for a snippet name with white spaces like that ? which makes me think I’ve not understood how to use this snippet.

Could someone explain how this is supposed to work please ?

(side question, how is this snippet getting included, I thought all snippets had to be prefixed with a @)

thanks

no-one is using this or is confident they understand how to use it properly ?

I never used this snippet, but I am pretty sure you understood correctly how it works, the snippet should be called “Kickstart Default custom_packages”. This is probably inteded as a way to make customizing your installation easier, while looking through “Kickstart Default” I realized there were several of these imports, for different sections of the installer.
The “usual”/old way of customizing your installation was to clone the default templates and customize those or write your own templates from scratch. This approach needs more maintenance, though, since you have to update and maintain your the templates yourself.

The template is included via the makro/function “snippet_if_exists”, which checks if a snippet by that name exists and includes it if it does. I am not sure where you got the idea from that snippets need to be prefixed with @, I cannot remember I ever saw that notation. The template writing documentation says you normally import snippets via the “snippet” function.

Hope this helps :slight_smile:

thanks for a reply, something is wrong here.

I cloned the kicsktart default to be

new-no-dns-base-kickstart - assigned it CentOS 8 and Rock9
created a custom snippet called “new-no-dns-base-kickstart custom_packages” (I’m really uncomfortable witih the snippet having a space in the name

snippet looks like this (the bold is actually a quote prefixed with # - the formatting is treatin # as bold)

custom packages for EL

packages for all

unzip

<% if rhel_compatible && os_major < 7 -%>

default packages for EL7

<% if rhel_compatible && os_major < 8 -%>
#default packages for EL8
-iwl6000-firmware
-iwl2030-firmware
-iwl1000-firmware
-iwl7260-firmware
-iwl6000g2a-firmware
-iwl5150-firmware
-iwl3160-firmware
-iwl2000-firmware
-iwl105-firmware
-iwl100-firmware
-iwl6050-firmware
-iwl5000-firmware
-iwl135-firmware

<% if rhel_compatible && os_major < 9 -%>
#default packages for EL9
-iwl7260-firmware
-iwl6050-firmware
-iwl6000g2a-firmware
-iwl5150-firmware
-iwl5000-firmware
-iwl3160-firmware
-iwl2030-firmware
-iwl135-firmware
-iwl105-firmware
-iwl1000-firmware
-iwl100-firmware

so it should include ‘unzip’ as a package no matter what, then remove firmware packages depending on the OS version

yet, when I look at the provisioning template for the host (in this example a rocky 9 host) the package list looks like this

%packages

yum
dhclient
chrony
-ntp
@Core
%end

so no unzip - which should be included anyway, and no firmware package removal.

In the beginning you wrote this:

However, the snippet is called:

If there is really no space in "custom_packages" then the full name does not contain a space, i.e. it would be "new-no-dns-base-kickstartcustom_packages" and not "new-no-dns-base-kickstart custom_packages"

I see that, and I’ve shamefully mixed my work around with the official view - to try to work with this I cloned the “kickstart default” package so that I could play with it to get it working, hence the name change.

(which your pointer has allowed me to fix)

the actual Kickstart Default code block looks like this

%packages
<%= snippet_if_exists(template_name + " custom packages") %>

as you can see I put the “_” in and remove the space as I was worried the white space was part of the problem this was working.

If I revert back to the Kickstart Default (which is the goal once a few upstream changes have been merged in)

The actual custom packages snippet name would look like this

“Kickstart Default custom packages”

using spaces like this doesn’t feel good to me as every reference will need to be escaped or quoted with the white spaces.

it may just be my legacy thinking and fear of using white spaces in names/variables.