Setup Spacewalk on CentOS 7 Monday, November 16, 2020 13:51 Pre-Requisites Setup Repositories yum install ­y yum­plugin­tmprepo yum install ­y spacewalk­repo ­­tmprepo=https://copr­be.cloud.fedoraproject.org/results/%40spacewalkproject/spacewalk­2.9/epel­7­x86_ 64/repodata/repomd.xml ­­nogpg rpm ­Uvh https://dl.fedoraproject.org/pub/epel/epel­release­latest­7.noarch.rpm Additionally, in RHEL 7, subscribe the system to Optional Channels. subscription­manager repos ­­enable rhel­7­server­optional­rpms Hostname vi /etc/hosts Modify it according to your environment. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 # Your Spacewalk Server 192.168.1.10 server.itzgeek.local server Firewall firewall­cmd ­­permanent ­­add­service=http firewall­cmd ­­permanent ­­add­service=https Add port 5222 if you want to push actions to client machines and 5269 for push actions to a Spacewalk Proxy, 69 udp if you want to use tftp. firewall­cmd ­­permanent ­­add­port=5222/tcp ­­add­port=5269/tcp ­­add­port=69/udp firewall­cmd ­­reload SpaceWalk Database yum ­y install spacewalk­setup­postgresql Install SpaceWalk yum install ­y spacewalk­postgresql Configure SpaceWalk spacewalk­setup Once the installation is complete, check the status of Spacewalk service. /usr/sbin/spacewalk­service status Access Spacewalk https://ip­add­ress OR https://your­domain­name Spacewalk Channels Channel is nothing but a collection of software (RPM) packages. A channel may contain packages from a specific distribution or contains packages for an application or family of applications. Users may also define channels. Any client can subscribe to a particular channel to download, update, install packages. The channels are linked to upstream server (a normal YUM/DEB repository). A channel may have linked to multiple repositories, can be cloned, sync or customized. There are two types of channels: Base channels Child channels A base channel consists of packages based on a specific architecture and Red Hat Enterprise Linux release. A child channel is a channel associated with a base channel that contains extra packages. A system must be subscribed to only one base channel but it can be subscribed to multiple child channels of its base channel. A subscribed system can only install or update packages available through its Satellite channels. Create a Base Channel Access the Spacewalk web console using the username and password that you defined in the previous tutorial. https://spacewalk­server­ip Goto Channels >> Manage Software Channels >> Create Channel. This is where you create a channel for your machine. My base channel looks like this. Channel Name: itzgeek_centos7 Channel Label: itzgeek_centos7 Parent Channel: None (Because this is a Base Channel) Architecture: x86_64 Channel Summary: ITzGeek CentOS 7 Base Channel Leave the remaining as it is. Likewise, you can create a channel for different versions of CentOS / RHEL machines and architectures. You need to be very careful while choosing an architecture for the channel as the machine with the same architecture can only able to subscribe to this channel. Create a repository for Base Channel Goto Channels >> Manage Software Channels >> Manage Repositories >> Create repository. Here you should mention the upstream server from where Spacewalk server will download packages for clients. Repository Details: Repository Name: CentOS 7 x86_64 Repository URL: http://mirror.rackspace.com/CentOS/7/os/x86_64/ Repository Type: yum For a demo, I used http://mirror.rackspace.com/CentOS/7/os/x86_64/ as Repository URL. This repository URL is one of the CentOS mirrors. You can find more mirrors here. Attaching a repository to Base channel Goto Channels >> Manage Software Channels >> Select the created channel (itzgeek_centos7) >> Repository >> Select the previously created repository (CentOS 7 x86_64) >> Update Repositories. Now its time to sync packages from the upstream server. Go to Channels >> Manage Software Channels >> Select the created channel >> Repository >> Sync >> Sync Now. OR Run below command to sync with the upstream server. # /usr/bin/spacewalk­repo­sync ­­channel itzgeek_centos7 ­­type yum Note: The packages will be downloaded from the upstream server will be kept in /var/satellite/ folder of your Spacewalk server. Make sure you have enough space in /var/satellite/ folder. You can go through sync logs to troubleshoot any issues arise during the synchronization. # cat /var/log/rhn/reposync/<reponame>.log Once the package synchronization is complete, you can view packages by going to Channels >> Manage Software Channels >> Select your channel >> Packages >> List / Remove. Create a Child Channel Goto Channels >> Manage Software Channels >> Create New Channel. Enter the Child channel name, label, Parent channel, Architecture, and Channel description, etc. Here you must select the Parent channel from the drop­down list. Finally, click Create Channel button. Channel Details: Channel Name: nginx_centos7 Channel Label: nginx_centos7 Parent Channel: itzgeek_centos7 (Because this is a child channel) Architecture: x86_64 Channel Summary: Nginx CentOS 7 – Child Channel Leave the remaining as it is. Create a Repository for Child Channel Goto Channels >> Manage Software Channels >> Manage Repositories >> Create repository. Let us create a Nginx repository, Enter the repository name and actual URL. Repository Details: Repository Name: Nginx CentOS 7 Repository URL: http://nginx.org/packages/centos/7/x86_64 Repository Type: yum Likewise, you can create your own repository. Assigning a repository to Child channel Goto Channels >> Manage Software Channels >> Select the child channel. Goto Repository (TAB) >> Select the created repository (Nginx) >> Update repository. In the same page, goto Sync (TAB) >> Sync Now or Select a schedule. OR Run the below command. /usr/bin/spacewalk­repo­sync ­­channel nginx_centos7 ­­type yum Create an Activation Key Here you can create activation keys for client subscription. In this page, you need to select the base channel ( itzgeek_centos7). Whenever any client uses this key, the client machine will be automatically subscribed to the created channel. You can create multiple keys in case you would like to assign multiple channels to a client machine. Goto Systems >> Activation Keys >> Create New Key. Better to leave the key blank for automatic generation. You can get a list of activation keys by going to Systems >> Activation Keys. At this stage, your Spacewalk server is almost ready to serve packages to clients. That’s all. In our next tutorial, we will configure a client to use Spacewalk server for getting packages and updates. Install Spacewalk client Though the base repository has packages that are required for registering clients with Spacewalk server, we will configure Spacewalk client repo on the client machine to get the latest packages. rpm ­Uvh http://yum.spacewalkproject.org/2.7­client/RHEL/7/x86_64/spacewalk­client­repo­2.7­2.el7.noarch.rpm rpm ­Uvh http://dl.fedoraproject.org/pub/epel/epel­release­latest­7.noarch.rpm Install below packages. yum ­y install rhn­client­tools rhn­check rhn­setup rhnsd m2crypto yum­rhn­plugin Install SpaceWalk’s certificate on your client machine to enable secure communication. Replace the Spacewalk server name and RPM version if required. rpm ­Uvh http://server.itzgeek.local/pub/rhn­org­trusted­ssl­cert­1.0­1.noarch.rpm Make sure the client machine can connect to the Spacewalk server with hostname. Use /etc/hosts file or DNS server for resolving the hostname. Register clients with SpaceWalk Server It is recommended to use activation keys for registering and configuring client systems with Spacewalk server. Login to Spacewalk server and get an activation that we created in the previous tutorial. Goto System >> Activation Keys. On client system’s Terminal, run the following command to register it to the Spacewalk server. rhnreg_ks ­­activationkey 1­b908cd891e78c7b90cc6000ee63c0ec5 ­­serverUrl https://server.itzgeek.local/XMLRPC Once the above command is executed, goto Spacewalk console, and click on Systems. You will see our client system that we just registered with Spacewalk. Click on client name. You will be taken to client summary page where you can see detailed information about the registered client (client.itzgeek.local). You can see that the client machine has been automatically subscribed to the base channel (itzgeek_centos7). Modifying a client subscription (Optional) If you want to make use of child channels (Ex. To install Nginx), enable the child channel (Nginx) of the base channel to get Nginx packages. GUI Mode Go to Systems >> <Your Client> >> Software >> Software Channels >> Software Channel Subscriptions. OR Click on Alter Subscription Channels on the client overview page. Select the Child channels (Ex. nginx_centos7) and click Change Subscriptions. Now, the client system is successfully subscribed to Nginx child channel. Install Packages using Spacewalk Server Now, you can start to install or update packages from the Spacewalk server. Disable non­Spacewalk repositories to avoid packages being downloaded from internet. To do that, run: sed ­i 's/enabled=1/enabled=0/g' /etc/yum.repos.d/* To test, install Nginx package on the client machine. yum install nginx