Background
We often receive the following question from customers:
I have software with limited licenses that I only want certain users to have access to. How do I make sure only those users can load the modules for that software?
This article explains how to accomplish this.
Steps
1. Place the module or modules in question in a different directory from the other modules.
- For example, you can move the information for a module to
/cm/shared/secret
.
2. Modify the /etc/profile.d/modules.sh
script to have logic that looks for a specific user ID, and if the ID matches, it appends the “secret” directory to the MODULEPATH_TMP variable.
- In this example
/cm/shared/secret
was used, and we are searching for the usercmtest
.- You can specify any path that is generally available to users.
- You can specify any user string.
- The beginning of that script has an additional
if
statement nested in theif
statement that matches non-root users:if [ "$ENABLE_LMOD" == "0" ];then
if [ `id -u` -ne 0 ]; then
MODULEPATH_TMP=/cm/local/modulefiles:/cm/shared/modulefiles
PATH_TMP=/sbin:/usr/sbin:/cm/local/apps/environment-modules/4.0.0/bin
if [ $USER == 'cmtest' ] ; then
MODULEPATH_TMP=$MODULEPATH_TMP:/cm/shared/secret
fi
else
...
3. When logging in as the cmtest
user, we can see the module in /cm/shared/secret
when running module avail
.
4. If you want those modules loaded by default for the user, you can modify their .bashrc
, loading the module when they log in.