피드 구독

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

저자 소개

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

채널별 검색

automation icon

오토메이션

기술, 팀, 인프라를 위한 IT 자동화 최신 동향

AI icon

인공지능

고객이 어디서나 AI 워크로드를 실행할 수 있도록 지원하는 플랫폼 업데이트

open hybrid cloud icon

오픈 하이브리드 클라우드

하이브리드 클라우드로 더욱 유연한 미래를 구축하는 방법을 알아보세요

security icon

보안

환경과 기술 전반에 걸쳐 리스크를 감소하는 방법에 대한 최신 정보

edge icon

엣지 컴퓨팅

엣지에서의 운영을 단순화하는 플랫폼 업데이트

Infrastructure icon

인프라

세계적으로 인정받은 기업용 Linux 플랫폼에 대한 최신 정보

application development icon

애플리케이션

복잡한 애플리케이션에 대한 솔루션 더 보기

Original series icon

오리지널 쇼

엔터프라이즈 기술 분야의 제작자와 리더가 전하는 흥미로운 스토리