HashiCorp Vault は、Orchestrator で資格情報ストアとして使用できるプラグインです。
次の 2 つのプラグインが含まれています。
- HashiCorp Vault – 読み取り/書き込みプラグイン (シークレットは Orchestrator によって作成される)。
- HashiCorp Vault (読み取り専用) – 読み取り専用プラグイン (シークレットは Vault で直接プロビジョニングする必要がある)。
前提条件
-
サポートされている、以下のいずれかの認証方法を設定する必要があります。
- AppRole (推奨)
- UsernamePassword
- LDAP
- Token
See how to configure authentication.
-
サポートされている、以下のいずれかのシークレット エンジンを設定する必要があります。
- KeyValueV1 - HashiCorp Vault と HashiCorp Vault (読み取り専用) の両方のプラグインで使用できます。
- KeyValueV2 - HashiCorp Vault と HashiCorp Vault (読み取り専用) の両方のプラグインで使用できます。
- ActiveDirectory - HashiCorp Vault (読み取り専用) プラグインでのみ使用できます。
-
選択した認証方法には、シークレットを保存するパスに対して以下の機能を許可するポリシーが設定されている必要があります。
- HashiCorp Vault (読み取り専用) プラグイン:
read
- HashiCorp Vault プラグイン:
create
、read
、update
、delete
、およびKeyValueV2
シークレット エンジンを使用する場合は、任意でメタデータ パスに対するdelete
。
- HashiCorp Vault (読み取り専用) プラグイン:
連携を構成する
The following is an example of how to configure a development version of HashiCorp Vault, running in a docker container, to be used as a credential store with Orchestrator. The examples should be adapted to your own environment. Please consult the official documentation of HashiCorp Vault for details.
認証を構成する
シークレットの作成と読み取りを開始するには、まず以下の手順を実行して、認証方法を設定する必要があります。
- コンテナー内でシェルを開きます。
docker exec -it dev-vault sh
- ルートとしてログインします。以下のコマンドを実行して、環境変数を設定するためのルート トークンがログに表示されていることを確認します。
export VAULT_TOKEN=s.hA7RJ5lBqSnKUPd8nrQBaK1f
- 以下のコマンドを実行して、Vault のステータスを確認します。
vault status
- Orchestrator のダミー シークレットを KV ストアに追加します。
vault kv put secret/applications/orchestrator/testSecret supersecretpassword=123456
- Orchestrator に、新たに作成された
secret/applications/orchestrator
パスへのアクセス権を付与します。それには、まず以下のコマンドを実行して、このパスとそのすべてのサブパスに対する読み取りと書き込みのポリシーを作成する必要があります。
cat <<EOF | vault policy write orchestrator-policy -
path "secret/data/applications/orchestrator/*" {
capabilities = ["create", "read", "update", "delete"]
}
path "secret/metadata/applications/orchestrator/*" {
capabilities = ["delete"]
}
EOF
注:
KeyValueV2 シークレット エンジンを使用すると、シークレットはパス
<mount>/data/<secret-path>
に書き込まれ、取得されます。これに対し、KeyValueV1 では<mount>/<secret-path>
に書き込まれ、取得されます。CLI コマンドは変更されません (つまり、パスにデータは指定しません)。
ただし、機能は実際のパスに適用されるため、ポリシーは変更されます。前の例では、KeyValueV2 シークレット エンジンを使用しているため、パスはsecret/data/applications/orchestrator/*
です。KeyValueV2 が使用されていた場合、パスはsecret/applications/orchestrator/*
でした。メタデータ パス上での削除機能が必要になるのは、Orchestrator で接続の検証時にテスト キーが残されないようにする場合のみです。この機能がない場合、Orchestrator で資格情報ストアを作成するときに、キーが作成されて、そのまま残ります。
userpass
を認証方法として使用した認証を有効化した後、Orchestrator のユーザーを作成し、作成済みのポリシーを割り当てます。
vault auth enable userpass
vault write auth/userpass/users/orchestrator password=123456 policies=orchestrator-policy
注:
Orchestrator は複数の認証モードをサポートしています。設定方法については、HashiCorp Vault のドキュメントをご覧ください。
- ログインし、前に作成したシークレットを読み取って、すべてを正しく設定したことを確認します。
vault login -method=userpass username=orchestrator password=123456
このコマンドの出力:
WARNING! The VAULT_TOKEN environment variable is set! This takes precedence
over the value set by this command. To use the value set by this command,
unset the VAULT_TOKEN environment variable or set it to the token displayed
below.
Success! You are now authenticated. The token information displayed below
is already stored in the token helper. You do NOT need to run "vault login"
again. Future Vault requests will automatically use this token.
Key Value
--- -----
token s.nwombWQH3gGPDhJumRzxKqgI
token_accessor aGJL6Pzc6fRRuP8d8tTjS2Kj
token_duration 768h
token_renewable true
token_policies ["default" "orchestrator-policy"]
identity_policies []
policies ["default" "orchestrator-policy"]
token_meta_username orchestratorWARNING! The VAULT_TOKEN environment variable is set! This takes precedence
over the value set by this command. To use the value set by this command,
unset the VAULT_TOKEN environment variable or set it to the token displayed
below.
Success! You are now authenticated. The token information displayed below
is already stored in the token helper. You do NOT need to run "vault login"
again. Future Vault requests will automatically use this token.
Key Value
--- -----
token s.nwombWQH3gGPDhJumRzxKqgI
token_accessor aGJL6Pzc6fRRuP8d8tTjS2Kj
token_duration 768h
token_renewable true
token_policies ["default" "orchestrator-policy"]
identity_policies []
policies ["default" "orchestrator-policy"]
token_meta_username orchestrator
- このトークンをルート トークンの代わりに設定した後、テスト シークレットを読み取ります。
export VAULT_TOKEN=s.nwombWQH3gGPDhJumRzxKqgI
vault kv get secret/applications/orchestrator/testSecret
このコマンドの出力:
====== Metadata ======
Key Value
--- -----
created_time 2020-10-12T06:24:41.7827631Z
deletion_time n/a
destroyed false
version 1
=========== Data ===========
Key Value
--- -----
supersecretpassword 123456====== Metadata ======
Key Value
--- -----
created_time 2020-10-12T06:24:41.7827631Z
deletion_time n/a
destroyed false
version 1
=========== Data ===========
Key Value
--- -----
supersecretpassword 123456
注:
以下のコマンドを実行して、appRole Orchestrator を有効化することもできます。
/ # vault auth enable approle / # vault write auth/approle/role/orchestrator policies=orchestrator-policy / # vault read auth/approle/role/orchestrator/role-id / # vault write -f auth/approle/role/orchestrator/secret-id
これで、Orchestrator での設定に必要なロール ID とシークレット ID を使用できるようになりました。
Active Directory シークレット エンジンを設定する
Active Directory シークレット エンジンを設定するには、以下の手順を実行します。
- 以下のコマンドを実行して、Active Directory シークレット エンジンを有効化します。
vault secrets enable ad
- HashiCorp Vault が Active Directory と通信してパスワードを生成するために使用する資格情報を設定します。
vault write ad/config \
binddn=$USERNAME \
bindpass=$PASSWORD \
url=ldaps://138.91.247.105 \
userdn='dc=example,dc=com'
- HashiCorp Vault の名前を Active Directory のアカウントにマップするロールを設定します。アプリケーションがパスワードを要求するときに、このロールでパスワード ローテーションの設定が管理されます。
vault write ad/roles/orchestrator service_account_name="my-application@example.com"
- AppRole などの認証方法を使用して、
ad/creds/orchestrator
にある資格情報へのアクセス権をorchestrator
に付与します。
cat <<EOF | vault policy write orchestrator-policy -
path "ad/creds/orchestrator" {
capabilities = ["read"]
}
EOF
HashiCorp Vault (読み取り専用) を使用する
HashiCorp Vault (読み取り専用) プラグインを使用する場合、Vault の管理者は Orchestrator が使用するシークレットを正しくプロビジョニングする必要があります。これらのシークレットのプロビジョニング形式は、シークレットの種類 (アセットあるいはロボットのパスワード) やシークレット エンジンによって異なります。
シークレットをプロビジョニングする手順については、以下をご覧ください。
Unattended ロボットの資格情報を HashiCorp Vault (読み取り専用) に保存する
アセットを HashiCorp Vault (読み取り専用) に保存する
約 1 か月前に更新