21.4. Ansible を使用してセルフサービスルールに特定の属性を含める
以下の手順では、Ansible Playbook を使用して、既存のセルフサービスルールに特定の設定を追加する方法を説明します。この例では、Users can manage their own name details セルフサービスルールに surname メンバー属性を含めます。
前提条件
コントロールノードの場合:
- Ansible バージョン 2.13 以降を使用している。
-
ansible-freeipaパッケージをインストールしている。 - この例では、~/MyPlaybooks/ ディレクトリーに、IdM サーバーの完全修飾ドメイン名 (FQDN) を使用して Ansible インベントリーファイル を作成したことを前提としている。
-
この例では、secret.yml Ansible Vault に
ipaadmin_passwordが保存されていることを前提としています。
-
ターゲットノード (
ansible-freeipaモジュールが実行されるノード) が、IdM クライアント、サーバー、またはレプリカとして IdM ドメインに含まれている。 - Users can manage their own name details セルフサービスルールが IdM に存在する。
手順
~/MyPlaybooks/ ディレクトリーに移動します。
$ cd ~/MyPlaybooks//usr/share/doc/ansible-freeipa/playbooks/selfservice/ディレクトリーにあるselfservice-member-present.ymlファイルのコピーを作成します。$ cp /usr/share/doc/ansible-freeipa/playbooks/selfservice/selfservice-member-present.yml selfservice-member-present-copy.yml-
Ansible Playbook ファイル (
selfservice-member-present-copy.yml) を開きます。 ipaselfserviceタスクセクションに以下の変数を設定してファイルを調整します。-
ipaadmin_password変数は IdM 管理者のパスワードに設定します。 -
name変数は、変更するセルフサービスルールの名前に設定します。 -
attribute変数はsurnameに設定します。 -
action変数はmemberに設定します。
以下は、今回の例で使用するように変更した Ansible Playbook ファイルです。
--- - name: Self-service member present hosts: ipaserver vars_files: - /home/user_name/MyPlaybooks/secret.yml tasks: - name: Ensure selfservice "Users can manage their own name details" member attribute surname is present ipaselfservice: ipaadmin_password: "{{ ipaadmin_password }}" name: "Users can manage their own name details" attribute: - surname action: member-
- ファイルを保存します。
Ansible Playbook を実行します。Playbook ファイル、secret.yml ファイルを保護するパスワードを格納するファイル、およびインベントリーファイルを指定します。
$ ansible-playbook --vault-password-file=password_file -v -i inventory selfservice-member-present-copy.yml