[install-guide/F21-rewrite] Adding %packages, %pre and %post + examples to Kickstart Syntax Reference

pbokoc pbokoc at fedoraproject.org
Tue Sep 16 23:48:40 UTC 2014


commit 5d7688a00e977b8c43fa228bd733bc5fc0799f03
Author: Petr Bokoc <pbokoc at redhat.com>
Date:   Tue Sep 16 22:58:46 2014 +0200

    Adding %packages, %pre and %post + examples to Kickstart Syntax Reference

 en-US/Kickstart_Syntax_Reference.xml |  412 +++++++++++++++++++++++++++++++++-
 1 files changed, 405 insertions(+), 7 deletions(-)
---
diff --git a/en-US/Kickstart_Syntax_Reference.xml b/en-US/Kickstart_Syntax_Reference.xml
index eaba6fb..c579422 100644
--- a/en-US/Kickstart_Syntax_Reference.xml
+++ b/en-US/Kickstart_Syntax_Reference.xml
@@ -429,30 +429,347 @@
     </section>
     
     <section id="sect-kickstart-packages">
-        <title>Package Selection</title>
+        <title>%packages - Package Selection</title>
         <para>
-            text
+            Use the <command>%packages</command> command to begin a Kickstart section which describes the software packages to be installed.
+        </para>
+        <para>
+            You can specify packages by <firstterm>environment</firstterm>, <firstterm>group</firstterm>, or by their package names. Several environments and groups that contain related packages are defined. See the <filename>repodata/*-comps-<replaceable>variant</replaceable>.<replaceable>architecture</replaceable>.xml</filename> file <remark>TODO: where's comps.xml?</remark>
+        </para>
+        <para>
+            The <filename>*-comps-<replaceable>variant</replaceable>.<replaceable>architecture</replaceable>.xml</filename> file contains a structure describing available environments (marked by the <literal>&lt;environment&gt;</literal> tag) and groups (the <literal>&lt;group&gt;</literal> tag). Each entry has an ID, user visibility value, name, description, and package list. If the group is selected for installation, the packages marked <literal>mandatory</literal> in the package list are always installed, the packages marked <literal>default</literal> are installed if they are not specifically excluded, and the packages marked <literal>optional</literal> must be specifically included even when the group is selected.
+        </para>
+        <para>
+            You can specify a package group or environment using either its ID (the <literal>&lt;id&gt;</literal> tag) or name (the <literal>&lt;name&gt;</literal> tag).
         </para>
+        <important>
+            <para>
+                To install a 32-bit package on a 64-bit system, you will need to append the package name with the 32-bit architecture for which the package was built - for example, <package>glibc.i686</package>. The <option>--multilib</option> option also must be specified in the Kickstart file; see the available options below.
+            </para>	
+        </important>
+        <important>
+            <para>
+                <application>Initial Setup</application> does not run after a system is installed from a Kickstart file unless a desktop environment and the <application>X Window System</application> were included in the installation and graphical login was enabled. This means that by default, no users except for <systemitem class="username">root</systemitem> will be created. You can either create a user with the <option>user</option> option in the Kickstart file before installing additional systems from it (see <xref linkend="sect-kickstart-commands-user" /> for details) or log into the installed system with a virtual console as <systemitem class="username">root</systemitem> and add users with the <command>useradd</command> command.
+            </para>
+        </important>
+        <para>
+            The <command>%packages</command> section must end with the <command>%end</command> command.
+        </para>
+        <variablelist>
+            <title>Specifying Environments, Groups and Packages</title>
+            <varlistentry>
+                <term>Specifying an Environment</term>
+                <listitem>
+                    <para>
+                        In addition to groups, you specify an entire environment to be installed:
+                    </para>
+                    <programlisting>
+<command>%packages</command>
+@^Infrastructure Server
+<command>%end</command>
+                    </programlisting>
+                    <para>
+                        This command will install all packages which are part of the <guilabel>Infrastracture Server</guilabel> environment. All available environments are described in the <filename>repodata/*-comps-<replaceable>variant</replaceable>.<replaceable>architecture</replaceable>.xml</filename> file.
+                    </para>	
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>Specifying Groups</term>
+                <listitem>
+                    <para>
+                        Specify groups, one entry to a line, starting with an <literal>@</literal> symbol, and then the full group name or group id as given in the <filename>*-comps-<replaceable>variant</replaceable>.<replaceable>architecture</replaceable>.xml</filename> file. For example:
+                    </para>
+                    <programlisting>
+<command>%packages</command> 
+ at X Window System
+ at Desktop
+ at Sound and Video
+<command>%end</command>
+                    </programlisting>
+                    <para>
+                        The <literal>Core</literal> and <literal>Base</literal> groups are always selected - it is not necessary to specify them in the <command>%packages</command> section.
+                    </para>
+                    <para>
+                        The <filename>*-comps-<replaceable>variant</replaceable>.<replaceable>architecture</replaceable>.xml</filename> file also defines groups called <literal>Conflicts (<replaceable>variant</replaceable>)</literal> for each variant of &PRODUCT;. This group contains all packages which are known to cause file conflicts, and is intended to be excluded. 
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>Specifying Individual Packages</term>
+                <listitem>
+                    <para>
+                        Specify individual packages by name, one entry to a line. You can use the asterisk character (<literal>*</literal>) as a <firstterm>wildcard</firstterm> in package names. For example:
+                    </para>
+                    <programlisting>
+<command>%packages</command> 
+sqlite
+curl
+aspell
+docbook*
+<command>%end</command>
+                    </programlisting>
+                    <para>
+                        The <literal>docbook*</literal> entry includes the packages <package>docbook-dtds</package>, <package>docbook-simple</package>, <package>docbook-slides</package> and others that match the pattern represented with the wildcard.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>Excluding Environments, Groups, or Packages</term>
+                <listitem>
+                    <para>
+                        Use a leading dash (<literal>-</literal>) to specify packages or groups to exclude from the installation. For example:
+                    </para>
+                    <programlisting>
+<command>%packages</command> 
+- at Graphical Internet 
+-autofs
+-ipa*fonts
+<command>%end</command>
+                    </programlisting>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+        <important>
+            <para>
+                Installing all available packages using only <literal>*</literal> in a Kickstart file is not supported, even if you exclude the <literal>@Conflicts (<replaceable>variant</replaceable>)</literal> group.
+            </para>
+        </important>
+        <para>
+            You can change the default behavior of the <command>%packages</command> section by using several options. Some options work for the entire package selection, others are used with only specific groups.
+        </para>
+        <variablelist>
+            <title>Common Package Selection Options</title>
+            <para>
+                The following options are available for the <command>%packages</command>. To use an option, append it to the start of the package selection section. For example:
+            </para>
+            <programlisting>
+<command>%packages --multilib --ignoremissing</command>
+            </programlisting>	
+            <varlistentry>
+                <term>
+                    <option>--nobase</option>
+                </term>
+                <listitem>
+                    <para>
+                        Do not install the <literal>@Base</literal> group. Use this option to perform a minimal installation, for example, for a single-purpose server or desktop appliance.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>
+                    <option>--ignoremissing</option>
+                </term>
+                <listitem>
+                    <para>
+                        Ignore any packages, groups and environments missing in the installation source, instead of halting the installation to ask if the installation should be aborted or continued.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>
+                    <option>--excludedocs</option>
+                </term>
+                <listitem>
+                    <para>
+                        Do not install any documentation contained within packages. In most cases, this will exclude any files normally installed in the <filename class="directory">/usr/share/doc*</filename> directory, but the specific files to be excluded depend on individual packages.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>
+                    <option>--multilib</option>
+                </term>
+                <listitem>
+                    <para>
+                        Configure the installed system for multilib packages (that is, to allow installing 32-bit packages on a 64-bit system) and install packages specified in this section as such.
+                    </para>
+                    <para>
+                        Normally, on a 64-bit system, only packages for this architecture (marked as <literal>x86_64</literal>) and packages for all architectures (marked as <literal>noarch</literal>) would be installed. When you use this option, packages for 32-bit systems (marked as <literal>i686</literal>) will be automatically installed as well, if available.
+                    </para>
+                    <para>
+                        This only applies to packages explicitly specified in the <command>%packages</command> section. Packages which are only being installed as dependencies without being specified in the Kickstart file will only be installed in architecture versions in which they are needed, even if they are available for more architectures. 
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+        <variablelist>
+            <title>Options for Specific Package Groups</title>
+            <para>
+                The options in this list only apply to a single package group. Instead of using them at the <command>%packages</command> command in the Kickstart file, append them to the group name. For example:
+            </para>
+            <programlisting>
+<command>%packages</command>
+ at Graphical Internet --optional
+<command>%end</command>
+            </programlisting>
+            <varlistentry>
+                <term>
+                    <option>--nodefaults</option>
+                </term>
+                <listitem>
+                    <para>
+                        Only install the group's mandatory packages, not the default selections.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>
+                    <option>--optional</option>
+                </term>
+                <listitem>
+                    <para>
+                        Install packages marked as optional in the group definition in the <filename>*-comps-<replaceable>variant</replaceable>.<replaceable>architecture</replaceable>.xml</filename> file, in addition to installing the default selections.
+                    </para>
+                </listitem>
+            </varlistentry>
+        </variablelist>
     </section>
     
     <section id="sect-kickstart-preinstall">
-        <title>Pre-installation Script</title>
+        <title>%pre - Pre-installation Script</title>
         <para>
-            text
+            You can add commands to run on the system immediately after the Kickstart file has been parsed, but before the installation begins. This section must be placed towards the end of the Kickstart file, after the actual Kickstart commands, and must start with <command>%pre</command> and end with <command>%end</command>. If your Kickstart file also includes a <command>%post</command> section, the order in which the <command>%pre</command> and <command>%post</command> sections are included does not matter.
+        </para>
+        <para>
+            You can access the network in the <command>%pre</command> section. However, the <firstterm>name service</firstterm> has not been configured at this point, so only IP addresses work, not URLs.
+        </para>
+        <para>
+            The pre-installation script section of Kickstart <emphasis>cannot</emphasis> manage multiple install trees or source media. This information must be included for each created Kickstart file, as the pre-installation script occurs during the second stage of the installation process.
+        </para>
+        <note>
+            <para>
+                Unlike the post-installation script, the pre-installation script is not run in the <systemitem>chroot</systemitem> environment.
+            </para>
+        </note>
+        <para>
+            The following options can be used to change the behavior of pre-installation scripts. To use an option, append it to the <command>%pre</command> line at the beginning of the script. For example:
+        </para>
+        <programlisting>
+<command>%pre --interpreter=/usr/bin/python</command>
+--- Python script omitted --
+<command>%end</command>
+        </programlisting>
+        <variablelist>
+            <varlistentry>
+                <term><option>--interpreter=</option></term>
+                <listitem>
+                    <para>
+                        Allows you to specify a different scripting language, such as Python. Any scripting language available on the system can be used; in most cases, these will be <systemitem>/usr/bin/sh</systemitem>, <systemitem>/usr/bin/bash</systemitem>, and <systemitem>/usr/bin/python</systemitem>.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term><option>--erroronfail</option></term>
+                <listitem>
+                    <para>
+                        Display an error and halt the installation if the script fails. The error message will direct you to where the cause of the failure is logged.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term><option>--log=</option></term>
+            <listitem>
+                    <para>
+                        Logs the script's output into the specified log file. For example:
+                    </para>
+                    <programlisting>
+<command>%pre --log=/mnt/sysimage/root/ks-pre.log</command>
+                    </programlisting>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+        <para>
+            For an example of a pre-installation script, see <xref linkend="exam-kickstart-pre-script" />.
         </para>
     </section>
     
      <section id="sect-kickstart-postinstall">
-        <title>Post-installation Script</title>
+        <title>%post - Post-installation Script</title>
         <para>
-            text
+            You have the option of adding commands to run on the system once the installation is complete, but before the system is rebooted for the first time. This section must be placed towards the end of the Kickstart file, after the actual Kickstart commands, and must start with <command>%post</command> and end with <command>%end</command>. If your Kickstart file also includes a <command>%pre</command> section, the order of the <command>%pre</command> and <command>%post</command> sections does not matter.
+        </para>
+        <para>
+            This section is useful for functions such as installing additional software or configuring an additional name server. The post-install script is run in a chroot environment, therefore, performing tasks such as copying scripts or RPM packages from the installation media do not work by default. You can change this behavior using the <option>--nochroot</option> option as described below.
+        </para>	 
+        <important>
+            <para>
+                If you configured the network with static IP information, including a name server, you can access the network and resolve IP addresses in the <command>%post</command> section. If you configured the network for <systemitem>DHCP</systemitem>, the <filename>/etc/resolv.conf</filename> file has not been completed when the installation executes the <command>%post</command> section. You can access the network, but you cannot resolve IP addresses. Thus, if you are using <systemitem>DHCP</systemitem>, you must specify IP addresses in the <command>%post</command> section.
+            </para>
+        </important>
+        <para>
+            The following options can be used to change the behavior of post-installation scripts. To use an option, append it to the <command>%post</command> line at the beginning of the script. For example:
+        </para>
+        <programlisting>
+<command>%post --interpreter=/usr/bin/python</command>
+--- Python script omitted --
+<command>%end</command>
+        </programlisting>
+        <variablelist>
+            <varlistentry>
+                <term><option>--interpreter=</option></term>
+                <listitem>
+                    <para>
+                        Allows you to specify a different scripting language, such as Python. For example:
+                    </para>
+                    <programlisting>
+<command>%post --interpreter=/usr/bin/python</command>
+                    </programlisting>
+                    <para>
+                        Any scripting language available on the system can be used; in most cases, these will be <systemitem>/usr/bin/sh</systemitem>, <systemitem>/usr/bin/bash</systemitem>, and <systemitem>/usr/bin/python</systemitem>.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term><option>--nochroot</option></term>
+                <listitem>
+                    <para>
+                        Allows you to specify commands that you would like to run outside of the chroot environment.
+                    </para>
+                    <para>
+                        The following example copies the file <filename>/etc/resolv.conf</filename> to the file system that was just installed.
+                    </para>
+                    <programlisting>
+<command>%post --nochroot</command>
+cp /etc/resolv.conf /mnt/sysimage/etc/resolv.conf
+<command>%end</command>
+                    </programlisting>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term><option>--erroronfail</option></term>
+                <listitem>
+                    <para>
+                        Display an error and halt the installation if the script fails. The error message will direct you to where the cause of the failure is logged.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term><option>--log=</option></term>
+                <listitem>
+                    <para>
+                        Logs the script's output into the specified log file. Note that the path of the log file must take into account whether or not you use the <option>--nochroot</option> option. For example, without <option>--nochroot</option>:
+                    </para>
+                    <programlisting>
+<command>%post --log=/root/ks-post.log</command>
+                    </programlisting>
+                    <para>
+                        with <option>--nochroot</option>:
+                    </para>
+                    <programlisting>
+<command>%post --nochroot --log=/mnt/sysimage/root/ks-post.log</command>
+                    </programlisting>
+                </listitem>
+            </varlistentry>
+        </variablelist>
+        <para>
+            For an example of a post-installation script, see <xref linkend="sect-kickstart-example-post" />.
         </para>
     </section>
     
     <section id="sect-kickstart-examples">
         <title>Example Kickstart Configurations</title>
 
-        <section id="sect-kickstart-partitioning-example">
+        <section id="sect-kickstart-example-advanced-partitioning">
             <title>Advanced Partitioning Example</title>
             <para>
                 The following is an integrated example showing the <command>clearpart</command>, <command>zerombr</command>, <command>part</command>, <command>raid</command>, <command>volgroup</command>, and <command>logvol</command> Kickstart options in action:
@@ -504,6 +821,87 @@
                 </para>
             </example>
         </section>
+        
+        <section id="sect-kickstart-example-pre">
+            <title>Example Pre-installation Script</title>
+            <para>
+                The following is an example <command>%pre</command> section:
+            </para>
+            <example id="exam-kickstart-pre-script">
+                <title>Sample %pre Script</title>
+                <programlisting>
+<command>%pre</command>
+#!/bin/sh
+hds=""
+mymedia=""
+for file in /proc/ide/h* do
+	mymedia=`cat $file/media`
+	if [ $mymedia == "disk" ] ; then
+		hds="$hds `basename $file`"
+	fi
+done 
+set $hds
+numhd=`echo $#`
+drive1=`echo $hds | cut -d' ' -f1`
+drive2=`echo $hds | cut -d' ' -f2`
+
+#Write out partition scheme based on whether there are 1 or 2 hard drives  
+if [ $numhd == "2" ] ; then
+	#2 drives
+	echo "#partitioning scheme generated in %pre for 2 drives" &gt; /tmp/part-include
+	echo "clearpart --all" &gt;&gt; /tmp/part-include
+	echo "part /boot --fstype xfs --size 75 --ondisk hda" &gt;&gt; /tmp/part-include
+	echo "part / --fstype xfs --size 1 --grow --ondisk hda" &gt;&gt; /tmp/part-include
+	echo "part swap --recommended --ondisk $drive1" &gt;&gt; /tmp/part-include
+	echo "part /home --fstype xfs --size 1 --grow --ondisk hdb" &gt;&gt; /tmp/part-include
+else
+	#1 drive
+	echo "#partitioning scheme generated in %pre for 1 drive" &gt; /tmp/part-include
+	echo "clearpart --all" &gt;&gt; /tmp/part-include
+	echo "part /boot --fstype xfs --size 75" &gt;&gt; /tmp/part-include
+	echo "part swap --recommended" &gt;&gt; /tmp/part-include
+	echo "part / --fstype xfs --size 2048" &gt;&gt; /tmp/part-include
+	echo "part /home --fstype xfs --size 2048 --grow" &gt;&gt; /tmp/part-include
+fi
+<command>%end</command>
+                </programlisting>
+                <para>
+                    This script determines the number of hard drives in the system and writes a text file with a different partitioning scheme depending on whether it has one or two drives. Instead of having a set of partitioning commands in the Kickstart file, include the following line:
+                </para>
+                <programlisting>
+<command>%include /tmp/part-include</command>
+                </programlisting>
+                <para>
+                    The partitioning commands selected in the script will be used.
+                </para>
+            </example>
+        </section>
+        
+        <section id="sect-kickstart-example-post">
+            <title>Example Post-installation Script</title>
+            <para>
+                The following is an example <command>%post</command> section:
+            </para>
+            <example id="exam-kickstart-post-script">
+                <title>Sample %post Script</title>
+                <programlisting>
+# Start of the %post section with logging into /root/ks-post.log
+<command>%post --log=/root/ks-post.log</command>
+
+# Mount an NFS share
+mkdir /mnt/temp
+mount -o nolock 10.10.0.2:/usr/new-machines /mnt/temp
+openvt -s -w -- /mnt/temp/runme
+umount /mnt/temp
+
+# End of the %post section
+<command>%end</command>
+                </programlisting>
+                <para>
+                    The above example mounts an NFS share and executes a script named <filename>runme</filename> located at <filename>/usr/new-machines/</filename> on the share. Note that NFS file locking is <emphasis>not</emphasis> supported while in Kickstart mode, therefore the <option>-o nolock</option> option is required.
+                </para>
+            </example>
+        </section>
 
     </section>
     


More information about the docs-commits mailing list