Debian Codegraph @

doc/source/cookbook/ensure-user-qualify-modules.rst

raw
1 .. _ensure-user-specify-module-version:
2
3 Ensure user fully qualify the modules they use
4 ==============================================
5
6 When managing a vast software catalog accessible by multiple users, it is
7 often desired that these users understand exactly what are the software they
8 enable in their environment. This is especially important when new software
9 versions are introduced in the catalog.
10
11 On a regular Modules installation, if multiple versions of a given module are
12 available, latest version is selected when user load this software module by
13 specifying its generic name (``module load software``). So when a new version
14 is installed for software, users automatically end up with this new version
15 enabled in their environment.
16
17 Depending on software, a precise version control may be required to avoid
18 issues. In this case the implicit default version selection done by Modules
19 is not desired. This recipe describe the way to handle this kind of
20 situation.
21
22 Implementation
23 --------------
24
25 Starting version 4.3 of Modules, a new option called
26 :mconfig:`implicit_default` is introduced. When enabled (which means
27 configuration option is set to 1) if a module is specified by its generic name
28 an implicit default is automatically defined (latest version) if no explicit
29 default is defined. When ``implicit_default`` configuration option is disabled
30 (when set to 0), no implicit default is computed and an error is returned to
31 user in case module has been specified by its generic name but no default
32 version has been set.
33
34 So to ensure user fully qualify the modules they use, this
35 ``implicit_default`` configuration option should be disabled. It could be
36 achieved by setting the option in the :file:`initrc` file installed in the
37 configuration directory (or in the ``modulerc`` file installed in the
38 initialization script directory if this location is preferred).
39
40 .. literalinclude:: ../../example/ensure-user-qualify-modules/initrc
41 :language: tcl
42 :caption: initrc
43
44 It may be desired to lock this option, to ensure users do not alter it
45 afterward. The :mconfig:`locked_configs` configuration option fills this need.
46 By setting this option and the ``implicit_default`` in a site-specific
47 configuration script, users will not be able to change the
48 ``implicit_default`` behavior you configure.
49
50 .. literalinclude:: ../../example/ensure-user-qualify-modules/siteconfig.tcl
51 :language: tcl
52 :caption: siteconfig.tcl
53 :lines: 13-17
54
55 **Compatible with Modules v4.3+**
56
57 Installation
58 ------------
59
60 Create site-specific configuration directory if it does not exist yet:
61
62 .. parsed-literal::
63
64 $ mkdir \ |etcdir|
65
66 Then copy there the initialization RC file of this recipe:
67
68 .. parsed-literal::
69
70 $ cp example/ensure-user-qualify-modules/initrc \ |etcdir|\ /
71
72 Or if you want to enforce the ``implicit_default`` disablement setup for
73 users, copy there the site-specific configuration script of this recipe:
74
75 .. parsed-literal::
76
77 $ cp example/ensure-user-qualify-modules/siteconfig.tcl \ |etcdir|\ /
78
79 If you currently use Modules version 4.3, copy the configuration script
80 specific to this version:
81
82 .. parsed-literal::
83
84 $ cp example/ensure-user-qualify-modules/siteconfig.tcl-4.3 \ |etcdir|\ /siteconfig.tcl
85
86 .. note::
87
88 Defined location for the site-specific configuration script may vary from
89 one installation to another. To determine the expected location for this
90 file on your setup, check the value of the ``siteconfig`` option::
91
92 $ module config siteconfig
93
94 Once file is installed, you could verify option value is correct::
95
96 $ module config implicit_default
97 Modules Release 4.3.0 (2019-07-26)
98
99 - Config. name ---------.- Value (set by if default overridden) ---------------
100 implicit_default 0 (locked)
101
102 Usage example
103 -------------
104
105 Enable the modulepath where the example modulefiles are located::
106
107 $ module use example/ensure-user-qualify-modules/modulefiles
108
109 Attempt to load a module, which does not defined a default version, by its
110 generic name::
111
112 $ module load -v softa
113 ERROR: No default version defined for 'softa'
114
115 Load succeed if module is fully qualified::
116
117 $ module load -v softa/1
118 Loading softa/1
119
120 For modules which define explicitly a default version, they can still be
121 loaded by their generic name::
122
123 $ module load -v softb
124 Loading softb/1
125
126 .. vim:set tabstop=2 shiftwidth=2 expandtab autoindent: