Confluent Platform をインストールするための Ansible インベントリファイルの準備

Ansible Playbook を実行する前に、インベントリファイルを生成する必要があります。インベントリファイルでは Confluent Platform コンポーネントをプロビジョニングするホストを指定します。Ansible インベントリファイルについて詳しくは、Ansible のインベントリの基本 を参照してください。

インベントリファイルの生成

インベントリファイルを生成するには、ホストの完全修飾ドメイン名(FQDN)をすべて集め、Ansible コントロールノードに hosts.yml というファイルを作成して、以下に示すように必要なグループの下に各ホスト名を設定します。

各ホストの組み込みの inventory_hostname 変数は、ホストのホスト名に設定されます。

zookeeper:
  hosts:
    ip-172-31-34-246.us-east-2.compute.internal:
    ip-172-31-37-15.us-east-2.compute.internal:
    ip-172-31-34-231.us-east-2.compute.internal:

kafka_broker:
  hosts:
    ip-172-31-34-246.us-east-2.compute.internal:
      broker_id: 0
    ip-172-31-34-247.us-east-2.compute.internal:
      broker_id: 1
    ip-172-31-34-248.us-east-2.compute.internal:
      broker_id: 3

schema_registry:
  hosts:
    ip-172-31-34-246.us-east-2.compute.internal:

kafka_rest:
  hosts:
    ip-172-31-34-246.us-east-2.compute.internal:

ksql:
  hosts:
    ip-172-31-37-15.us-east-2.compute.internal:
    ip-172-31-37-16.us-east-2.compute.internal:

kafka_connect:
  hosts:
    ip-172-31-34-246.us-east-2.compute.internal:

control_center:
  hosts:
    ip-172-31-37-15.us-east-2.compute.internal:

ansible_host を使用した SSH の接続

inventory_hostname が SSH で機能しない場合、ansible_host 変数を使用して SSH の接続向けのホスト名をもう 1 つ指定できます。

以下の例では、ip-172-31-40-189.us-west-2.compute.internalinventory_hostname であり、ec2-34-217-174-252.us-west-2.compute.amazonaws.com が SSH に使用されます。

zookeeper:
  hosts:
    ip-172-31-40-189.us-west-2.compute.internal:
      ansible_host: ec2-34-217-174-252.us-west-2.compute.amazonaws.com

Confluent Platform ホストへの接続の確認

インベントリファイルを生成したら、Ansible コントロールノードが各 Confluent Platform ホストと接続できるよう、接続変数を設定します。

多くの場合、Ansible では接続に SSH が使用されます。接続変数の設定について詳しくは、『 Connecting to hosts: behavioral inventory parameters 』を参照してください。

hosts.yml に次のセクションを追加します。

all:
  vars:
    ansible_connection: ssh
    ansible_user: ec2-user
    ansible_become: true
    ansible_ssh_private_key_file: /tmp/certs/ssh_priv.pem

Ansible が SSH で接続できることを検証するには、次のコマンドを使用します。

ansible -i /path/to/hosts.yml all -m ping

上記のコマンドでは、すべてのホストで Python インタープリターが使用できることを検証し、成功すると pong が返されます。

インベントリファイルはそれぞれの Git リポジトリ内に保存することをお勧めします。各デプロイに対してインベントリファイルを含む Git リポジトリが存在している場合があります。