[Network Administration]: Automount maps in LDAP

I’ve got my LDAP server up and running based on the previous post. I’ve got my home directories that I’ve placed on the Synology NAS. What I would like to do is automount them when needed. I’m going to load these from the LDAP server so that I can have just one location for the automount maps.
I’m using the rfc2307bis schema for my LDAP server, so it’s already got all of the automount objectclasses already defined in there. I’m going to use those.
I’m going to be starting with the Ubuntu autofsLDAP doc with some changes for using the objectsclasses automountMap and automount in rfc2307bis. The class automountMap is essentially the map file that would reside on the machine (with automountMapName being the filename), and automount is the entry in the map (automountKey is the key from the map file, and automountInformation is remainder – options and location from the map). Couple of quick notes, the /home map is an indirect map since we’re going to be using wildcards, and in the LDAP entries, the wildcard for the key is “/” and not “*” like the filethe wildcard for the linux autofs can be either “/” or “*”. It appears to handle either character, whereas the OS X autofs supports just the “*” as the wildcard. Also, I’m going to be loading the OS specific home directory from the NAS. So for linux machines, I’m going to mount /Linux off the NAS, and for OS X, I’m going to mount /Darwin off of the NAS. This way the two don’t get overly cluttered with the OS files for both. This is determined using the ${OSNAME} variable in the last DN.
[Update: 1/25/2013]: You can mount the OS specific home directory if you want using the ${OSNAME} variable. I’m using a single directory for linux and OS X and am going to merge the desktops and the shell initialization scripts for both. Also, I’m going to convert to using the Sun names for the maps as auto_master instead of auto.master.
Here is my LDAP tree for the autofs:

## This is the branch for automounter
dn: ou=autofs,ou=daemon,dc=ldap,dc=server,dc=tld
ou: autofs
objectClass: top
objectClass: organizationalUnit

## This defines the auto_master
dn: automountMapName=auto_master,ou=autofs,ou=daemon,dc=ldap,dc=server,dc=tld
objectClass: top
objectClass: automountMap
automountMapName: auto_master
description: master table for automounter

## This is the entry in the master map (auto_master)
dn: automountKey=/home,automountMapName=auto+master,ou=autofs,ou=daemon,dc=ldap,dc=server,dc=tld
objectClass: top
objectClass: automount
automountKey: /home
automountInformation: auto_home
description: indirect map auto_home for account homes

## This defines auto_home
dn: automountMapName=auto_home,ou=autofs,ou=daemon,dc=ldap,dc=server,dc=tld
objectClass: top
objectClass: automountMap
automountMapName: auto_home
description: home directories table for automounter

dn: automountKey=*,automountMapName=auto_home,ou=autofs,ou=daemon,dc=ldap,dc=server,dc=tld
objectClass: top
objectClass: automount
automountKey: *
automountInformation: -fstype=nfs,rw,atime,sync filer-01:/volume1/accounts/&
description: mapping for nfs mount of home dirs

On one machine, I want to have access to all of the exports off of my synology NAS, so for the auto.master map table, I’m not going to use the LDAP entries for that. Also, I have some local mounts that I want to use autofs for. I’m going to be using the file in the filesystem for that instead of the directory map. I’ve modified the auto.master file from

+auto.master

to look like

# Don’t look for the table in the directory server
#+auto_master
#use the builtin map to load all the exports from the nfs hosts.
/net -hosts
#direct maps on local device
/- auto.direct
#indirect maps for home directories
/home auto.home

[Update: 2/16/2014]: You don’t actually have to do this. If the automounter is properly setup to be well behaved (for example in /etc/nsswitch we have the automount order as “files ldap”), then it will automatically look for a local /etc/auto_home file first, and then in the LDAP directory. In this case, since my auto_master map already has an entry that is “/home auto_home” in it, I don’t actually have to call out the /home indirect map in my /etc/auto_master file. I can just query the ldap entry, which will return “auto_home” as the location of the /home indirect map location, and the system will look in the local filesystem first. My local /etc/auto_home file still needs to make the call to lookup the auto_home map from the directory however.

This will load the local /etc/auto.home file for the home dirs. This is what I have for the auto.home

# Load from auto.home map in directory
+auto_home
# Local host directories mounted
* :/export/home/&

What this file does is first look in the ldap directory for the auto_home table,and then loads any local home mounts from /export/home. You have to enable ldap in /etc/nsswitch.conf

automount: files ldap

Note, the order. It first looks in the filesystem, and then in the directory. I want to read the local auto.master file instead of the directory server entry. The MASTER_MAP_NAME in the /etc/default/autofs file shouldn’t contain the DN of the auto_master table but rather point at the file

MASTER_MAP_NAME="/etc/auto.master"

The remainder of the LDAP variables in /etc/default/autofs should be configured properly with the server information, the search base, and the following to define the schema that we’re using

MAP_OBJECT_CLASS=”automountMap”
ENTRY_OBJECT_CLASS=”automount”
MAP_ATTRIBUTE=”automountMapName”
ENTRY_ATTRIBUTE=”automountKey”
VALUE_ATTRIBUTE=”automountInformation”

Advertisements

One thought on “[Network Administration]: Automount maps in LDAP

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s