This is an old revision of the document!
Spacecmd
General Information
Spacewalk provides centralized management of Red Hat systems. (https://fedorahosted.org/spacewalk/)
Spacecmd is the command line interface to the server and is much faster than logging into the web portal.
Checklist
- Spacewalk server setup
- Spacewalk user account created
Install Spacecmd
- Add spacewalk client repo
- CentOS 6
rpm -Uvh http://yum.spacewalkproject.org/2.4-client/RHEL/6/x86_64/spacewalk-client-repo-2.4-3.el6.noarch.rpm
- CentOS 7
rpm -Uvh http://yum.spacewalkproject.org/2.4-client/RHEL/7/x86_64/spacewalk-client-repo-2.4-3.el7.noarch.rpm
- Install spacecmd
yum 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
[spacecmd] server=spacewalkserver.mydomain.com username=usernamehere password=passwordhere
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 -q group_list
List systems in a group
spacecmd -q group_listsystems <GROUP>
Add systems to a group (SYSTEMS space separated)
spacecmd -q group_addsystems <GROUP> <SYSTEMS>
Remove systems from a group (SYSTEMS space separated)
spacecmd -q group_removesystems <GROUP> <SYSTEMS>
System Commands
List all systems (good for piping to grep)
spacecmd -q system_list
Delete system(s) from Spacewalk (SYSTEMS space separated)
spacecmd -q system_delete <SYSTEMS>
List a System's Base Channel
spacecmd -q system_listbasechannel <SYSTEM>
List a System's Child Channels
spacecmd -q system_listchildchannels <SYSTEM>
Set an entire group's base channel
spacecmd -qy system_setbasechannel group:<GROUP-NAME> <BASE-CHANNEL-NAME>
List systems in a group and all errata except kernel:
spacecmd -q system_listerrata group:<GROUP-NAME> | grep -vi "kernel"
Errata install command:
spacecmd -qy system_applyerrata group:<GROUP-NAME> <ERRATA-NAME>
List installed packages, grep for glibc:
spacecmd -q system_listinstalledpackages <SYSTEM> | grep glibc
Report Commands
Systems Not in Any Group
spacecmd -q report_ungroupedsystems
Systems Not Checking In and Last Checkin Time
spacecmd -q report_inactivesystems