Spacewalk – Bootstrap Script

Spacewalk is a tool for managing linux-servers. Its a very powerful tool which will make your life easyer especally if you have to manage large amounts of servers.

Spacewalk has two ways to add systems to the manager.

The first way is that you install a fresh server and add him to the system. You can add the nescessary steps in the post-install-script.

The second way is to add existing servers to the system. And this is the use case that i have mostly.

So, lets have a look at the nescessary steps we need:

  • Import the SSL-Key of the spacewalk-server
  • Import GPG-keys of non-official repositorys
  • Install the rhn-setup package which provides the binary that makes the regisitration to the spacewalk-server
  • registration to the spacewalk-server
  • Install spacewalk-related packages (for use of remote-commands, executing tasks, controlling package-manager…)
  • disable local repositorys
  • enable remote-commands
  • enable and start osad (task-engine)

I added this to a script and im providing it via the spacewalk-server. Clients can download it from the web interface.

So here is my little script:

cat bootstrap.sh
#!/bin/bash

#import ssl cert from spacewalk

rpm -Uvh http://spacewalk-url/pub/rhn-org-trusted-ssl-cert-1.0-1.noarch.rpm

#import gpg key for spacewalk-client-repo

rpm --import http://spacewalk-url/pub/gpg/RPM-GPG-KEY-spacewalk-2.9-client

#import gpg key for epel repo

rpm --import http://spacewalk-url/pub/gpg/RPM-GPG-KEY-EPEL-7

#install nescessary packages

yum -y install rhn-setup

#register client on spacewalk-server

rhnreg_ks --serverUrl=https://spacewalk-url/XMLRPC --sslCACert=/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT --activationkey=1-activationkey

#install spacewalk related packages

yum -y install osad rhncfg-actions rhncfg rhncfg-client yum-rhn-plugin fping screen perl-Frontier-RPC perl-Text-Unidecode

#disable centos original repos

sed -i '/\[base\]/ a enabled=0' /etc/yum.repos.d/CentOS-Base.repo
sed -i '/\[updates\]/ a enabled=0' /etc/yum.repos.d/CentOS-Base.repo
sed -i '/\[extras\]/ a enabled=0' /etc/yum.repos.d/CentOS-Base.repo
sed -i 's/enabled=1/enabled=0/' /etc/yum.repos.d/epel.repo

#activate remote commands and osa-service

rhn-actions-control --enable-all

systemctl enable osad

systemctl start osad

Spacewalk – Automatic Creation of a Kickstartable Tree

Spacewalk is a tool for (mainly) managing and provisioning server or client linux-systems.

I’m using for a few months now and yeah. Its not well documented, especially the provisioning part.

Spacewalk uses kickstart as provisioning tool.

You have to add a kickstartable tree. Then make your kickstart distribution and then finally your kickstart profile where you define the properties for your system.

The problem is the kickstartable tree. The documentation says, simple mount a distribution dvd and then use the path where the distro is mounted.

Uhm… no. wont work for CentOS 🙂

I found a script on the net wich dowloads all the distribution files that you need. its name is mkelfs.

The github entry was updated in Nov 2015 but it still works.

Just download it from here: https://github.com/stdevel/mkelfs/blob/master/mkelfs.py

Before you can use the command you have to create the folders in which the script deploys the distro data.

mkdir /var/satellite/kickstart_tree

Here is the command you need for CentOS 7 (dont be suprised, the reason why Centos is not in the parameters is that its a default value 😀 )

./mkelfs.py --release 7 --arch x86_64 -b centos7-x86_64

-b is the name of your base channel