AutoFs is a program for automatically mounting File System directories on an as-needed basis.
Getting automounter maps from LDAP
AutoFS Client Setup
The Jessie standard kernel ships with autofs module needed for automounting. Install the autofs,autofs-ldap packages and optionally nfs-common.
$ apt-get install autofs autofs-ldap
Autofs mapping entries on LDAP
Actually, the autofs ldap backend supports three (3) different schema styles to store its automountmaps in an ldap. You can verify this by reading /etc/default/autofs #common ldap mappings.
Adding schema to OpenLDAP using cn=config
The schema file provided by the autofs-ldap package /etc/ldap/schema/autofs.schema needs to be converted to ldif format when using the new cn=config backend for openldap (instead of slapd.conf). Create a file /tmp/schema_convert.conf with the following content
include /etc/ldap/schema/core.schema include /etc/ldap/schema/cosine.schema include /etc/ldap/schema/autofs.schema
Create a temporary ldif output directory and run slaptest to generate autofs.ldif
# mkdir /tmp/ldif_output # slaptest -f schema_convert.conf -F /tmp/ldif_output
Modify the resulting file in
dn: cn=autofs,cn=schema,cn=config .. cn: autofs .. <remove all lines from structuralObjectClass: olcSchemaConfig onwards>
The result should look like this: https://launchpadlibrarian.net/55451730/autofs.ldif If you like to, you may copy it over to /etc/ldap/schema/autofs.ldif. Finally add the ldif to your config database:
# ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/ldap/schema/autofs.ldif
Store mappings on the ldap
To store eg. auto.home maps on LDAP you can use the following format (user and home mapping shown):
dn: uid=auser,ou=People,dc=example,dc=com uid: auser uidNumber: 1044 gidNumber: 501 gecos: A. User,,, homeDirectory: /home/auser loginShell: /bin/bash dn: cn=auser,ou=auto.home,dc=example,dc=com objectClass: automount cn: auser automountInformation: -rw,soft,intr,quota homeserver:/export/home/&
Create a file autofs-data.ldif with the above content and add it to the ldap:
# ldapadd -D cn=admin,dc=example,dc=com -W -f autofs-data.ldif
Activate ldap lookup for autofs maps in /etc/nsswitch.conf
automount: files ldap
Configure /etc/default/autofs with proper URI,SEARCHBASE and schema mapping definition. You can also use ldap on a directory basis and maintaining other directories via files as usual:
# auto.master file /home ldap:ou=auto.home,dc=example,dc=com
If not using anonymous binds on the ldap you need to edit /etc/autofs_ldap_auth.conf, too.
See also
CategorySoftware | CategoryNetwork | CategorySystemAdministration