Deploy/SpaceWalk/Howto
Create a distribution
For automating the installation of a Linux system a method called kickstart can be used. First, we have to setup a directory structure on the spacewalk server based on content of the CentOS dvd1 iso. From your CentOS 6.1 dvd1, copy the following directories:
- images
- isolinux
- repodata
to <path>/var/distro-trees/centos6.1-x86_64</path>
Next, open the spacewalk console and navigate to the following location:
systems -> kickstart -> distributions -> new distribution
Enter the following parameters for the new distribution:
- Distribution label: centos6.1-x86_64
- tree path: /var/distro-trees/centos6.1-x86_64
- Base Channel: CentOS 6.1 – 64 Bit
- Installer Generation: Red Hat Enterprise Linux 6
Next step is to create a kickstart profile for the channel and distribution. Open the spacewalk console and navigate to the following location:
systems -> kickstart -> create new kickstart profile
Enter the following parameters for the new kickstart profile:
- Label: centos61-minimal
- Base channel: CentOS 6.1 – 64 Bit
- Kickstartable tree: centos6.1-x86_64
- Virtualization type: none
To make sure the spacewalk client repository is used during kickstart, navigate to the following location:
systems -> kickstart -> profiles -> centos61-minimal -> operating system
Make sure the child channel swclnt1.5-el6-x86_64 is checked.
Also, have a look at the other tabs to have an idea of the configuration options which are available. Possible interesting area’s are:
- Software: Adding extra packages or package groups in addition to the base installation. Add the package just by adding it on a new line, package groups can be added by an @-sign followed by the group name. A package can be excluded by an hyphen (-) followed by the package name
- Kickstart details -> Details -> Kernel options: Adding and removing kernel options. You can add a kernel option, just by adding it’s key/value pair to the input field. Removal is done by just mentioning the kernel option preceded by an ! and giving it ~ as a value. For example, the value "!text=~ resolution=800×600″ in the kernel option box forces the use of the graphical installer (remove the text kernel option) and sets screen resolution to 800×600.
- Kickstart details -> Advanced options: Allows detailed configuration of the kickstarted system. For example, to add an user,during installation, named weblogic with password weblogic01, tick the "user" checkbox and add the value "–name=weblogic –password=weblogic01 –plaintext" to the input field.
- Kickstart details -> Variables: the usage of variables can be done by adding a key/value pair and refer to it in another tab. For example (might be a bad example but it is just to demonstrate the usage), to define the hostname during kickstart, add a key/value pair (hostname=appsrvr1) in the variables tab and refer to it in the Advanced options by adding "–hostname $hostname" to the network text box.
Let’s cobbler
Next step is to create an iso image to boot a new vm from. Important note: In the next couple of steps we are going to deploy a new linux virtual machine. If your virtualization network setup supports a dns where the spacewalk server can be found by it’s hostname you can skip the next step. In other words, your newly created vm must be able to find the spacewalk server using it’s hostname during boot/initial setup. If this is not the case or if you are unsure, please perform the following step to change the spacewalk hostname to it’s ip-address, if you are sure dns is in place you can skip this step:
- In /etc/rhn/rhn.conf change the value of the parameter cobbler.host to the ip address of the spacewalk server.
- In /etc/cobbler/settings change the value of the parameters server and redhat_management_server to the ip-address of the spacewalk server.
On the spacewalk server, run the command (this only needs to be done once):
cobbler get-loaders
Next, start building the iso using the command:
cobbler buildiso
The result of the buildiso command is a file named generated.iso in the directory from where you issued the command.
Let’s kickstart
On your host, create a new virtual machine and provide it with the generated.iso file to boot from. Upon boot you will see a menu allowing you to specify the centos61-minimal setup to be installed.
Select this entry and the setup will install a base 64 bit CentOS 6.1 Linux system. If all goes well, this will happen completely automated, without any user intervention whatsoever. If, during install, you receive messages like "Error downloading kickstart file", this probably means you have to look into dns issues as described earlier in the article.
Verify that the system registered itself in spacewalk, it should appear in the system tab on the main screen of the spacewalk web console. Configuring the client
Now that we have installed a fresh 64 bit CentOS 6.1 Linux vm we have to configure it as a client for spacewalk. Open an ssh session to the newly deployed CentOS 6.1 vm and install the packages rhncfg-client and rhn-check using yum.
yum install -y --nogpgcheck rhncfg-client rhn-check
Managing the configuration of this newly created vm can be done in the following two ways:
- Deploy new packages to the client
- Deploy (configuration) files to the client
Deploy new packages to the client
To install a new package from the repository to the new server, go to the spacewalk web console and navigate to the following location:
system -> "your system" -> Software -> Packages -> Install
Select the required package from the repository (for example xauth) and click on "Install Selected Packages"
Next, select "Schedule action as soon as possible" at the confirmation screen and click on "Confirm"
Now, log on to the client and verify the software channels it is subscribed to by executing:
rhn-channel --list
Check if the channel where you made the pending change is in the list. Next, verify if the selected package is not installed yet by executing, on the client:
# rpm -qa | grep -i xauth
If the package is not installed yet, apply the pending change (installation of the package) by executing:
rhn_check
The server will check for any pending actions (in this case installing the selected package) and execute (install the package) them. Now, check again to verify that the (xauth) package was installed by executing:
# rpm -qa | grep -i xauth
xorg-x11-xauth-1.0.2-7.1.el6.x86_64
Deploy (configuration) files to the client
In case of managing the configuration files of a linux system through spacewalk, this can be done through configuration channels.
First of all, create a new configuration channel. Open the spacewalk web console and navigate to the following location:
Configuration -> Configuration channels -> create new config channel
Enter information to identify the config channel:
Name: My Config Channel Label: myConfigChannel Description: My Config Channel
Next step is to populate this channel with files and directories by navigating to the following location:
Select the configuration channel -> add files -> create file
Now you can create files, directories and symlinks, set ownerships and file permissions. In case of creating a file it is possible to add the actual content of the file in the inline editor. Click on "Create Configuration File" to finalize this action.
To deploy this file to the managed linux system, this system must first be subscribed to the config channel. In the spacewalk web console, navigate to the following location:
systems -> "your system" -> configuration -> manage configuration channels -> subscribe to channels
Next, verify if the client is successfully subscribed to the newly created config channel by executing the following command on the client:
# rhncfg-client channels
Using server name spacewalk Config channels: Label Name
----
myConfigChannel My Config Channel
If the channel appears in the output of the previous command you can get those files (or directories) by issuing:
# rhncfg-client get
Using server name spacewalk Deploying /opt/oracle Deploying /opt/oracle/middleware Deploying /opt/oracle/middleware/jrockit
If you want to verify if there is a delta between your system and the config channel you can do so by executing
rhncfg-client diff
Conclusion
As usual with this kind of systems, it takes a lot of effort upfront to set it all up. With this article i hope i will help the reader by setting up a spacewalk system relatively easy and fast. Hopefully, the reader will realize pretty soon that managing Linux systems now really is a breeze and all effort for setting it up was worth it. In my opinion, as of version 1.5, which is current at the time of writing this article, stability and functionality has increased a lot since I started working with Spacewalk. If you’re looking for a way to manage your Red Hat derived Linux systems, i highly recommend taking a look at Spacewalk.
