
Snippets
13
For more information, refer to https://fedorahosted.org/cobbler/wiki/KickstartSnippets.
7.3.1. Default Snippets
There are many snippets that ship by default and may be used in kickstarts written on or uploaded to
the Satellite server. You may want to look at a template from a wizard style kickstart located in /var/
lib/rhn/kickstarts/wizard/ and see what default snippets are used and how they are used.
One of the most useful ones is redhat_register.
The redhat_register snippet can be used to register machines to a Satellite server as
part of the kickstart. It uses a special variable called redhat_management_key to register it
to the server. Simply set that variable at either the system, profile, or distro level and then add
$SNIPPET('redhat_register') to a %post section of your kickstart. Any wizard style kickstarts
that are generated by the Satellite server will already include this snippet in it's pre-made %post
section.
7.3.2. Escaping Special Characeters
Since the $ and # characters are used during templating for specifying variables and control flow, you
should not use these characters within scripts without escaping them.
So for example, if you were writing a bash script in a %post section:
%post
echo $foo > /tmp/foo.txt
The templating engine would try to find a variable named $foo and would fail if foo did not exist
as a variable. There are a few ways to escape the $ symbol so it shows up as a bash variable. The
simplest is with a backslash:
%post
echo \$foo > /tmp/foo.txt
\$foo will be rendered as $foo within the kickstart.
A second method is to wrap the entire script in #raw ... #endraw :
%post
#raw
echo \$foo > /tmp/foo.txt
#endraw
All %pre and %post scripts created using the wizard style kickstarts are wrapped with
#raw...#endraw by default. This can be toggled using the Template checkbox available when
editing a %post or %pre script.
The final method is simply by including #errorCatcher Echo in the first line of your kickstart. This
instructs the templating engine to ignore any variables that do not exist and print out the text as is.
Commenti su questo manuale