HOWTO autofs via OpenLDAP on RHEL5, Fedora Core 12
Please provide feedback in the comments, specially about other versions/distributions.
Server (hostname server.example.com)
-
# yum install openldap-servers openldap-clients
- NFS:
# mkdir -p /export/foo; touch /export/foo/demofile # echo "/export/foo *(ro)" >> /etc/exports # chkconfig nfs on; service nfs start
- LDAP:
- Modify /etc/openldap/slapd.conf:
- Add line 8:
include /etc/openldap/schema/redhat/autofs.schema
- Modify suffix and rootdn by replacing
dc=my-domain,dc=combydc=example,dc=com - Define a rootpw by uncommenting:
rootpw secret
- Give read-only access to everyone by adding:
access to * by * read
- Add line 8:
# chkconfig ldap on; service ldap start- Populate the directory:
# ldapadd -c -x -D cn=Manager,dc=example,dc=com -w secret << EOF dn: dc=example,dc=com dc: example objectClass: top objectClass: domain objectClass: domainRelatedObject associatedDomain: example.com dn: ou=auto.master, dc=example, dc=com objectClass: top objectClass: automountMap ou: auto.master dn: cn=/home, ou=auto.master, dc=example, dc=com objectClass: automount cn: /home automountInformation: ldap server.example.com:ou=auto.home,dc=example,dc=com dn: ou=auto.home, dc=example, dc=com objectClass: top objectClass: automountMap ou: auto.home dn: cn=foo, ou=auto.home, dc=example, dc=com objectClass: automount cn: foo automountInformation: -fstype=nfs,hard,intr,nodev,nosuid server.example.com:/export/foo EOF
- Modify /etc/openldap/slapd.conf:
Client
- Check connectivity & name resolution:
# ping server.example.com
-
# yum install autofs
- Add ldap to the automount line in /etc/nsswitch.conf:
automount: files ldap
- In /etc/sysconfig/autofs:
- Uncomment:
MAP_OBJECT_CLASS="automountMap" ENTRY_OBJECT_CLASS="automount" MAP_ATTRIBUTE="automountMapName" ENTRY_ATTRIBUTE="automountKey" VALUE_ATTRIBUTE="automountInformation"
- Set those variables:
BROWSE_MODE="yes" LDAP_URI="ldap://server.example.com" SEARCH_BASE="dc=example,dc=com"
- Uncomment:
-
# service autofs start
- Final check:
# ls -l /home/foo/demofile
