0

I've got a couple of CentOS 7 client machines authenticating against OpenLDAP right now. The next step is to get autofs working. Which I have, but my map loads all users at once. I'd like to avoid this. Assume I have two users

user1
user2

They both have a NFS share and I want to map them using autofs.

/home -fstype=nfs,rw domain.com:/homes

Works, but I get everyone. I thought that I could use variables or wildcards to achieve this. So I attempted the following map

/home/${USER} -fstype=nfs,rw  domain.com:/homes/${USER}
/home/${USER}/Music -fstype=nfs,rw  domain.com:/homes/${USER}/&

But it would appear that my variables aren't liked by CentOS. I've tried

/home/${USER} -fstype=nfs,rw  domain.com:/homes/${USER}
/home/$USER -fstype=nfs,rw  domain.com:/homes/$USER
/home/* -fstype=nfs,rw  domain.com:/homes

Could someone please tell me what I'm missing?

Thank you!

Edited for logs

Dec  8 22:22:13 workstation automount[1897]: setautomntent: lookup(sss): setautomntent: No such file or directory
Dec  8 22:22:13 workstation automount[1897]: do_mount_autofs_direct: failed to create mount directory /home/${USER}
  • 1
    Use something like '* fileserver.example.com:/export/home/&' – nkms Dec 9 '15 at 9:08
1

From the autofs man page:

Map Key Substitution

An & character in the location is expanded to the value of the key field that matched the line (which probably only makes sense together with a wildcard key).

Wildcard Key

A map key of * denotes a wild-card entry. This entry is consulted if the specified key does not exist in the map. A typical wild-card entry looks like this:
*    server:/export/home/&
The special character '&' will be replaced by the provided key. So, in the example above, a lookup for the key 'foo' would yield a mount of server:/export/home/foo.

Am typing from my phone so apologies for the formatting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.