Home > System Administration > Quick Script to join content hosts to Satellite 6

Quick Script to join content hosts to Satellite 6

I wrote this for $DAYJOB to move machines registered with RHN or CentOS machines not registered to anything over to our Satellite 6 server.

I presume you have created activation keys titled organization-${DISTRO}${MAJ_REL}-development for all combinations of DISTRO (rhel, centos) and MAJ_REL (6, 7).

#!/bin/sh
 
# Prepare to register with Satellite
# Make sure lsb_release is installed  
rpm -q redhat-lsb-core 2>&1 >/dev/null
if [ $? -ne 0 ]; then
  yum -y install redhat-lsb-core
fi
 
# Which version are we running
RELEASE=`lsb_release -r -s`
MAJ_REL=${RELEASE:0:1}
 
# Are we on CentOS or RHEL?
if [ -f /etc/centos-release ]; then
  DISTRO="centos"
 
  # Get the copr release of RHSM for CentOS
  if [ ! -f /etc/yum.repos.d/dgoodwin-subscription-manager.repo ]; then
    wget -O /etc/yum.repos.d/dgoodwin-subscription-manager.repo http://copr-fe.cloud.fedoraproject.org/coprs/dgoodwin/subscription-manager/repo/epel-${MAJ_REL}/dgoodwin-subscription-manager-epel-${MAJ_REL}.repo
  fi
else
  DISTRO="rhel"
fi
 
# Install the certificates - will pull in subscription-manager
yum -y install http://satellite.example.com/pub/katello-ca-consumer-latest.noarch.rpm
 
# Install additional useful packages
yum -y install katello-agent
/sbin/service goferd start
 
# Register with Satellite
subscription-manager register --org="Example" --activationkey="example-${DISTRO}${MAJ_REL}-development"