Red Hat Training

A Red Hat training course is available for RHEL 8

36.4. IdM ホストグループへの ID ビューの適用

ipa idview-apply コマンドでは、--hostgroups オプションを使用できます。ただし、このオプションは、指定のホストに現在所属するホストに ID ビューを適用する 1 回限りの操作として機能しますが、ホストグループ自体と ID ビューを動的に関連付けることはありません。--hostgroups オプションは、指定したホストグループのメンバーを拡張して、--hosts オプションを個別にすべて適用します。

新しいホストを後でホストグループに追加する場合は、--hosts オプションで ipa idview-apply コマンドを使用して、新しいホストに ID ビューを手動で適用する必要があります。

同様に、ホストグループからホストを削除すると、ID ビューは削除後でも、ホストに割り当てられます。削除されたホストから ID ビューの適用を解除するには、ipa idview-unapply id_view_name --hosts=name_of_the_removed_host コマンドを実行する必要があります。

次の目標を達成するには、次の手順に従ってください。

  1. ホストグループを作成し、そのグループにホストを追加する方法。
  2. ID ビューをホストグループに適用する方法。
  3. ホストグループに新規ホストを追加し、ID ビューを新しいホストに適用する方法。

前提条件

手順

  1. ホストグループを作成し、そのグループにホストを追加します。

    1. ホストグループを作成します。たとえば、baltimore という名前のホストグループを作成するには、次のコマンドを実行します。

      [root@server ~]# ipa hostgroup-add --desc="Baltimore hosts" baltimore
      ---------------------------
      Added hostgroup "baltimore"
      ---------------------------
      Host-group: baltimore
      Description: Baltimore hosts
    2. ホストグループにホストを追加します。たとえば、host102 および host103baltimore ホストグループに追加するには、次のコマンドを実行します。

      [root@server ~]# ipa hostgroup-add-member --hosts={host102,host103} baltimore
      Host-group: baltimore
      Description: Baltimore hosts
      Member hosts: host102.idm.example.com, host103.idm.example.com
      -------------------------
      Number of members added 2
      -------------------------
  2. ホストグループのホストに ID ビューを適用します。たとえば、example_for_host1 ID ビューを ‍baltimore ホストグループに適用するには、次のコマンドを実行します。

    [root@server ~]# ipa idview-apply --hostgroups=baltimore
    ID View Name: example_for_host1
    -----------------------------------------
    Applied ID View "example_for_host1"
    -----------------------------------------
      hosts: host102.idm.example.com, host103.idm.example.com
    ---------------------------------------------
    Number of hosts the ID View was applied to: 2
    ---------------------------------------------
  3. ホストグループに新規ホストを追加し、ID ビューを新しいホストに適用します。

    1. ホストグループに新規ホストを追加します。たとえば、somehost.idm.example.com ホストを baltimore ホストグループに追加するには、次のコマンドを実行します。

      [root@server ~]# ipa hostgroup-add-member --hosts=somehost.idm.example.com baltimore
        Host-group: baltimore
        Description: Baltimore hosts
        Member hosts:  host102.idm.example.com, host103.idm.example.com,somehost.idm.example.com
      -------------------------
      Number of members added 1
      -------------------------
    2. 必要に応じて、ID ビュー情報を表示します。たとえば、example_for_host1 ID ビューの詳細を表示するには、次のコマンドを実行します。

      [root@server ~]# ipa idview-show example_for_host1 --all
        dn: cn=example_for_host1,cn=views,cn=accounts,dc=idm,dc=example,dc=com
        ID View Name: example_for_host1
      [...]
        Hosts the view applies to: host102.idm.example.com, host103.idm.example.com
        objectclass: ipaIDView, top, nsContainer

      この出力では、ID ビューが baltimore ホストグループに新規追加されたホスト somehost.idm.example.com に適用されていないことが分かります。

    3. ID ビューを新規ホストに適用します。たとえば、ID ビュー example_for_host1somehost.idm.example.com に適用するには、次のコマンドを実行します。

      [root@server ~]# ipa idview-apply --host=somehost.idm.example.com
      ID View Name: example_for_host1
      -----------------------------------------
      Applied ID View "example_for_host1"
      -----------------------------------------
        hosts: somehost.idm.example.com
      ---------------------------------------------
      Number of hosts the ID View was applied to: 1
      ---------------------------------------------

検証手順

  • ID ビュー情報を再度表示します。

    [root@server ~]# ipa idview-show example_for_host1 --all
      dn: cn=example_for_host1,cn=views,cn=accounts,dc=idm,dc=example,dc=com
      ID View Name: example_for_host1
    [...]
      Hosts the view applies to: host102.idm.example.com, host103.idm.example.com, somehost.idm.example.com
      objectclass: ipaIDView, top, nsContainer

    この出力は、ID ビューが baltimore ホストグループに新規追加されたホスト somehost.idm.example.com に適用されていることを示しています。