#author("2024-10-04T16:05:12+00:00","default:sysosa","sysosa") &color(red){改定中}; &size(10){過去記事: [[samba4/ホームディレクトリ/NFS設定/autofs]]}; #author("2024-10-04T16:05:20+00:00","default:sysosa","sysosa") ストレージサーバが1台なら単純にstaticでNFS共有すればいい だが、複数台になるとnisのauto.master/auto.homeのような機構が必要となる このauto.master/auto.homeのマップ情報をsamba-adに載せて、sssd経由で利用してみる &size(10){参照:}; &size(10){[[https://wiki.samba.org/index.php/Samba_AD_Schema_Extenstions>+https://wiki.samba.org/index.php/Samba_AD_Schema_Extenstions]]}; &size(10){[[http://linuxcostablanca.blogspot.com.es/2013/09/samba4-autofs-with-rfc2307bis-schema.html>+http://linuxcostablanca.blogspot.com.es/2013/09/samba4-autofs-with-rfc2307bis-schema.html]]}; &size(10){[[https://linuxcostablanca.blogspot.com/2013/09/samba4-autofs-with-rfc2307bis-schema.html>+https://linuxcostablanca.blogspot.com/2013/09/samba4-autofs-with-rfc2307bis-schema.html]]}; ***samba-ad のスキーマを拡張 [#xef96318] 拡張する前にsamba-adを停止して、バックアップを取得する。&size(10){失敗した場合の保険}; あとデータベースに問題がないかをチェックして、あるなら修正しておく #code(nonumber){{ [root@ad ~]# systemctl stop samba [root@ad ~]# (cd /opt && tar cvfz samba-241002.tar.gz ./samba) [root@ad ~]# samba-tool dbcheck <--エラーがあるなら「samba-tool dbcheck --fix --yes」 [root@ad ~]# samba-tool dbcheck --cross-ncs <--エラーがあるなら「samba-tool dbcheck --cross-ncs --fix --yes」 }} &color(white,blue){留意}; &size(10){DCが複数あるなら、fsmoのSchemaMasterRoleを持っているマスターノードなマシンで作業する。作業中、他のDCは止めたほうがいいみたい}; まずは下記3つの属性(Attribute Types)を追加する automountMapName automountKey automountInformation これらのスキーマ追加は&color(magenta){ldbmodify};コマンドで [[attr.ldif>samba/autofs/ldif#scfa01fe]]ファイルを流し込む #code(nonumber){{ [root@ad ~]# ldbmodify -H /opt/samba/private/sam.ldb ldif/attr.ldif --option="dsdb:schema update allowed"=true Modified 3 records successfully }} 次に、下記2つのオブジェクトクラスを加える automountMap automount これも同じく&color(magenta){ldbmodify};コマンドで、今度は[[class.ldif>samba/autofs/ldif#z2e09703]]ファイルを流し込む #code(nonumber){{ [root@ad ~]# ldbmodify -H /opt/samba/private/sam.ldb ldif/class.ldif --option="dsdb:schema update allowed"=true Modified 2 records successfully }} 成功したら samba を再起動させます &color(white,blue){留意}; &size(10){DCが複数あるなら、マスター稼動後に他のDCも稼動させる}; #code(nonumber){{ [root@ad ~]# systemctl start samba }} ***追加スキーマの確認 [#efd81596] 「LdapAdmin.exe」を使って、DCにアクセスして、「Tools」->「Schema..」を選ぶ。 表示された「Schema Viewer」で、左ペインを展開して 「&color(darkorchid){Attribute Type};」に「automountInformation」「automountKey」「automountMapName」を確認します &ref(2024y10m04d_193733489.png,nolink); 「&color(green){Object Classes};」に「automount」「automountMap」を確認します。 &ref(2024y10m04d_193815390.png,nolink); &color(red){*};複数DCで運用している場合、暫くすると伝播して同じスキーマが表示されます。 ***autofsの枠組み登録 [#zff71a9a] ここではNISで言うところの「auto.master/auto.home」マップをADの組織単位(OU)「automount」の配下に入れることにします。 作成は再び&color(magenta){ldbmodify};コマンドで行います。 まず、組織単位(OU)「automount」の作成。[[automount.ldif>samba/autofs/ldif#gf938261]] #code(nonumber){{ [root@ad ~]# ldbmodify -H /opt/samba/private/sam.ldb ldif/automount.ldif Modified 1 records successfully }} &color(red){*};&size(10){sambaは稼働中でもOK}; 次に「auto.master」と「auto.home」を登録します [[auto.master.ldif>samba/autofs/ldif#pe0cf734]]、 [[auto.home.ldif>samba/autofs/ldif#v956c16d]] #code(nonumber){{ [root@ad ~]# ldbmodify -H /opt/samba/private/sam.ldb ldif/auto.master.ldif Modified 1 records successfully [root@ad ~]# ldbmodify -H /opt/samba/private/sam.ldb ldif/auto.home.ldif Modified 1 records successfully }} この後、「Active Directory ユーザーとコンピューター」を開くと追加されたことが分かる &ref(2024y10m04d_195503164.png,nolink); ***autofsのデータ登録 [#pe1d568a] 値を入れる枠が出来たので次は値を入れます まず、auto.master. NISで言うところの/etc/auto.masterが #code(nonumber){{ /- auto.home --timeout=60 }} なら auto.master.value.ldif を下記のように作り #code(nonumber){{ dn: CN=/-,ou=auto.master,OU=automount,DC=chaperone,DC=jp objectClass: top objectClass: automount objectClass: container cn: /- name: /- automountKey: /- automountInformation: auto.home --timeout=60 }} ldbmodify コマンドで下記のようにして反映させます #code(nonumber){{ [root@ad ~]# ldbmodify -H /opt/samba/private/sam.ldb ldif/auto.master.value.ldif }} 次に、auto.homeの登録であるが、これもNISで言うところの #code(nonumber){{ /home -rw nfs:/home /apps -rw nfs:/apps }} であるなら、auto.home.value.ldif として #code(nonumber){{ dn: CN=/home,ou=auto.home,OU=automount,DC=chaperone,DC=jp objectClass: top objectClass: automount objectClass: container cn: /home name: /home automountKey: /home automountInformation: -rw nfs:/home dn: CN=/apps,ou=auto.home,OU=automount,DC=chaperone,DC=jp objectClass: top objectClass: automount objectClass: container cn: /apps name: /apps automountKey: /apps automountInformation: -rw nfs:/apps }} を用意して #code(nonumber){{ [root@ad ~]# ldbmodify -H /opt/samba/private/sam.ldb ldif/auto.home.value.ldif }} と実行する。 これら登録したデータは「Active Directory ユーザーとコンピューター」では確認できません。「ADSIエディター」で確認します。 &ref(2024y10m04d_222349583.png,nolink); ***autofs データを利用する [#y78d513c] 参照[[LDAP/autofs]] この登録したautofsデータを実際のクライアントで使用してみる [[samba/Linux参加#ib38591b]]で示したようにsamba-adへの参加方法はいくつかある #code(nonumber){{ samba-ad +--- sssd --> /etc/sss/sssd.conf を修正 sssd を起動 | +-- id_provider = ad | +-- id_provider = ldap <-- samba-adをLDAPサーバと見做す | +--- winbind --> /etc/samba/smb.confを修正 winbindd を起動 +-- backend:ad <-- rfc2307が使える +-- backend:rid <-- rfc2307なし }} samba-adにスキーマ拡張してautofsを扱うようしたが、実態はldapのそれと同じ. sssd系,winbind系共にsssdでカバーした方がいいかな. staticでするなら従来通りの /etc/auto.(master|host) を作る事になります. 具体的には -sssd.conf ADのアカウント情報を引き出していたが、autofs情報も引き出すように修正を加える -nsswitch.conf automountの参照先をsssとする の2か所を調整します。 まずsssd.confから、パッケージ「libsss_autofs」をインストールして、sssd.confを修正します #code(nonumber){{ [root@samba-client ~]# dnf install libsss_autofs autofs nfs-utils autofs sssd-tools [root@samba-client ~]# vi /etc/sssd/sssd.conf [sssd] services = nss, pam, autofs config_file_version = 2 domains = default : : [autofs] autofs_provider = ldap ldap_autofs_search_base = OU=automount,DC=chaperone,DC=jp ldap_autofs_map_object_class = automountMap ldap_autofs_entry_object_class = automount ldap_autofs_map_name = automountMapName ldap_autofs_entry_key = automountKey ldap_autofs_entry_value = automountInformation [root@samba-client ~]# systemctl restart sssd }} 注意 [[LDAP/autofs]] と違ってます。理由は使っているスキーマの違いです. [[https://linuxcostablanca.blogspot.com/2013/09/samba4-autofs-with-rfc2307bis-schema.html>+https://linuxcostablanca.blogspot.com/2013/09/samba4-autofs-with-rfc2307bis-schema.html]]の票の「RFC2307bis」です. [[LDAP/autofs]]は「NIS」で行ってます 次に/etc/nsswitch.confの「automount:」項目を修正して「sss」のみにします #code(diff,nonumber){{ [root@samba-client ~]# vi /etc/nsswitch.conf : netgroup: sss files automount: sss services: sss files : [root@samba-client ~]# [root@samba-client ~]# systemctl restart sssd [root@samba-client ~]# systemctl restart autofs }} これでautofsの情報は samba-ad から取得して実行されます あとこれはkrb対応にしていれば「sec=krb5」とか使える.