4.6 Creating a Kickstart Profile in Cobbler

You can also create Kickstart profiles in Cobbler outside of Spacewalk. As for Spacewalk, a profile defines how to configure an installation if the target client has to perform a certain role. For example, you might want to configure a system as a web or database server. To create a profile in Cobbler, you associate a Kickstart file with a distribution.

You can use the cobbler profile list command to list the profiles that are known to Cobbler, for example:

# cobbler profile list
   ol6u6-x86_64

To find out which Kickstart file a profile uses, run the cobbler profile report command, for example:

# cobbler profile report ol6u6-x86_64 | grep Kickstart
Kickstart                      : /var/lib/cobbler/kickstarts/sample.ks
Kickstart Metadata             : {}

The default sample.ks and other Kickstart files that Cobbler provides in /var/lib/cobbler/kickstarts are unlikely to be suitable for provisioning clients.

To create a new profile for a distribution:

  1. Create the Kickstart file to associate with a distribution.

    For example, the following file, named ol6u6_basic_server.ks, contains a Kickstart definition for a basic Oracle Linux 6 server:

    # Oracle Linux 6 Basic Server
    # Use text-based installation
    text
    # Install using HTTP from a URL provided by Cobbler
    url --url=$tree
    # Define localized settings
    lang en_US.UTF-8
    keyboard us
    timezone --utc America/New_York
    # Configure network interface settings
    network --onboot yes --device eth0 --bootproto dhcp --noipv6
    # root password is an SHA-512 hash provided by Cobbler
    rootpw  --iscrypted $default_password_crypted
    authconfig --enableshadow --passalgo=sha512
    # Allow only SSH connections
    firewall --service=ssh
    # Configure SELinux enforcing mode
    selinux --enforcing
    # Perform a new installation, removing all existing partitions
    # before configuring the new boot loader and disk partitions
    install
    zerombr
    clearpart --drives=sda --all --initlabel
    bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
    autopart
    # Shutdown and power off the system after installation is finished
    # to allow you to change the boot order or make other changes.
    poweroff
    # Alternatives are halt (default), reboot, and shutdown,
    # which might not be suitable for unattended installations
    
    # Package groups and packages to be installed
    %packages
    ...
    %end

    For sample package lists, see Appendix B, Sample Package Lists.

    Note

    This example requires that you configure an SHA-512 password hash for the default_password_crypted setting in /etc/cobbler/settings.

    This example does not take advantage of the power of Kickstart templating and snippets for managing large numbers of profiles and systems in Cobbler. For more information, see the cobbler(1) manual page and http://www.cobblerd.org/.

  2. If SELinux is enabled in enforcing mode on your system and you create the Kickstart file in a directory other than /var/lib/cobbler/kickstarts, for example /var/kickstart:

    1. Use the semanage command to define the default file type of the directory hierarchy as cobbler_var_lib_t, for example:

      # /usr/sbin/semanage fcontext -a -t cobbler_var_lib_t "/var/kickstart(/.*)?"

    2. Use the restorecon command to apply the file type to the entire directory hierarchy.

      # /sbin/restorecon -R -v /var/kickstart

    3. For each Kickstart file in the directory, use the chcon command to set the SELinux user to system_u.

      # chcon -u system_u /var/kickstart/*.ks

    If SELinux is enabled in enforcing mode on your system and you create the Kickstart file in /var/lib/cobbler/kickstarts or in a directory on which you have defined the default file type as cobbler_var_lib_t, use the chcon command to set the SELinux user of the file to system_u, for example:

    # chcon -u system_u ol6u6_basic_server.ks

    You can use the ls -Z command to display the context, for example:

    # ls -Z ol6u6_basic_server.ks
    -rw-rw-r--. root root system_u:object_r:cobbler_var_lib_t:s0 ol6u6_basic_server.ks

    The correct SELinux context for a Kickstart file used by Cobbler is system_u:object_r:cobbler_var_lib_t:s0.

  3. Use the cobbler profile add command to create the profile, for example:

    # cobbler profile add --name=ol6u6_basic_server --distro=ol6u6-x86_64 \
      --kickstart=/var/lib/cobbler/kickstarts/ol6u6_basic_server.ks
    Note

    If this command returns the error kickstart not found for a file that does exist at the specified path, the file's SELinux context is incorrect. See the previous step for details of how to set the correct SELinux context on a file.

  4. Enter the cobbler profile list command to display the profiles that are now known to Cobbler.

    # cobbler profile list
       ol6u6-x86_64
       ol6u6_basic_server

    The ol6u6-x86_64 profile is unlikely to be usable. If you want to remove a profile, use the cobbler profile remove command.

    # cobbler profile remove --name=ol6u6-x86_64
    # cobbler profile list
       ol6u6_basic_server
    Note

    Removing a profile also removes any client system definitions that you have created from that profile.

You can now define PXE clients that Cobbler can provision based on a profile that you have created. See Section 4.6.1, “Adding a PXE Client to be Provisioned by Cobbler”.