Abonnez-vous au flux

This article was originally published on the Red Hat Customer Portal. The information may no longer be current.

Overview

As a user of subscription-manager, I find myself frequently frustrated when running a subscription-manager list --all --available to find a specific subscription. As I am using an account that has a large number of subscriptions this is painful. And since each subscription has a varying amount of output associated with it, using grep (even with the -A switch) is painful. Ultimately, I end up piping the output via my PAGER (less|more|most) until I find the pool ID that I want. That is less than desirable.

This article covers some new options that are present in newer versions of subscription-manager to make dealing with subscriptions less painful.

Requirements

  • subscription-manager >= 1.13.6-1 (What is included in RHEL >= 6.7 and >= 7.1)
    • Red Hat Subscription Management (RHSM)
    • Red Hat Satellite 6.1 or greater

Features

subscription-manager now has a --matches option which will match a variety of fields, varying with the list type:

  • Installed
    • Product Name
    • Product ID
  • Available
    • Subscription Name
    • Product Name & Product ID for each product listed under Provides:
    • SKU
    • Contract
    • Service Level
  • Consumed
    • Subscription Name
    • Product Name & Product ID for each product listed under Provides
    • SKU
    • Contract
    • Service Level

Let's see it in action:

Use case 1

As a user, I want to find ALL subscriptions which have Red Hat Satellite in their name. (because everyone wants to install Satellite components, right?)

# subscription-manager list --available --matches 'Red Hat Satellite*'

+-------------------------------------------+
    Available Subscriptions
+-------------------------------------------+
Subscription Name:   Red Hat Satellite
Provides:            Red Hat Satellite Capsule Beta
                     Red Hat Beta
                     Red Hat Software Collections (for RHEL Server)
                     Red Hat Satellite Capsule
                     Red Hat Satellite with Embedded Oracle
                     Red Hat Satellite 6 Beta
                     Red Hat Satellite Beta
                     Red Hat Enterprise Linux Server
                     Red Hat Enterprise Linux High Availability (for RHEL Server)
                     Red Hat Satellite
                     Red Hat Software Collections Beta (for RHEL Server)
                     Red Hat Enterprise Linux Load Balancer (for RHEL Server)
SKU:                 MCT0370
Contract:            11223344
Pool ID:             2c918f824e5ef0e8014e675ed46d0eeb
Provides Management: Yes
Available:           1
Suggested:           1
Service Level:       Premium
Service Type:        L1-L3
Subscription Type:   Standard
Ends:                10/08/2016
System Type:         Physical

Subscription Name:   Red Hat Satellite Capsule Server
Provides:            Red Hat Satellite Proxy
                     Red Hat Satellite Capsule Beta
                     Red Hat Beta
                     Red Hat Software Collections (for RHEL Server)
                     Red Hat Satellite Capsule
                     Red Hat Enterprise Linux Server
                     Red Hat Enterprise Linux High Availability (for RHEL Server)
                     Red Hat Software Collections Beta (for RHEL Server)
                     Red Hat Enterprise Linux Load Balancer (for RHEL Server)
SKU:                 MCT0369
Contract:            11223344
Pool ID:             2c918f824e5ef0e8014e675ed2e30e8c
Provides Management: Yes
Available:           5
Suggested:           1
Service Level:       Premium
Service Type:        L1-L3
Subscription Type:   Standard
Ends:                10/08/2016
System Type:         Physical

Use Case 2

As a (more advanced) user, show me all of the RH00004 - Red Hat Enterprise Linux Server, Standard (Physical or Virtual Nodes) subscriptions that I own

#subscription-manager list --available --matches 'RH00004'
+-------------------------------------------+
    Available Subscriptions
+-------------------------------------------+

Subscription Name:   Red Hat Enterprise Linux Server, Standard (Physical or Virtual Nodes)
Provides:            Red Hat Container Images Beta
                     Red Hat Beta
                     Red Hat Software Collections (for RHEL Server)
                     Oracle Java (for RHEL Server)
                     Red Hat Enterprise Linux Atomic Host Beta
                     Red Hat Container Images
                     Red Hat Enterprise Linux Server
                     Red Hat Software Collections Beta (for RHEL Server)
                     Red Hat Enterprise Linux Atomic Host
                     Red Hat Developer Toolset (for RHEL Server)
SKU:                 RH00004
Contract:            11223344
Pool ID:             2c918f824e5ef0e8014e675ed7a10fc2
Provides Management: No
Available:           4
Suggested:           1
Service Level:       Standard
Service Type:        L1-L3
Subscription Type:   Instance Based
Ends:                10/08/2016
System Type:         Physical


Subscription Name:   Red Hat Enterprise Linux Server, Standard (Physical or Virtual Nodes)
Provides:            Red Hat Container Images Beta
                     Red Hat Beta
                     Red Hat Software Collections (for RHEL Server)
                     Oracle Java (for RHEL Server)
                     Red Hat Enterprise Linux Atomic Host Beta
                     Red Hat Container Images
                     Red Hat Enterprise Linux Server
                     Red Hat Software Collections Beta (for RHEL Server)
                     Red Hat Enterprise Linux Atomic Host
                     Red Hat Developer Toolset (for RHEL Server)
SKU:                 RH00004
Contract:            44332211
Pool ID:             2c918f824e5ef0e8014e675ed7320fa2
Provides Management: No
Available:           5
Suggested:           1
Service Level:       Standard
Service Type:        L1-L3
Subscription Type:   Instance Based
Ends:                11/20/2016
System Type:         Physical

Advanced usage 1:

In Satellite 6, when creating a custom product (under Content->Products), a subscription is created, allowing you to treat custom software exactly how you treat Red Hat software. Thus, subscription-manager (and our new handy-dandy --matches command) works for them too.

#  subscription-manager list --available --matches 'Extra*'
+-------------------------------------------+
    Available Subscriptions
+-------------------------------------------+

Subscription Name:   Extra Packages for Enterprise Linux
Provides:
SKU:                 1436175280816
Contract:
Pool ID:             2c918f824e5ef0e8014e62b7abcf0a02
Provides Management: No
Available:           Unlimited
Suggested:           1
Service Level:
Service Type:
Subscription Type:   Standard
Ends:                06/28/2045
System Type:         Physical

Advanced usage 2

I want to search for (and attach) a Satellite Capsule Server subscription. As a review, we can use either '--matches MCT0369' OR '--matches Red Hat Satellite Capsule Server'. Your pick . We'll use the '--pool-only' switch to output just the pool ID and then pipe that to the attach subcommand.

#subscription-manager list --available --matches 'Red Hat Satellite Capsule Server'
+-------------------------------------------+
    Available Subscriptions
+-------------------------------------------+
Subscription Name:   Red Hat Satellite Capsule Server
Provides:            Red Hat Satellite Proxy
                     Red Hat Satellite Capsule Beta
                     Red Hat Beta
                     Red Hat Software Collections (for RHEL Server)
                     Red Hat Satellite Capsule
                     Red Hat Enterprise Linux Server
                     Red Hat Enterprise Linux High Availability (for RHEL Server)
                     Red Hat Software Collections Beta (for RHEL Server)
                     Red Hat Enterprise Linux Load Balancer (for RHEL Server)
SKU:                 MCT0369
Contract:            11223344
Pool ID:             2c918f824e5ef0e8014e675ed2e30e8c
Provides Management: Yes
Available:           5
Suggested:           1
Service Level:       Premium
Service Type:        L1-L3
Subscription Type:   Standard
Ends:                10/08/2015
System Type:         Physical

And let's attach that sub. And there are two ways to do that.

# subscription-manager list --available \
   --matches 'Red Hat Satellite Capsule Server' \
   --pool-only | subscription-manager attach --file=-
Successfully attached a subscription for: Red Hat Satellite Capsule Server

OR

# subscription-manager attach \
  --pool=$(subscription-manager list --available \
  --matches 'Red Hat Satellite Capsule Server' --pool-only)

References

  • man (8) subscription-manager
  • BZ1146125 – [RFE] would like a --contains-text option for subscription-manager list module
  • BZ1210294 - request for subscription-manager to support attaching a matching subscription

À propos de l'auteur

Rich Jerrido is the Senior Principal Product Manager for Hybrid Cloud Business Services.
 
Read full bio
UI_Icon-Red_Hat-Close-A-Black-RGB

Parcourir par canal

automation icon

Automatisation

Les dernières nouveautés en matière d'automatisation informatique pour les technologies, les équipes et les environnements

AI icon

Intelligence artificielle

Actualité sur les plateformes qui permettent aux clients d'exécuter des charges de travail d'IA sur tout type d'environnement

open hybrid cloud icon

Cloud hybride ouvert

Découvrez comment créer un avenir flexible grâce au cloud hybride

security icon

Sécurité

Les dernières actualités sur la façon dont nous réduisons les risques dans tous les environnements et technologies

edge icon

Edge computing

Actualité sur les plateformes qui simplifient les opérations en périphérie

Infrastructure icon

Infrastructure

Les dernières nouveautés sur la plateforme Linux d'entreprise leader au monde

application development icon

Applications

À l’intérieur de nos solutions aux défis d’application les plus difficiles

Original series icon

Programmes originaux

Histoires passionnantes de créateurs et de leaders de technologies d'entreprise