LoginSignup
2
2

More than 5 years have passed since last update.

AWSのUserDataでRHEL起動時にサブスクリプションを自動で追加する

Last updated at Posted at 2017-12-28

OpenShiftをインストールするときなど、RHEL起動時にsubscription-managerでシステム登録して、さらにサブスクリプションをアタッチして…という作業が面倒。

cloud-initで起動時に自動でサブスクリプションを追加したい。

cloud-initのrh_subscriptionモジュール

というものがRHEL7.4のcloud-initから使用できます。

これをUserDataに設定することで起動と同時にシステムを登録してサブスクリプションを追加できます。

rh_subscriptionをUserDataに設定する

以下の内容をUserDataに設定して、RHEL7.4のインスタンスを起動します。

#cloud-config
rh_subscription:
  username: 'xxx@example.com' # RHNのユーザー名
  password: 'xxxxx' # RHNのパスワード
  auto-attach: False # 適切っぽいサブスクリプションを自動的に追加するかどうか
  add-pool: [ 'xxxxxxxxx' ] # 追加したいサブスクリプションのPool ID

rhel-sb-screen.png

rh_subscriptionのオプション詳細

より。

#cloud-config

# RHELベースのOSを登録します。
#
# このcloud-initプラグインではユーザー名/パスワードまたはアクティベーションでシステムを登録することができます。
# また、登録に成功した後、以下のことも可能です:
#  - サブスクリプションのauto-attach
#  - service levelの設定
#  - pool IDを明示してサブスクリプションを追加
#  - repo idでyumリポジトリを有効化する
#  - repo idでyumリポジトリを無効化する
#  - /etc/rhsm/rhs.confのrhsm_baseurlとserver-hostnameを変更する


rh_subscription:
    username: joe@foo.bar

    ## 記号を安全に使いたい場合はクォートで囲んでください
    password: '1234abcd'

    ## ユーザー名とパスワードの代わりに、組織とアクティベーションキーを使うこともできます。
    ## その場合、ユーザー名とパスワードをコメントアウトしてください。
    #activation-key: foobar
    #org: 12345

    ## サブスクリプションをシステムにauto-attachする場合はコメントアウトを外します 
    #auto-attach: True

    ## サブスクリプションのサービスレベルを指定する場合はコメントアウトを外します
    ## (訳注: auto-attachの際に適切なサブスクリプションをフィルタリングするのに使用します)
    #service-level: self-support

    ## poolを追加するにはコメントアウトを外します(PoolIDのリストで指定する)
    #add-pool: []

    ## yumレポジトリを追加したり削除したりするにはコメントアウトを外します(repo-idのリストで指定する)
    ## (訳注: なお、以下のようにアスタリスクも指定できるようです。 disable-repo: [ '*' ])
    #enable-repo: []
    #disable-repo: []

    ## /etc/rhsm/rhsm.confのbaseurlを変更するにはコメントアウトを外します
    #rhsm-baseurl: http://url

    ## /etc/rhsm/rhsm.confのサーバーホスト名を変更するにはコメントアウトを外します
    #server-hostname: foo.bar.com
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2