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

Leave a Reply

Your email address will not be published.