30.3. Ansible を使用して委譲ルールに特定の属性を含める
以下の手順では、Ansible Playbook を使用して、委譲ルールに特定の設定を指定する方法を説明します。この Playbook を使用して、以前に作成した委譲ロールを変更できます。この例では、basic manager attributes 委譲ルールに departmentnumber メンバー属性のみが含まれるようにします。
前提条件
コントロールノード:
- Ansible バージョン 2.15 以降を使用している。
-
ansible-freeipaパッケージがインストールされている。 - ~/MyPlaybooks/ ディレクトリーに、IdM サーバーの完全修飾ドメイン名 (FQDN) を使用して Ansible インベントリーファイル が作成されている (この例の場合)。
-
secret.yml Ansible vault に
ipaadmin_passwordが保存されており、secret.yml ファイルを保護するパスワードを格納しているファイルにアクセスできる (この例の場合)。
-
ターゲットノード (
freeipa.ansible_freeipaモジュールが実行されるノード) が、IdM クライアント、サーバー、またはレプリカとして IdM ドメインに含まれている。 - basic manager attributes 委譲ルールが IdM に存在する。
手順
~/MyPlaybooks/ ディレクトリーに移動します。
$ cd ~/MyPlaybooks//usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/delegation/ディレクトリーにあるdelegation-member-present.ymlファイルのコピーを作成します。$ cp /usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/delegation/delegation-member-present.yml delegation-member-present-copy.yml-
Ansible Playbook ファイル
delegation-member-present-copy.ymlを開きます。 freeipa.ansible_freeipa.ipadelegationタスクセクションで次の変数を設定して、ファイルを変更します。-
name変数は、変更する委譲ルールの名前に設定します。 -
attribute変数はdepartmentnumberに設定します。 -
action変数はmemberに設定します。
以下は、今回の例で使用するように変更した Ansible Playbook ファイルです。
--- - name: Delegation member present hosts: ipaserver vars_files: - /home/user_name/MyPlaybooks/secret.yml tasks: - name: Ensure delegation "basic manager attributes" member attribute departmentnumber is present freeipa.ansible_freeipa.ipadelegation: ipaadmin_password: "{{ ipaadmin_password }}" name: "basic manager attributes" attribute: - departmentnumber action: member-
ファイルを保存します。
FreeIPA Ansible コレクション内の変数とサンプル Playbook の詳細は、コントロールノードの
/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/README-delegation.mdファイルと/usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/ipadelegationディレクトリーを参照してください。Ansible Playbook を実行します。Playbook ファイル、secret.yml ファイルを保護するパスワードを格納するファイル、およびインベントリーファイルを指定します。
$ ansible-playbook --vault-password-file=password_file -v -i ~/MyPlaybooks/inventory delegation-member-present-copy.yml