Satellite 6: How to enable and synchronize repositories via command line?

Solution Verified - Updated

Environment

  • Red Hat Satellite 6

Issue

  • I would like to know how to enable repos via command line in Satellite 6
  • how to synchronize repositories via command line

Resolution

Enable Repositories on Satellite 6

1.- Connect to you server viadoc ssh

# ssh root@satellite.example.com

2.- Execute the hammer shell

#hammer  shell --username <username of satellite admin account> --password  <password> 

3.- Obtain List of Organizations

hammer> organization list  
IDNAMELABELDESCRIPTION
1Default_OrganizationDefault_OrganizationDefault_Organization Organization

4.- Get product list

hammer> product list --organization-label Default_Organization
IDNAMEDESCRIPTIONORGANIZATIONREPOSITORIESSYNC STATE
2Red Hat Software Collections for RHEL ServerDefault_Organization0not_synced
8Red Hat Enterprise Linux Load Balancer for RHEL ServerDefault_Organization0not_synced
12Red Hat Enterprise Linux WorkstationDefault_Organization0not_synced
5Red Hat Enterprise Linux ServerDefault_Organization0not_synced

5.- Get repositories on the Product with the id

hammer> repository-set list --organization-label Default_Organization --product "Red Hat Enterprise Linux Server"
IDTYPENAME
2024yumRed Hat Enterprise Linux 4 ES (Source RPMs)
861fileRed Hat Enterprise Linux 5 Server Beta (Source ISOs)
3535yumRed Hat Enterprise Linux 5 Server Beta - Optional Productivity Applications (Debug RPMs)
3025fileRed Hat Enterprise Linux 6 Server - Extras (Images)
168yumRed Hat Enterprise Linux 6 Server (RPMs)

6.- If you want to see the child contents of the main repo

hammer > repository-set available-repositories --organization-label Default_Organization --product "Red Hat Enterprise Linux Server" --id 168
NAMEARCHRELEASEENABLED
Red Hat Enterprise Linux 6 Server RPMs i386 6.1i3866.1no
Red Hat Enterprise Linux 6 Server RPMs x86_64 6.1x86_646.1no
Red Hat Enterprise Linux 6 Server RPMs i386 6.2i3866.2no
Red Hat Enterprise Linux 6 Server RPMs x86_64 6.2x86_646.2no
Red Hat Enterprise Linux 6 Server RPMs i386 6.3i3866.3no
Red Hat Enterprise Linux 6 Server RPMs x86_64 6.3x86_646.3no
Red Hat Enterprise Linux 6 Server RPMs i386 6.4i3866.4no
Red Hat Enterprise Linux 6 Server RPMs x86_64 6.4x86_646.4no
Red Hat Enterprise Linux 6 Server RPMs i386 6.5i3866.5no
Red Hat Enterprise Linux 6 Server RPMs x86_64 6.5x86_646.5no
Red Hat Enterprise Linux 6 Server RPMs i386 6.6i3866.6no
Red Hat Enterprise Linux 6 Server RPMs x86_64 6.6x86_646.6no
Red Hat Enterprise Linux 6 Server RPMs i386 6Serveri3866Serverno
Red Hat Enterprise Linux 6 Server RPMs x86_64 6Serverx86_646Serveryes

6.- Enable Repository

For enable the base repo
repository-set enable --organization-label Default_Organization --product "Red Hat Enterprise Linux Server" --id 168 --releasever 6Server --basearch x86_64

For enable any child repo 
repository-set enable --organization-label Default_Organization --product "Red Hat Enterprise Linux Server" --id 168 --releasever 6.3 --basearch x86_64

Where:
id = is the repo that you want to add to Satellite 6
product = is the product where the repo is locate you can get that on point #3 (product-id can be used as well)
organization-label = is the organization name/label that we going to add the repo (organization-id can be used as well)
releasever = is the release product you want to obtain
basearch = is the architecture desire of the product (usually x86_64 or i386)

Synchronize repos

1.- Obtain List of Organizations

hammer> organization list  
IDNAMELABELDESCRIPTION
1Default_OrganizationDefault_OrganizationDefault_Organization Organization

2.- Get product list

hammer> product list --organization-label Default_Organization
IDNAMEDESCRIPTIONORGANIZATIONREPOSITORIESSYNC STATE
2Red Hat Software Collections for RHEL ServerDefault_Organization0not_synced
8Red Hat Enterprise Linux Load Balancer for RHEL ServerDefault_Organization0not_synced
12Red Hat Enterprise Linux WorkstationDefault_Organization0not_synced
5Red Hat Enterprise Linux ServerDefault_Organization0not_synced

3.- Get the repolist

hammer> repository list --organization-label Default_Organization
IDNAMEPRODUCTCONTENT TYPEURL
4Puppet MasterPuppet Modulespuppet
1Red Hat Enterprise Linux 6 ServerRed Hat Enterprise Linux Serveryumhttps://cdn.redhat.com/content/dist/rhel/server/6/6Server/x86_64/

4.- Execute hammer command to start the synchonization of the repo

hammer> repository synchronize --async --organization-label Default_Organization --product "Red Hat Enterprise Linux Server" --id 1

Where:
id =The repository you want to sync.
organization-label = The label of the organization that you want to sync the repo (organization-id can be used as well).
product = The product channel where the repo is going to be sync (product-id can be used as well).

For more KB articles/solutions related to Red Hat Satellite 6.x Repository Issues, please refer to the Red Hat Satellite Consolidated Troubleshooting Article for Red Hat Satellite 6.x Repository Issues.

SBR
Product(s)
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.