Search

Chapter 2. Managing Organizations, Locations, and Repositories

download PDF

You can use hammer to create, edit, and manage organizations, locations, and repositories. For web UI equivalents of the following procedures see Managing Organizations and Importing Red Hat Content in the Content Management Guide.

2.1. Organizations

Organization in Red Hat Satellite is an isolated collection of systems, content, and other functionality within a Satellite deployment. This section shows how to create and modify organizations using hammer.

2.1.1. Creating an Organization

Use the following command to create an organization:

$ hammer organization create \
--name "org_name" \
--label "org_label" \
--description "org_description"

Where:

  • org_name is the name of the organization. This parameter is required.
  • org_label is the organization label used in command-line applications such as subscription-manager. Labels cannot contain white space and you cannot change them later. If not specified, label is generated automatically from the organization name (white space is replaced with underscores).
  • org_description is a short description of the organization. This parameter is not required, but it can help you to manage a large number of organizations.

You can fully configure an organization while creating it (issue hammer organization create --help to see the options). Also, you can modify an existing organization using the hammer organization update command.

Example 2.1. Creating and Updating ACME Organization

The following example shows how to create an organization named ACME:

$ ORG="ACME"
$ hammer organization create \
--name $ORG \
--description "Example_organization"

This command assigns a compute resource to the organization:

$ hammer organization update \
--name $ORG \
--compute-resource-ids 1

2.1.2. Identifying an Organization in a Hammer Command

Many tasks you can perform in the Satellite Server are specific to an organization. Hammer commands provide three ways to identify an organization: by using the organization, organization-label, or organization-id option. To find the organization ID, use the following command:

$ hammer organization list

If your organization name is long, consider storing it in a shell variable. You can use this variable in Hammer commands. For example:

$ ORG = "Red Hat Enterprise Linux Developer Team"
$ hammer product list --organization $ORG

This approach is used in examples in this guide.

If you mostly manage a single organization, you can set it as default. For information on how to do that, see Section 1.4, “Setting a Default Organization”.

2.1.3. Uploading a Manifest

A Subscription Manifest transfers subscriptions from the Red Hat Customer Portal to Satellite Server. First, generate the manifest on the Red Hat Customer portal as described in the Creating a Subscription Manifest in the Content Management Guide. Then upload the manifest to the organization as follows:

$ hammer subscription upload \
--organization-label org_label \
--file path_to_manifest

Example 2.2. Uploading a Manifest to ACME Organization

The following example shows how to upload a Subscription Manifest file to the ACME organization (assuming the organization name is stored in a shell variable):

$ hammer subscription upload --organization $ORG --file /tmp/manifest.zip

To view the subscriptions imported with the manifest, issue:

$ hammer subscription list --organization $ORG

2.2. Locations

Location in Red Hat Satellite is collection of default settings that represent a physical place. This section shows how to create locations using hammer.

2.2.1. Creating a Location

Use the following command to create a location:

$ hammer location create --name location_name

Example 2.3. Creating Multiple Locations Using a Script

The following Bash script creates three locations (london, munich, boston), and assigns them to the ACME organization.

ORG="ACME"
LOCATIONS="london munich boston"

for LOC in ${LOCATIONS}
do
  hammer location create --name "${LOC}"
  hammer location add-organization --name "${LOC}" --organization "${ORG}"
done

Run hammer location --help to view all possible location related operations.

2.3. Repositories

Repository provides storage for a collection of content. This section shows how to enable and synchronize repositories using hammer.

2.3.1. Enabling a Repository

Before enabling a Red Hat repository, you need to know its name, the name of the product it provides, the base architecture, and the release version. Use the following command to enable a repository:

$ hammer repository-set enable \
--organization-label org_label \
--product "product_name" \
--basearch "base_architecture" \
--releasever "release_version" \
--name "repository_name"

Example 2.4. Enabling a Red Hat Enterprise Linux Repository

The following command enables the Red Hat Enterprise Linux 7 Server repository for the organization:

$ hammer repository-set enable \
--organization $ORG \
--product "Red Hat Enterprise Linux Server" \
--basearch "x86_64" \
--releasever "7Server" \
--name "Red Hat Enterprise Linux 7 Server (RPMs)"

Run hammer repository-set --help to view all possible repository related operations. Also see hammer repository --help.

2.3.2. Synchronizing a Repository

By synchronizing a repository you pull its content from Red Hat Customer Portal to the Satellite Server. To synchronize a repository you need to specify its name and a product name:

$ hammer repository synchronize \
--product "product_name" \
--name "repo_name" \
--organization-label org_label \
--async

Note that if you have created Content Views, multiple repositories with the same name can exist within a single organization. In such a case, use the --id option to identify the repository you want to synchronize (issue hammer repository list to find repository IDs).

Example 2.5. Synchronizing a Red Hat Enterprise Linux Repository

The following command performs a single synchronization of the Red Hat Enterprise Linux 7 Server repository in the organization:

$ hammer repository synchronize \
--product "Red Hat Enterprise Linux Server" \
--name "Red Hat Enterprise Linux 7 Server (RPMs)" \
--organization $ORG \
--async

The task ID is displayed after executing the above command:

Repository is being synchronized in task 640bb71f-0ce5-40a3-a675-425a4acacceb

To view the progress of the task, issue:

$ hammer task progress --id 640bb71f-0ce5-40a3-a675-425a4acacceb

After finishing the first synchronization, the repository is added to the list of repositories mirrored on Satellite Server. Execute the following command to see the list:

$ hammer repository list --organization $ORG

You can also synchronize all repositories within a product as follows:

$ hammer product synchronize \
--organization-label org_label \
--name "product_name" \
--async

With the --async option, the repository synchronization runs in the background, which for example allows you to enable and synchronize several repositories in parallel.

Example 2.6. Synchronizing All Repositories in ACME Organization

The following Bash script synchronizes all repositories within the ACME organization.

ORG="ACME"

for i in $(hammer --csv repository list --organization $ORG | grep -vi '^ID' | awk -F, {'print $1'})
do
  hammer repository synchronize --id ${i} --organization $ORG --async
done

2.3.3. Creating a Synchronization Plan

Product in Red Hat Satellite is a collection of repositories that acts as the smallest unit of the synchronization process. You can create a synchronization plan to automatically update repositories of a selected product in a given time interval.

To define a synchronization plan, issue the following command:

$ hammer sync-plan create \
--name "sync_plan_name" \
--enabled=true \
--interval repetition_interval \
--organization-label org_label \
--sync-date "initial_sync"

Replace repetition_interval with hourly, daily, or weekly. Replace initial_sync with the date and time of the initial synchronization in the form of "YYYY-MM-DD HH:MM:SS".

Example 2.7. Creating a Synchronization Plan

The following command creates a daily synchronization schedule for the ACME organization, that runs at 3 a.m., starting from 15 January 2016:

$ hammer sync-plan create \
--name "daily sync at 3 a.m." \
--enabled=true \
--interval daily \
--organization $ORG \
--sync-date "2016-01-15 03:00:00"

To associate the synchronization plan with a product, issue the following command:

$ hammer product set-sync-plan \
--organization-label org_label \
--name "product_name" \
--sync-plan "sync_plan_name"

Example 2.8. Assigning a Synchronization Plan to Multiple Products

The following Bash script selects the products in the ACME organization that have been synchronized at least once and contain at least one repository and assigns them a synchronization plan named "daily sync at 3 a.m.".

ORG="ACME"
SYNC_PLAN="daily sync at 3 a.m."

for i in $(hammer --csv product list --organization $ORG --per-page 999 | grep -vi '^ID' | grep -vi not_synced | awk -F, {'{ if ($5!=0) print $1}'})
do
  hammer product set-sync-plan --sync-plan $SYNC_PLAN --organization $ORG --id $i
done

After executing the script, issue the following command to see which products have been assigned the synchronization plan:

$ hammer product list --organization $ORG --sync-plan "daily sync at 3 a.m."

To view synchronization plans available for a selected organization, issue the following command:

$ hammer sync-plan list --organization-label org_label

For more details on working with products and synchronization plans see the output of hammer sync-plan --help and hammer product --help.

2.3.4. Creating a Custom Repository

After enabling a Red Hat repository, the corresponding product is created automatically. To enable a repository with custom packages, you first need to manually create a product for this repository.

Use the following command to create a custom product:

$ hammer product create --name "product_name" --organization-label org_label

The following command creates a new repository under the custom product:

$ hammer repository create \
--name "repo_name" \
--organization-label org_label \
--product "product_name" \
--content-type cont_type --publish-via-http true \
--url "repo_url"

Replace the example values with your own details, in particular:

  • cont_type specifies the type of content in the repository, choose one of yum, puppet, or docker.
  • repo_url specifies the URL on which the repository will be available, valid only if ` --publish-via-http` is enabled.

To upload packages to a custom repository, issue the following command:

$ hammer repository upload-content \
 --organization-label org_label \
 --id "repo_id" \
--path path_to_dir

Replace path_to_dir with the path to the directory with content (RPM packages, Puppet modules, or Docker images) to be added to the custom repository.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.