Hi Mark,
Perfect!
Indeed, I should have written "file exists" or "file isfile" instead of "file stat" in my answer yesterday :-).
Regards,
Xavier
Le jeudi 03 juin 2021 à 08:58 +0000, Mark Waterhouse a écrit :
Hi Xavier
I tried your suggestion and got this error
Module ERROR: wrong # args: should be "file stat name varName"
while executing
"file stat /usr/lib/os-release"
invoked from within
"if {[file stat /usr/lib/os-release]} {
puts stderr "Loading...."
}"
However, I was able to follow your idea and found that this does exactly what I needed
if {[file isfile /usr/lib/os-release]} {
module-forbid vendor/X
module-hide vendor/X
}
For future readers, the only other thing I had to do was to change the syntax slightly….I hadn’t realised that /usr/lib/os-release exists on CentOS machines as well so am looking for the existence of /etc/debian-version instead.
I also then modified a number of my other module files to test whether a module is available prior to loading. This means that I don’t have to change too much of the environment
if {[is-avail vendor/X]} {module load vendor/X}
Thank you very much for your help and guidance Xavier
Mark
From: Xavier Delaruelle <xav...@gm...>
Reply to: "Environment Modules usage and discussion." <mod...@li...>
Date: Wednesday, 2 June 2021 at 19:25
To: "Environment Modules usage and discussion." <mod...@li...>
Subject: Re: [Modules] Using module-hide/forbid inside a modulefile
CAUTION: This email originated from outside of Palma Ceia SemiDesign. Links or attachments may be unsafe.
Le mer. 2 juin 2021 à 14:50, Mark Waterhouse <mar...@pc...<mailto:mar...@pc...>> a écrit :
Hi list
I have a common set of applications which are loaded as part of a default environment setup.
Today, most of our machines are using a RedHat/CentOS base and the modulefiles we have all work fine.
We have a standard set of tools which are loaded into the environment and some of these require modification to LD_LIBRARY_PATH.
I recently deployed a new Debian based OS and found that our standard tool installations ‘break’ modules.
LD_LIBRARY_PATH is changed and tcl on Debian doesn’t like this.
I started to look for a solution to this but then realized that the tool in question was not supported on Debian so even had I resolved the LD_LIBRARY_PATH issue, I would be no closer.
I was reading through the cookbook (https://modules.readthedocs.io/en/latest/cookbook.html) to see if there were some good examples and realized I could do this by testing for the existence of a file (/usr/lib/os-release) and, if this didn’t exist, I could ignore the rest of the code.
I then came across module-hide and decided that this would be a better idea.
I could load a ‘common’ module which, based on the OS, I could forbid access to these tools on operating systems where the tool was not supported.
It looks like module-hide / module-forbid are only available in .modulerc and this led to my posting.
Is it possible to do something like this (module-forbid is the bit that I’m stumped on)
#%Module 1.0
#
# Some OS configurations are not supported for some tools
# Debian
# For these hosts, we will hide all of the tools from Vendor X
setenv DEBHOST /usr/lib/os-release
set cmd { open [getenv DEBHOST] r }
if { ! [catch $cmd errmsg] } {
module-forbid vendor/X/*
module-hide vendor/X/*
}
I tried this and I get no error but the vendor modules still exist.
I wondered whether I could put some logic inside the .modulerc file but this would require changing all of my existing modulefiles; if I could work out the correct syntax for module-forbid/module-hide, I wouldn’t need to 😊
Does anyone have any suggestions?
Thanks in advance
Mark
Hi Mark,
You are close: to select all version of module vendor/X (let's says vendor/X/1.0, vendor/X/2.0), you just have to write:
module-forbid vendor/X
module-hide vendor/X
The extra * is taken literally by modules (which meant only the modulefile named vendor/X/* were set hidden and forbidden).
You could also simplify your OS-specific test condition:
if {[file stat /usr/lib/os-release]} {
module-forbid vendor/X
module-hide vendor/X
}
On a side note, if your LD_LIBRARY_PATH issue impacts the module command itself, you may look at the quarantine mechanism to protect module execution [1].
Regards,
Xavier
[1] https://modules.readthedocs.io/en/latest/MIGRATING.html#quarantine-mechanism-to-protect-module-execution
_______________________________________________
Modules-interest mailing list
Mod...@li...<mailto:Mod...@li...>
https://lists.sourceforge.net/lists/listinfo/modules-interest
|