Table of Contents

Spacecmd

General Information

Spacewalk provides centralized management of Red Hat systems.

Spacecmd is the command line interface to the server and is much faster than logging into the web portal.

Checklist


Install Spacecmd


Spacecmd Config File

Setting up the spacecmd config file greatly shortens the command, as you do not have to specify server, username, and password each time.

Create the file ~/.spacecmd/config

mkdir ~/.spacecmd
chmod 700 ~/.spacecmd
touch ~/.spacecmd/config
chmod 600 ~/.spacecmd/config

Edit the file

vim ~/.spacecmd/config
 
[spacecmd]
server=spacewalkserver.mydomain.com
username=usernamehere
password=passwordhere

Verify configuration by testing connectivity

spacecmd

Useful Alias

It is also useful to create the following alias in your ~/.bashrc file

alias spacecmd='spacecmd -q'

This will always execute spacecmd with the quiet option. This will not show logging into the server info, which just gets in the way if you are trying to pipe output to other commands.


Clear Caches

Spacecmd creates a local cache of system queries to improve performance. This can leave you with outdated information when working at the CLI in some situations.

To clear the local cache

spacecmd clear_caches

Group Commands

List system groups

spacecmd group_list

List systems in a group

spacecmd group_listsystems <GROUP>

Add systems to a group (SYSTEMS space separated)

spacecmd group_addsystems <GROUP> <SYSTEMS>

Remove systems from a group (SYSTEMS space separated)

spacecmd group_removesystems <GROUP> <SYSTEMS>

System Commands

List all systems (good for piping to grep)

spacecmd system_list

Delete system(s) from Spacewalk (SYSTEMS space separated)

spacecmd system_delete <SYSTEMS>

List a System's Base Channel

spacecmd system_listbasechannel <SYSTEM>

List a System's Child Channels

spacecmd system_listchildchannels <SYSTEM>

Set an entire group's base channel

spacecmd -y system_setbasechannel group:<GROUP-NAME> <BASE-CHANNEL-NAME>

List systems in a group and all errata except kernel:

spacecmd system_listerrata group:<GROUP-NAME> | grep -vi "kernel"

Errata install command:

spacecmd -y system_applyerrata group:<GROUP-NAME> <ERRATA-NAME>

List installed packages, grep for glibc:

spacecmd system_listinstalledpackages <SYSTEM>  | grep glibc

Report Commands

Systems Not in Any Group

spacecmd report_ungroupedsystems

Systems Not Checking In and Last Checkin Time

spacecmd report_inactivesystems