Satellite 6: How to enable and synchronize repositories via command line?
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
| ID | NAME | LABEL | DESCRIPTION |
|---|---|---|---|
| 1 | Default_Organization | Default_Organization | Default_Organization Organization |
4.- Get product list
hammer> product list --organization-label Default_Organization
| ID | NAME | DESCRIPTION | ORGANIZATION | REPOSITORIES | SYNC STATE |
|---|---|---|---|---|---|
| 2 | Red Hat Software Collections for RHEL Server | Default_Organization | 0 | not_synced | |
| 8 | Red Hat Enterprise Linux Load Balancer for RHEL Server | Default_Organization | 0 | not_synced | |
| 12 | Red Hat Enterprise Linux Workstation | Default_Organization | 0 | not_synced | |
| 5 | Red Hat Enterprise Linux Server | Default_Organization | 0 | not_synced |
5.- Get repositories on the Product with the id
hammer> repository-set list --organization-label Default_Organization --product "Red Hat Enterprise Linux Server"
| ID | TYPE | NAME |
|---|---|---|
| 2024 | yum | Red Hat Enterprise Linux 4 ES (Source RPMs) |
| 861 | file | Red Hat Enterprise Linux 5 Server Beta (Source ISOs) |
| 3535 | yum | Red Hat Enterprise Linux 5 Server Beta - Optional Productivity Applications (Debug RPMs) |
| 3025 | file | Red Hat Enterprise Linux 6 Server - Extras (Images) |
| 168 | yum | Red 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
| NAME | ARCH | RELEASE | ENABLED |
|---|---|---|---|
| Red Hat Enterprise Linux 6 Server RPMs i386 6.1 | i386 | 6.1 | no |
| Red Hat Enterprise Linux 6 Server RPMs x86_64 6.1 | x86_64 | 6.1 | no |
| Red Hat Enterprise Linux 6 Server RPMs i386 6.2 | i386 | 6.2 | no |
| Red Hat Enterprise Linux 6 Server RPMs x86_64 6.2 | x86_64 | 6.2 | no |
| Red Hat Enterprise Linux 6 Server RPMs i386 6.3 | i386 | 6.3 | no |
| Red Hat Enterprise Linux 6 Server RPMs x86_64 6.3 | x86_64 | 6.3 | no |
| Red Hat Enterprise Linux 6 Server RPMs i386 6.4 | i386 | 6.4 | no |
| Red Hat Enterprise Linux 6 Server RPMs x86_64 6.4 | x86_64 | 6.4 | no |
| Red Hat Enterprise Linux 6 Server RPMs i386 6.5 | i386 | 6.5 | no |
| Red Hat Enterprise Linux 6 Server RPMs x86_64 6.5 | x86_64 | 6.5 | no |
| Red Hat Enterprise Linux 6 Server RPMs i386 6.6 | i386 | 6.6 | no |
| Red Hat Enterprise Linux 6 Server RPMs x86_64 6.6 | x86_64 | 6.6 | no |
| Red Hat Enterprise Linux 6 Server RPMs i386 6Server | i386 | 6Server | no |
| Red Hat Enterprise Linux 6 Server RPMs x86_64 6Server | x86_64 | 6Server | yes |
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
| ID | NAME | LABEL | DESCRIPTION |
|---|---|---|---|
| 1 | Default_Organization | Default_Organization | Default_Organization Organization |
2.- Get product list
hammer> product list --organization-label Default_Organization
| ID | NAME | DESCRIPTION | ORGANIZATION | REPOSITORIES | SYNC STATE |
|---|---|---|---|---|---|
| 2 | Red Hat Software Collections for RHEL Server | Default_Organization | 0 | not_synced | |
| 8 | Red Hat Enterprise Linux Load Balancer for RHEL Server | Default_Organization | 0 | not_synced | |
| 12 | Red Hat Enterprise Linux Workstation | Default_Organization | 0 | not_synced | |
| 5 | Red Hat Enterprise Linux Server | Default_Organization | 0 | not_synced |
3.- Get the repolist
hammer> repository list --organization-label Default_Organization
| ID | NAME | PRODUCT | CONTENT TYPE | URL |
|---|---|---|---|---|
| 4 | Puppet Master | Puppet Modules | puppet | |
| 1 | Red Hat Enterprise Linux 6 Server | Red Hat Enterprise Linux Server | yum | https://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.
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.