2024/02/06 注記: subscription-manager にてユーザー情報を登録する方法から、insights-client にてパッケージの設定ファイルを編集する方法に修正しました。
はじめに
猫とアポロチョコが好きな、アノテーション株式会社の m.hayakawa です。
今回は Red Hat Insights を使う機会があったので、EC2 インスタンスを登録する一連の流れを記事にしようと思います。
登録の流れを知りたい方の一助になれば幸いです。
事前準備
検証用 EC2 の作成
今回は RHEL 9 の AMI(ami-0a3299a47e8a9111b) からインスタンスを作成します。
今回は検証用であるため、パブリックサブネットに配置し、セキュリティグループのアウトバウンドルールは全許可、インバウンドルールは自 IP からの SSH22 番ポートでのアクセスを許可します。
Red Hat Customer Portal のユーザー作成
下記 URL へアクセスし、「Register for a Red Hat account」をクリックし、Red Hat Customer Portal のユーザーを作成します。
ここで設定したユーザ名とパスワードは Insights クライアントを登録する際に使用するので、覚えておいてください。
すでに作っている場合は新規作成の必要はありません。
EC2(RHEL)への Insights の登録方法
Insights クライアントのインストール
EC2 に SSH 接続をし、Insights クライアントを yum コマンドでインストールします。
$ sudo yum install insights-client
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered with an entitlement server. You can use subscription-manager to register.
Red Hat Enterprise Linux 9 for x86_64 - AppStream from RHUI (RPMs) 57 MB/s | 28 MB 00:00
Red Hat Enterprise Linux 9 for x86_64 - BaseOS from RHUI (RPMs) 33 MB/s | 16 MB 00:00
Red Hat Enterprise Linux 9 Client Configuration 30 kB/s | 3.8 kB 00:00
Package insights-client-3.2.2-1.el9_3.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
なお、RHEL 8 では事前に Insights クライアントが既に組み込まれているとのことでしたが、上記の結果の通り、RHEL 9 も既に組み込まれているようです。
Q: Red Hat Insights とは何ですか? RHEL のどのバージョンと使用できますか? Red Hat Insights は事前対応型の管理ツールで、RHEL に広くサポートされています。Insights クライアントのインストールと登録が完了すると、Insights はバックグラウンドで稼動し、パフォーマンス、セキュリティ、その他の潜在的な問題について毎日アラートを送信し、運用に影響を及ぼす前に問題を解決します。RHEL 8 では Insights クライアントが既に組み込まれているため、インストールする必要はありませんが、アクティブ化する必要があります。Insights について詳しくはこちら、および「Public Cloud Usage」と「New Red Hat Account」サブタブを参照してください。
insights-clientパッケージの設定ファイル(/etc/insights-client/insights-client.conf)への BASIC 認証の設定
/etc/insights-client/insights-client.conf
を編集して、Red Hat Insightsを利用するためのBASIC認証を設定します。ユーザー名とパスワードはプレーンテキストとして保存されるため、扱いには十分お気を付けください。(変更箇所をコメントアウトで示しています。)
/etc/insights-client/insights-client.conf
[insights-client]
# Example options in this file are the defaults
# Change log level, valid options DEBUG, INFO, WARNING, ERROR, CRITICAL. Default DEBUG
#loglevel=DEBUG
# Attempt to auto configure with Satellite server
## ↓変更箇所↓
auto_config=False
# Change authentication method, valid options BASIC, CERT. Default BASIC
## ↓変更箇所↓
authmethod=BASIC
# username to use when authmethod is BASIC
## ↓変更箇所↓
username=<Red Hat Customer Portal アカウントのユーザー名>
# password to use when authmethod is BASIC
## ↓変更箇所↓
password=<Red Hat Customer Portal アカウントのユーザーのパスワード>
# Base URL for the Insights API
#base_url=cert-api.access.redhat.com:443/r/insights
# URL for your proxy. Example: http://user:pass@192.168.100.50:8080
#proxy=
# Automatically update the dynamic configuration
#auto_update=True
# Obfuscate IP addresses
#obfuscate=False
# Obfuscate hostname. Requires obfuscate=True.
#obfuscate_hostname=False
# Display name for registration
#display_name=
# Ansible hostname for this system
#ansible_host=
# Timeout for commands run during collection, in seconds
#cmd_timeout=120
# Timeout for HTTP calls, in seconds
#http_timeout=120
# Use insights-core as the collection source. Included for compatibility only. Modify only as directed.
#core_collect=True
# Location of the redaction file for commands, files, and components
#redaction_file=/etc/insights-client/file-redaction.yaml
# Location of the redaction file for patterns and keywords
#content_redaction_file=/etc/insights-client/file-content-redaction.yaml
# Location of the tags file for this system
#tags_file=/etc/insights-client/tags.yaml
EC2 を Red Hat Insights へ登録する
insights-client --register
を実行し、EC2 を Red Hat Insights へ登録します。
$ sudo insights-client --register
Successfully registered host ip-172-31-1-9.ap-northeast-1.compute.internal
Automatic scheduling for Insights has been enabled.
Starting to collect Insights data for ip-172-31-1-9.ap-northeast-1.compute.internal
Uploading Insights data.
Successfully uploaded report for ip-172-31-1-9.ap-northeast-1.compute.internal.
View the Red Hat Insights console at https://console.redhat.com/insights/
クライアントの状況をブラウザから確認する
コマンド結果で表示された URL へアクセスすることで確認できます。
最後に
手順としてまとめてみると、そこまで複雑な対応は必要なさそうに見えました。
ブラウザ上から様々な情報が取得できるので、監視の視認性が上がりそうです。ぜひ導入を検討してみてください。
参考資料
Red Hat Insights のクライアント設定ガイド Red Hat Insights 1-latest | Red Hat Customer Portal
Red Hat Customer Portal ログインIDの作成方法 | Red Hat Portal
パブリッククラウド上のRHELでもRed Hat Insightsを使ってセキュアに運用しよう - 赤帽エンジニアブログ
アノテーション株式会社について
アノテーション株式会社はクラスメソッドグループのオペレーション専門特化企業です。サポート・運用・開発保守・情シス・バックオフィスの専門チームが、最新 IT テクノロジー、高い技術力、蓄積されたノウハウをフル活用し、お客様の課題解決を行っています。当社は様々な職種でメンバーを募集しています。「オペレーション・エクセレンス」と「らしく働く、らしく生きる」を共に実現するカルチャー・しくみ・働き方にご興味がある方は、アノテーション株式会社 採用サイト をぜひご覧ください。