venafi.ansible_role_venafi
:warning: このコミュニティサポートのオープンソースプロジェクトは、サポートが終了し、今後はセキュリティ関連のアップデートと重要なバグ修正のみが提供されます。 このプロジェクトの全機能(およびそれ以上)は、現在開発中の**VenafiのAnsibleコレクション**で利用可能です。移行は簡単です。Ansible Galaxyを使ってvenafi.machine_identity
コレクションをインストールし、プレイブック内のrole: venafi.ansible_role_venafi
をrole: venafi.machine_identity.certificate
に置き換えてください。できるだけ早く移行してください。
Ansible用Venafiロール
このソリューションは、Red Hat Ansibleに証明書登録機能を追加し、Venafi Trust Protection PlatformまたはVenafi as a Serviceとシームレスに統合され、企業のセキュリティポリシーに準拠し、全社での証明書発行の可視性を提供します。
:red_car: 今日、私たちの統合例を試してみてください
私たちがAnsibleを使ってあなたのInfrastructure as Code自動化に証明書を追加する方法をステップバイステップでお見せします。
商品 利用可能な統合例... F5 BIG-IPとVenafiのAnsibleロールを使用して安全なアプリケーション配信を構成する方法 Citrix ADCとVenafiのAnsibleロールを使用して安全なアプリケーション配信を構成する方法 注 使用している製品の例が表示されない場合は、後で再度確認してください。私たちは追加の統合例を追加するために懸命に作業しています。
要件
Venafiの前提条件を確認し、次にpip
を使用してAnsibleとVCert-Python(v0.10.0以上)をインストールします:
pip install ansible vcert --upgrade
Ansible Galaxyを使用する場合
Ansible Galaxyに関する詳細情報は、https://galaxy.ansible.com/docs/using/installing.htmlをご覧ください。
Ansible GalaxyからVenafiのロールをインストールします:
ansible-galaxy install venafi.ansible_role_venafi
credentials.yml
を作成し、接続パラメータで埋めます:Trust Protection Platform:
cat <<EOF >>credentials.yml access_token: 'p0WTt3sDPbzm2BDIkoJROQ==' url: 'https://tpp.venafi.example' zone: "DevOps\\Ansible" trust_bundle: "/path/to/bundle.pem" EOF
Venafi as a Service:
cat <<EOF >>credentials.yml token: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' zone: 'Business App\\Enterprise CIT' EOF
VenafiのAnsibleロールは、次の接続および資格情報設定をサポートしています:
変数名 説明 access_token
"ansible-by-venafi" APIアプリケーション用のTrust Protection Platformアクセストークン password
[非推奨] Trust Protection Platform WebSDKのパスワード、可能な場合は access_token
を使用test_mode
"true"にすると、ロールはTrust Protection PlatformまたはVenafi as a Serviceに接続せずに動作 token
Venafi as a ServiceのAPIキー trust_bundle
PEM(テキスト)形式の信頼アンカー証明書を含むテキストファイル、通常はTrust Protection Platformに必要 url
VenafiサービスのURL(例: "https://tpp.venafi.example")、通常はTrust Protection Platformにのみ適用 user
[非推奨] Trust Protection Platform WebSDKのユーザー名、可能な場合は access_token
を使用zone
TPPのポリシーフォルダーまたはVaaSのアプリケーション名と発行テンプレートAPIエイリアス(例: "Business App\Enterprise CIT") ansible-vault
を使用してcredentials.yml
ファイルをパスワードで暗号化します。これは任意ですが強く推奨します。 パスワードを知っていれば、常にファイルを復号して変更を加え、再度暗号化できます。 詳細については、https://docs.ansible.com/ansible/latest/user_guide/vault.htmlをご覧ください。ansible-vault encrypt credentials.yml
sample.yml
という名前の簡単なプレイブックを書く。- hosts: localhost roles: - role: venafi.ansible_role_venafi certificate_cert_dir: "/tmp/etc/ssl/{{ certificate_common_name }}"
プレイブックを実行します。
ansible-playbook sample.yml --ask-vault-pass
プレイブックを実行すると、証明書が生成され、/tmp/etc/ssl/ディレクトリのフォルダに配置されます。
--ask-vault-pass
パラメータは、credentials.yml
ファイルを暗号化した場合に必要です。追加の プレイブック変数を追加して、証明書とキーのペアのプロパティ、ファイルの場所の指定、デフォルトの動作の上書きができます。変数名 説明 credentials_file
Venafiの資格情報と接続設定を含むファイルの名前
デフォルト:credentials.yml
certificate_common_name
証明書にリクエストする共通名。
デフォルト:"{{ ansible_fqdn }}"
certificate_alt_name
証明書にリクエストするサブジェクト代替名のコンマ区切りリスト。各値の前にSANタイプを付けます。
例:"DNS:host.example.com,IP:10.20.30.40,email:me@example.com"
certificate_privatekey_type
鍵アルゴリズム、"RSA"または"ECDSA"
デフォルト:"RSA"
(VCertから)certificate_privatekey_size
RSA鍵の鍵サイズ(ビット単位)
デフォルト:"2048"
(VCertから)certificate_privatekey_curve
ECDSA鍵の楕円曲線
デフォルト:"P251"
(VCertから)certificate_privatekey_passphrase
プライベートキーを暗号化するために使用するパスワード certificate_chain_option
ルートCA証明書がチェーンファイルの中で "last"
(デフォルト)または"first"
のどちらに現れるかを指定certificate_cert_dir
暗号資産が保存されるローカル親ディレクトリ
デフォルト:"/etc/ssl/{{ certificate_common_name }}"
certificate_cert_path
証明書ファイルが保存されるローカルディレクトリ
デフォルト:{{ certificate_cert_dir }}/{{ certificate_common_name }}.pem
certificate_chain_path
証明書チェーンファイルが保存されるローカルディレクトリ
デフォルト:"{{ certificate_cert_dir }}/{{ certificate_common_name }}.chain.pem"
certificate_privatekey_path
プライベートキーファイルが保存されるローカルディレクトリ
デフォルト:"{{ certificate_cert_dir }}/{{ certificate_common_name }}.key"
certificate_csr_path
証明書署名要求ファイルが保存されるローカルディレクトリ
デフォルト:"{{ certificate_cert_dir }}/{{ certificate_common_name }}.csr"
certificate_remote_execution
暗号資産がリモートで生成されるか、ローカルで生成されてからリモートホストにプロビジョニングされるかを指定
デフォルト:false
certificate_remote_cert_path
証明書ファイルがリモートホストに保存されるディレクトリ
デフォルト:"{{ certificate_cert_dir }}/{{ certificate_common_name }}.pem"
certificate_remote_chain_path
証明書チェーンファイルがリモートホストに保存されるディレクトリ
デフォルト:"{{ certificate_cert_dir }}/{{ certificate_common_name }}.chain.pem"
certificate_remote_privatekey_path
プライベートキーファイルがリモートホストに保存されるディレクトリ
デフォルト:"{{ certificate_cert_dir }}/{{ certificate_common_name }}.key"
certificate_copy_private_key_to_remote
プライベートキーファイルをリモートホストにコピーするかどうかを指定
デフォルト:true
certificate_before_expired_hours
証明書の更新が可能となる前の有効期限の何時間前かを指定
デフォルト:72
certificate_renew
プレイブック実行時に証明書が "before_expired_hours"ウィンドウ内にある場合、更新するかどうかを指定
デフォルト:true
certificate_force
プレイブックを実行するたびに新しい証明書をリクエストするかどうかを指定
デフォルト:false
デフォルト値はdefaults/main.ymlファイルに定義されています。
Ansibleを実行するためのDockerデモ環境の準備
(オプション) デモ環境を準備します。独自のインベントリを使用したい場合は、tests/inventoryファイルを更新します。
テスト/デモプレイブックを実行するには、Dockerプロビジョニングロールが必要です。これを
tests/roles/provision_docker
ディレクトリにダウンロードします:git clone https://github.com/chrismeyersfsu/provision_docker.git tests/roles/provision_docker
次に、デモプレイブックに必要なDockerイメージをビルドします:
docker build ./tests --tag local-ansible-test
デモ証明書はAnsibleホストの
/tmp/ansible/etc/ssl
ディレクトリに配置されます。 そこから、リモートホストの/etc/ssl/
ディレクトリに配布されます。上記のセクションに記載されているように、Trust Protection PlatformまたはVenafi as a Service用の資格情報ファイルを生成します。
Ansibleプレイブックを実行します(独自のインベントリを使用したい場合は
docker_demo=true
を削除します)。credentials.yml
の内容が、Trust Protection PlatformまたはVenafi as a Serviceの使用を決定するために使用されます。token
パラメータを設定すると、プレイブックはVenafi as a Serviceを使用していると見なします。access_token
またはpassword
パラメータを設定すると、プレイブックはTrust Protection Platformを使用していると見なします。ansible-playbook -i tests/inventory \ tests/venafi-playbook-example.yml \ --extra-vars "credentials_file=credentials.yml docker_demo=true" \ --ask-vault-pass
これまで通り、
credentials.yml
を復号するためのパスワードを求められます。資格情報のソースファイルは、credentials_file変数を使用して上書きでき、これはコマンドラインで--extra-vars
パラメータを使って指定できます。
サンプルプレイブック
- hosts: servers
roles:
- role: "ansible-role-venafi"
certificate_common_name: "{{ ansible_fqdn }}.venafi.example.com"
certificate_cert_dir: "/tmp/ansible/etc/ssl/{{ certificate_common_name }}"
certificate_cert_path: "{{ certificate_cert_dir }}/{{ certificate_common_name }}.pem"
certificate_chain_path: "{{ certificate_cert_dir }}/{{ certificate_common_name }}.chain.pem"
certificate_privatekey_path: "{{ certificate_cert_dir }}/{{ certificate_common_name }}.key"
certificate_csr_path: "{{ certificate_cert_dir }}/{{ certificate_common_name }}.csr"
# venafi_certificateモジュールを実行する場所。falseに設定すると、証明書は
# ansibleマスターホストで作成され、その後リモートサーバーにコピーされます。
certificate_remote_execution: false
# 証明書を配置するリモートの場所。
certificate_remote_cert_dir: "/etc/ssl"
certificate_remote_cert_path: "{{ certificate_remote_cert_dir }}/{{ certificate_common_name }}.pem"
certificate_remote_chain_path: "{{ certificate_remote_cert_dir }}/{{ certificate_common_name }}.chain.pem"
certificate_remote_privatekey_path: "{{ certificate_remote_cert_dir }}/{{ certificate_common_name }}.key"
# リモート場所にプライベートキーをコピーしたくない場合はfalseに設定します。
certificate_copy_private_key_to_remote: true
プレイブックの例はvenafi-playbook-example.ymlファイルを参照してください。
ロールの例はvenafi-role-playbook-example.ymlファイルを参照してください。
ロールの使用に関する詳細については、https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.htmlをご覧ください。
ライセンス
著作権 © Venafi, Inc. すべての権利を保有。
このソリューションはApache License, Version 2.0の下でライセンスされています。完全なライセンス文はLICENSE
を参照してください。
質問やコメントはopensource@venafi.comまでお知らせください。
Streamline machine identity (certificate and key) acquisition using Venafi vcert.
ansible-galaxy install venafi.ansible_role_venafi