此内容没有您所选择的语言版本。
Chapter 10. Managing Activation Keys
Activation keys provide a method to automate system registration and subscription attachment. You can create multiple keys and associate them with different environments and Content Views. For example, you might create a basic activation key with a subscription for Red Hat Enterprise Linux workstations and associate it with Content Views from a particular environment.
You can use activation keys during content host registration to improve the speed, simplicity and consistency of the process.
Activation keys can define the following properties for content hosts:
- Associated subscriptions and subscription attachment behavior.
- Available products and repositories.
- A life cycle environment and a Content View.
- Host collection membership.
Note that activation keys are used only when hosts are registered. If changes are made to an activation key, it is applicable only to hosts that are registered with the amended activation key in the future. The changes are not made to existing hosts.
Content View Conflicts between Host Creation and Registration
When you provision a host, Satellite uses provisioning templates and other content from the Content View that you set in the host group or host settings. When the host is registered, the Content View from the activation key overwrites the original Content View from the host group or host settings. Then Satellite uses the Content View from the activation key for every future task, for example, rebuilding a host.
When you rebuild a host, ensure that you set the Content View that you want to use in the activation key and not in the host group or host settings.
Using the Same Activation Key with Multiple Content Hosts
You can apply the same activation key to multiple content hosts if it contains enough subscriptions. However, activation keys set only the initial configuration for a content host. When the content host is registered to an organization, the organization’s content can be attached to the content host manually.
Using Multiple Activation Keys with a Content Host
A content host can be associated with multiple activation keys that are combined to define the host settings. In case of conflicting settings, the last specified activation key takes precedence. You can specify the order of precedence by setting a host group parameter as follows:
$ hammer hostgroup set-parameter \ --name kt_activation_keys \ --value name_of_first_key, name_of_second_key,... \ --hostgroup hostgroup_name
10.1. Creating an Activation Key
You can use activation keys to define a specific set of subscriptions to attach to hosts during registration. The subscriptions that you add to an activation key must be available within the associated Content View.
Subscription Manager attaches subscriptions differently depending on the following factors:
- Are there any subscriptions associated with the activation key?
- Is the auto-attach option enabled?
Based on the previous factors, there are three possible scenarios for subscribing with activation keys:
Activation key with no subscriptions specified.
With no subscriptions specified and auto-attach enabled, hosts using the activation key search for the best fitting subscription from the ones provided by the Content View associated with the activation key. This is similar to entering the
subscription-manager --auto-attach
command.Activation key providing a custom subscription pool for auto-attach.
If there are subscriptions specified and auto-attach is enabled, hosts using the activation key select the best fitting subscription from the list specified in the activation key.
Activation key with the exact set of subscriptions.
If there are subscriptions specified and auto-attach is disabled, hosts using the activation key are associated with all subscriptions specified in the activation key.
Custom Products
If a custom product, typically containing content not provided by Red Hat, is assigned to an activation key, this product is always enabled for the registered content host regardless of the auto-attach setting.
Procedure
To create an activation key, complete the following steps:
- In the Satellite web UI, navigate to Content > Activation keys and click Create Activation Key.
- In the Name field, enter the name of the activation key.
- If you want to set a limit, clear the Unlimited hosts check box, and in the Limit field, enter the maximum number of systems you can register with the activation key. If you want unlimited hosts to register with the activation key, ensure the Unlimited Hosts check box is selected.
- In the Description field, enter a description for the activation key.
- From the Environment list, select the environment to use.
-
From the Content View list, select a Content View to use. If you want to use this activation key to register hosts, the Content View must contain the Satellite Tools repository because it is required to install the
katello-agent
. - Click Save and when your new activation key appears in the Activation Keys window, click the name to edit.
For CLI Users
Create the activation key:
# hammer activation-key create \ --name "My_Activation_Key" \ --unlimited-hosts \ --description "Example Stack in the Development Environment" \ --lifecycle-environment "Development" \ --content-view "Stack" \ --organization "My_Organization"
Obtain a list of your subscription IDs:
# hammer subscription list --organization "My_Organization"
Attach the Red Hat Enterprise Linux subscription UUID to the activation key:
# hammer activation-key add-subscription \ --name "My_Activation_Key" \ --subscription-id ff808181533518d50152354246e901aa \ --organization "My_Organization"
List the product content associated with the activation key:
# hammer activation-key product-content \ --name "My_Activation_Key" \ --organization "My_Organization"
Override the default auto-enable status for the Red Hat Satellite Tools 6.6 repository. The default status is set to disabled. To enable, enter the following command:
# hammer activation-key content-override \ --name "My_Activation_Key" \ --content-label rhel-7-server-satellite-tools-6.6-rpms \ --value 1 \ --organization "My_Organization"
10.2. Updating Subscriptions Associated with an Activation Key
You can change the subscriptions associated with an activation key using the web UI or using the Hammer command-line tool.
Note that changes to an activation key apply only to machines provisioned after the change. To update subscriptions on existing content hosts, see Section 4.7, “Bulk Updating Content Hosts' Subscriptions”.
Procedure
To update the subscriptions associated with an activation key, complete the following steps:
- In the Satellite web UI, navigate to Content > Activation keys and click the name of the activation key.
- Click the Subscriptions tab.
- To remove subscriptions, select List/Remove, and then select the check boxes to the left of the subscriptions to be removed and then click Remove Selected.
- To add subscriptions, select Add, and then select the check boxes to the left of the subscriptions to be added and then click Add Selected.
- Click the Repository Sets tab and review the repositories' status settings.
- To enable or disable a repository, select the check box for a repository and then change the status using the Select Action list.
- Click the Details tab, select a Content View for this activation key, and then click Save.
For CLI Users
List the subscriptions that the activation key currently contains:
# hammer activation-key subscriptions \ --name My_Activation_Key \ --organization "My_Organization"
Remove the required subscription from the activation key:
# hammer activation-key remove-subscription \ --name "My_Activation_Key" \ --subscription-id ff808181533518d50152354246e901aa \ --organization "My_Organization"
For the
--subscription-id
option, you can use either the UUID or the ID of the subscription.Attach new subscription to the activation key:
# hammer activation-key add-subscription \ --name "My_Activation_Key" \ --subscription-id ff808181533518d50152354246e901aa \ --organization "My_Organization"
For the
--subscription-id
option, you can use either the UUID or the ID of the subscription.List the product content associated with the activation key:
# hammer activation-key product-content \ --name "My_Activation_Key" \ --organization "My_Organization"
Override the default auto-enable status for the required repository:
# hammer activation-key content-override \ --name "My_Activation_Key" \ --content-label content_label \ --value 1 \ --organization "My_Organization"
For the
--value
option, enter1
for enable,0
for disable.
10.3. Using Activation Keys for Host Registration
You can use activation keys to complete the following tasks:
- Registering new hosts during provisioning through Red Hat Satellite 6. The kickstart provisioning templates in Red Hat Satellite 6 contain commands to register the host using an activation key that is defined when creating a host.
-
Registering existing Red Hat Enterprise Linux hosts. Configure Red Hat Subscription Manager to use Satellite Server for registration and specify the activation key when running the
subscription-manager register
command.
Procedure
To use an activation key for host registration with an existing Red Hat Enterprise Linux 7 host to Satellite Server, complete the following steps:
Download the consumer RPM for your Satellite Server. This is located in the
pub
directory on the host’s web server. For example, for a Satellite Server with the host namesatellite.example.com
, enter the following command on the host to register:# rpm -Uvh http://satellite.example.com/pub/katello-ca-consumer-latest.noarch.rpm
This RPM installs the necessary certificates for accessing repositories on Satellite Server and configures Red Hat Subscription Manager to use the server’s URL.
On the host, enter the following command to register the host to Satellite using the activation key:
# subscription-manager register --activationkey="My_Activation_Key" \ --org="My_Organization"
To view a list of hosts for an organization, on Satellite Server, enter the following command:
# hammer host list --organization "My_Organization"
After registering a host to Satellite Server, install the
katello-agent
package on the host so that it can report back to Satellite Server:# yum install katello-agent
The Red Hat Satellite Tools 6.6 repository provides this package.
Multiple Activation Keys
You can use multiple activation keys when registering a content host. You can then create activation keys for specific subscription sets and combine them according to content host requirements. For example, the following command registers a content host to your organization with both VDC and OpenShift subscriptions:
# subscription-manager register --org="My_Organization" \
--activationkey="ak-VDC,ak-OpenShift"
Settings Conflicts
If there are conflicting settings in activation keys, the rightmost key takes precedence.
- Settings that conflict: Service Level, Release Version, Environment, Content View, and Product Content.
- Settings that do not conflict and the host gets the union of them: Subscriptions and Host Collections.
- Settings that influence the behavior of the key itself and not the host configuration: Content Host Limit and Auto-Attach.
10.4. Enabling Auto-Attach
When auto-attach is enabled on an activation key and there are subscriptions associated with the key, the subscription management service selects and attaches the best-matched associated subscriptions based on a set of criteria like currently installed products, architecture, and preferences like service level.
You can enable auto-attach and have no subscriptions associated with the key. This type of key is commonly used to register virtual machines when you do not want the virtual machine to consume a physical subscription, but to inherit a host-based subscription from the hypervisor. For more information, see Configuring Virtual Machine Subscriptions in Red Hat Satellite.
Auto-attach is enabled by default. Disable the option if you want to force attach all subscriptions associated with the activation key.
Procedure
To enable auto-attach, complete the following steps:
- In the Satellite web UI, navigate to Content > Activation Keys.
- Click the activation key name that you want to edit.
- Click the Subscriptions tab.
- Click the edit icon next to Auto-Attach.
- Select or clear the check box to enable or disable auto-attach.
- Click Save.
For CLI Users
To enable auto-attach on the activation key:
# hammer activation-key update --name "My_Activation_Key" \ --organization "My_Organization" --auto-attach true
10.5. Setting the Service Level
You can configure an activation key to define a default service level for the new host created with the activation key. Setting a default service level selects only the matching subscriptions to be attached to the host. For example, if the default service level on an activation key is set to Premium, only subscriptions with premium service levels are attached to the host upon registration.
Procedure
To set the service level, complete the following steps:
- In the Satellite web UI, navigate to Content > Activation Keys.
- Click the activation key name you want to edit.
- Click the edit icon next to Service Level.
- Select the required service level from the list. The list only contains service levels available to the activation key.
- Click Save.
For CLI Users
To set a default service level to Premium on the activation key:
# hammer activation-key update --name "My_Activation_Key" \ --organization "My_Organization" --service-level premium