33.3. Ansible を使用した IdM での自動マウントの場所、マップ、およびキーの設定
Identity Management (IdM) のシステム管理者は、IdM で自動マウントの場所とマップを設定できます。これにより、指定した場所の IdM ユーザーが、ホストの特定のマウントポイントに移動して、NFS サーバーがエクスポートした共有にアクセスできるようになります。エクスポートされた NFS サーバーディレクトリーとマウントポイントの両方が、マップで指定されます。LDAP 用語では、ロケーションはそのようなマップエントリーのコンテナーです。
この例では、Ansible を使用して、raleigh の場所と、IdM クライアント上の /devel/project マウントポイントに nfs-server.idm.example.com:/exports/project 共有を読み取り/書き込みディレクトリーとしてマウントするマップを設定する方法を説明します。
前提条件
コントロールノード:
- Ansible バージョン 2.15 以降を使用している。
-
freeipa.ansible_freeipaコレクションがインストールされている。 - ~/MyPlaybooks/ ディレクトリーに、IdM サーバーの完全修飾ドメイン名 (FQDN) を使用して Ansible インベントリーファイル が作成されている (この例の場合)。
-
secret.yml Ansible vault に
ipaadmin_passwordが保存されており、secret.yml ファイルを保護するパスワードを格納しているファイルにアクセスできる (この例の場合)。
-
ターゲットノード (
freeipa.ansible_freeipaモジュールが実行されるノード) が、IdM クライアント、サーバー、またはレプリカとして IdM ドメインに含まれている。
手順
Ansible コントロールノードで、~/MyPlaybooks/ ディレクトリーに移動します。
$ cd ~/MyPlaybooks//usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/automount/ディレクトリーにあるautomount-location-present.ymlAnsible Playbook ファイルをコピーします。$ cp /usr/share/ansible/collections/ansible_collections/freeipa/ansible_freeipa/playbooks/automount/automount-location-present.yml automount-location-map-and-key-present.yml-
automount-location-map-and-key-present.ymlファイルを編集用に開きます。 freeipa.ansible_freeipa.ipaautomountlocationタスクセクションで次の変数を設定して、ファイルを変更します。-
ipaadmin_password変数の値が secret.yml Ansible vault ファイルで定義されていることを示します。 -
name変数を raleigh に設定します。 state変数はpresentに設定されていることを確認します。以下は、今回の例で使用するように変更した Ansible Playbook ファイルです。
--- - name: Automount location present example hosts: ipaserver vars_files: - /home/user_name/MyPlaybooks/secret.yml tasks: - name: Ensure automount location is present freeipa.ansible_freeipa.ipaautomountlocation: ipaadmin_password: "{{ ipaadmin_password }}" name: raleigh state: present-
automount-location-map-and-key-present.ymlファイルの編集を続けます。tasksセクションで、自動マウントマップが存在することを確認するタスクを追加します。[...] vars_files: - /home/user_name/MyPlaybooks/secret.yml tasks: [...] - name: ensure map named auto.devel in location raleigh is created freeipa.ansible_freeipa.ipaautomountmap: ipaadmin_password: "{{ ipaadmin_password }}" name: auto.devel location: raleigh state: present別のタスクを追加して、マウントポイントと NFS サーバー情報をマップに追加します。
[...] vars_files: - /home/user_name/MyPlaybooks/secret.yml tasks: [...] - name: ensure automount key /devel/project is present freeipa.ansible_freeipa.ipaautomountkey: ipaadmin_password: "{{ ipaadmin_password }}" location: raleigh mapname: auto.devel key: /devel/project info: nfs-server.idm.example.com:/exports/project state: presentauto.devel が auto.master に接続されていることを確認する別のタスクを追加します。
[...] vars_files: - /home/user_name/MyPlaybooks/secret.yml tasks: [...] - name: Ensure auto.devel is connected in auto.master: freeipa.ansible_freeipa.ipaautomountkey: ipaadmin_password: "{{ ipaadmin_password }}" location: raleigh mapname: auto.map key: /devel info: auto.devel state: present
- ファイルを保存します。
Ansible Playbook を実行し、Playbook とインベントリーファイルを指定します。
$ ansible-playbook --vault-password-file=password_file -v -i inventory automount-location-map-and-key-present.yml