How can I subscribe systems to a distributor using subscription-manager in a kickstart file?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 6.1 or newer
  • Red Hat Enterprise Linux 5.7 or newer

Issue

  • How do I use subscription-manager in a kickstart file

Resolution

The subscription-manager command line application is used to register a system to the Certificate-Based Subscription Management service, according to the subscriptions available to the organization. Similar to registering a system to a local Satellite service, subscription-manager can be run as part of the post-install script in a kickstart file. The --autosubscribe option automatically subscribes the new system to the best matched subscription pool available after registering to the entitlements service.

Insert the following in the %post section of the kickstart file:

%post --log=/root/ks-post.log  
/usr/sbin/subscription-manager register --username <rhn_username> \
  --password <rhn_password> --autosubscribe

A more advanced form, where you have implemented your own instance of Subscription Asset Manager would be:

/usr/sbin/subscription-manager register --username=admin@example.com --password=secret \
  --serverurl=sam-server.example.com --org="Admin Group" --environment="Dev" \  
  --servicelevel=standard --release="6.4"

NOTE: Utilizing this method results in the kickstart file containing the RHN username and password in plain-text format, and the file should be protected and safeguarded from potential malicious activities. The care required is similar to the rhnreg_ks functionality used in RHN Classic.

For more detail about subscription-manager usage please review How do I register my system using Red Hat Subscription Manager?

For more detail about the 2013 Packaging Model please review the Overview of Red Hat Enterprise Linux 2013 Packaging Model.

For a full understanding of subscription management, please review the This content is not included.Red Hat Subscription Management Guide.

SBR
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.