From 89bb3f7d14a8527c3c9c6469afa309f4858e6dfa Mon Sep 17 00:00:00 2001 From: Asa Rentschler Date: Tue, 19 May 2026 12:58:12 -0400 Subject: [PATCH 1/4] Updated NSP role with NSP_template_header to replace ansible_managed. Signed-off-by: Asa Rentschler --- nsp/defaults/main.yaml | 14 ++++++++++++++ nsp/meta/argument_specs.yaml | 17 +++++++++++++++++ nsp/tasks/main.yaml | 2 +- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/nsp/defaults/main.yaml b/nsp/defaults/main.yaml index 762d979..7f5c9df 100644 --- a/nsp/defaults/main.yaml +++ b/nsp/defaults/main.yaml @@ -17,3 +17,17 @@ NSP_file_permissions: "644" NSP_executable_permissions: "755" NSP_architecture: "{{ ansible_architecture }}" + +NSP_template_header: |- + | WARNING! This file is managed by Ansible. + | Do NOT make manual changes to this file. + | Please email {{ NSP_help_email }} to request a change. + + | Info: + | Role: {{ ansible_role_name }} + {% if (template_path is defined) and (playbook_dir is defined) and (playbook_dir in template_path) %} + | {{ NSP_site_name }} Template: {{ template_path.replace(playbook_dir, '').lstrip('/') }} + {% elif template_path is defined %} + | NSP Template: {{ template_path }} + {% endif %} + | User: {{ ansible_user_id }} diff --git a/nsp/meta/argument_specs.yaml b/nsp/meta/argument_specs.yaml index 5d4c203..8d237a9 100644 --- a/nsp/meta/argument_specs.yaml +++ b/nsp/meta/argument_specs.yaml @@ -65,6 +65,23 @@ argument_specs: required: false default: "{{ ansible_architecture }}" description: Hardware architecture to target. + NSP_template_header: + type: str + required: false + default: |- + | WARNING! This file is managed by Ansible. + | Do NOT make manual changes to this file. + | Please email {{ NSP_help_email }} to request a change. + + | Info: + | Role: {{ ansible_role_name }} + {% if (template_path is defined) and (playbook_dir is defined) and (playbook_dir in template_path) %} + | {{ NSP_site_name }} Template: {{ template_path.replace(playbook_dir, '').lstrip('/') }} + {% elif template_path is defined %} + | NSP Template: {{ template_path }} + {% endif %} + | User: {{ ansible_user_id }} + description: A jinja string to use as the header in templates. clear_scratch: description: - "Clears the scratch directory." diff --git a/nsp/tasks/main.yaml b/nsp/tasks/main.yaml index a866e5b..79ec29e 100644 --- a/nsp/tasks/main.yaml +++ b/nsp/tasks/main.yaml @@ -8,6 +8,6 @@ recurse: false changed_when: false tags: - - nps + - nsp - meta - always From a2f8da1cc143e58e10b6825456e132cdb395e215 Mon Sep 17 00:00:00 2001 From: Asa Rentschler Date: Tue, 19 May 2026 13:20:51 -0400 Subject: [PATCH 2/4] Updated INIT role with stable templates and helper functions. Signed-off-by: Asa Rentschler --- .docs/role_documentation_generator | 75 +++++++++++++++--------------- init/defaults/main.yaml | 1 - init/meta/argument_specs.yaml | 11 ++--- init/tasks/main.yaml | 44 ------------------ init/templates/cshrc.j2 | 18 ++++++- init/templates/profile.j2 | 18 ++++++- 6 files changed, 77 insertions(+), 90 deletions(-) diff --git a/.docs/role_documentation_generator b/.docs/role_documentation_generator index 37f6cf5..e64fffb 100755 --- a/.docs/role_documentation_generator +++ b/.docs/role_documentation_generator @@ -40,52 +40,53 @@ if __name__ == "__main__": roles_rst.append("") # options - roles_rst.extend(["`Variables`", "^^^^^^^^^^^", ""]) - for option in specs["argument_specs"]["main"]["options"]: - roles_rst.extend([ - ".. _{}_variable:".format(option), - "", - "``{}``".format(option), - '"' * (len(option) + 4), - "", - ":Type: **{}**".format( - specs["argument_specs"]["main"]["options"][option]["type"] - ), - "", - ":Required: **{}**".format( - json_dumps( - specs["argument_specs"]["main"]["options"][option]["required"] - ) - ), - "", - ]) - if "choices" in specs["argument_specs"]["main"]["options"][option]: + if "options" in specs["argument_specs"]["main"]: + roles_rst.extend(["`Variables`", "^^^^^^^^^^^", ""]) + for option in specs["argument_specs"]["main"]["options"]: roles_rst.extend([ - ":Allowed Values: ``{}``".format( - json_dumps(specs["argument_specs"]["main"]["options"][option]["choices"]) - ) - ]) - if (not specs["argument_specs"]["main"]["options"][option]["required"] and - "default" in specs["argument_specs"]["main"]["options"][option]): - roles_rst.extend([ - ":Default: ``{}``".format( + ".. _{}_variable:".format(option), + "", + "``{}``".format(option), + '"' * (len(option) + 4), + "", + ":Type: **{}**".format( + specs["argument_specs"]["main"]["options"][option]["type"] + ), + "", + ":Required: **{}**".format( json_dumps( - specs["argument_specs"]["main"]["options"][option]["default"] + specs["argument_specs"]["main"]["options"][option]["required"] ) ), "", ]) - roles_rst.extend([ - ":Description: {}".format( - specs["argument_specs"]["main"]["options"][option]["description"] - ), - "", - ]) - if "raw" in specs["argument_specs"]["main"]["options"][option]: + if "choices" in specs["argument_specs"]["main"]["options"][option]: + roles_rst.extend([ + ":Allowed Values: ``{}``".format( + json_dumps(specs["argument_specs"]["main"]["options"][option]["choices"]) + ) + ]) + if (not specs["argument_specs"]["main"]["options"][option]["required"] and + "default" in specs["argument_specs"]["main"]["options"][option]): + roles_rst.extend([ + ":Default: ``{}``".format( + json_dumps( + specs["argument_specs"]["main"]["options"][option]["default"] + ) + ), + "", + ]) roles_rst.extend([ - specs["argument_specs"]["main"]["options"][option]["raw"], + ":Description: {}".format( + specs["argument_specs"]["main"]["options"][option]["description"] + ), "", ]) + if "raw" in specs["argument_specs"]["main"]["options"][option]: + roles_rst.extend([ + specs["argument_specs"]["main"]["options"][option]["raw"], + "", + ]) print("--- writing out documentation for NSP roles ---") out_dir = Path(__file__).parent.joinpath("source/reference") diff --git a/init/defaults/main.yaml b/init/defaults/main.yaml index ab8d60a..e69de29 100644 --- a/init/defaults/main.yaml +++ b/init/defaults/main.yaml @@ -1 +0,0 @@ -NSP_INIT_wipe: false diff --git a/init/meta/argument_specs.yaml b/init/meta/argument_specs.yaml index c1a4472..39887f3 100644 --- a/init/meta/argument_specs.yaml +++ b/init/meta/argument_specs.yaml @@ -10,9 +10,8 @@ argument_specs: The ``init`` directory and accompanying files are completely optional. Without them, blank init scripts will be created. - options: - NSP_INIT_wipe: - type: bool - required: false - default: false - description: Wipe and recreate the init scripts on every run. + - |- + .. note:: + The init role provides a bash/csh function called ``nsp_initialize_lmod`` that can be used to setup Lmod + from the default location. You may use them in your own ``profile.j2`` and ``cshrc.j2`` + templates if desired. diff --git a/init/tasks/main.yaml b/init/tasks/main.yaml index 1eb6684..dc11a5a 100644 --- a/init/tasks/main.yaml +++ b/init/tasks/main.yaml @@ -8,13 +8,6 @@ tags: - init -- name: Check profile Status - ansible.builtin.stat: - path: "{{ [NSP_install_root, 'init', 'profile'] | path_join }}" - register: profile_status - tags: - - init - - name: Generate profile ansible.builtin.template: src: profile.j2 @@ -22,28 +15,6 @@ owner: "{{ NSP_user }}" group: "{{ NSP_group }}" mode: "{{ NSP_file_permissions }}" - when: NSP_INIT_wipe or not profile_status.stat.exists - tags: - - init - -- name: Add Contents to profile - ansible.builtin.blockinfile: - block: "{{ lookup('template', [playbook_dir, 'init/profile.j2'] | path_join) }}" - path: "{{ [NSP_install_root, 'init', 'profile'] | path_join }}" - marker: "# {mark} INIT MANAGED" - append_newline: true - prepend_newline: true - owner: "{{ NSP_user }}" - group: "{{ NSP_group }}" - mode: "{{ NSP_file_permissions }}" - when: "[playbook_dir, 'init/profile.j2'] | path_join is file" - tags: - - init - -- name: Check cshrc Status - ansible.builtin.stat: - path: "{{ [NSP_install_root, 'init', 'cshrc'] | path_join }}" - register: cshrc_status tags: - init @@ -54,20 +25,5 @@ owner: "{{ NSP_user }}" group: "{{ NSP_group }}" mode: "{{ NSP_file_permissions }}" - when: NSP_INIT_wipe or not cshrc_status.stat.exists - tags: - - init - -- name: Add Contents to cshrc - ansible.builtin.blockinfile: - block: "{{ lookup('template', [playbook_dir, 'init/cshrc.j2'] | path_join) }}" - path: "{{ [NSP_install_root, 'init', 'cshrc'] | path_join }}" - marker: "# {mark} INIT MANAGED" - append_newline: true - prepend_newline: true - owner: "{{ NSP_user }}" - group: "{{ NSP_group }}" - mode: "{{ NSP_file_permissions }}" - when: "[playbook_dir, 'init/cshrc.j2'] | path_join is file" tags: - init diff --git a/init/templates/cshrc.j2 b/init/templates/cshrc.j2 index 4421220..4740b3d 100644 --- a/init/templates/cshrc.j2 +++ b/init/templates/cshrc.j2 @@ -1,2 +1,18 @@ #!/usr/bin/env csh -{{ ansible_managed | comment(beginning='##', end='##', decoration='#', prefix_count=0, postfix_count=0) }} +{{ NSP_template_header | comment(beginning='##', end='##', decoration='#', prefix_count=0, postfix_count=0) }} + +######################################## +# NSP Helpers +######################################## + +nsp_initialize_lmod() { + if ( -f "{{ [NSP_install_root, 'lmod/etc/profile'] | path_join }}" ) then + source "{{ [NSP_install_root, 'lmod/etc/profile'] | path_join }}" + endif +} + +######################################## +# User Content +######################################## + +{{ lookup('template', [playbook_dir, 'init/cshrc.j2'] | path_join, errors='ignore') | default('') }} diff --git a/init/templates/profile.j2 b/init/templates/profile.j2 index a91b52b..89b65b7 100644 --- a/init/templates/profile.j2 +++ b/init/templates/profile.j2 @@ -1,2 +1,18 @@ #!/usr/bin/env bash -{{ ansible_managed | comment(beginning='##', end='##', decoration='#', prefix_count=0, postfix_count=0) }} +{{ NSP_template_header | comment(beginning='##', end='##', decoration='#', prefix_count=0, postfix_count=0) }} + +######################################## +# NSP Helpers +######################################## + +nsp_initialize_lmod() { + if [ -f {{ [NSP_install_root, 'lmod/etc/profile'] | path_join }} ]; then + source {{ [NSP_install_root, 'lmod/etc/profile'] | path_join }} + fi +} + +######################################## +# User Content +######################################## + +{{ lookup('template', [playbook_dir, 'init/profile.j2'] | path_join, errors='ignore') | default('') }} From e161941128225f8b9659051a08448c4b2ff9fd15 Mon Sep 17 00:00:00 2001 From: Asa Rentschler Date: Tue, 19 May 2026 15:22:54 -0400 Subject: [PATCH 3/4] Updated LMOD role. Signed-off-by: Asa Rentschler --- lmod/meta/main.yaml | 1 - lmod/tasks/external.yaml | 47 --------------------- lmod/tasks/internal.yaml | 58 -------------------------- lmod/tasks/main.yaml | 20 +++++---- lmod/templates/DefApps.lua.j2 | 2 +- lmod/templates/NSPHierarchyHook.lua.j2 | 2 +- lmod/templates/NSPLoggingHook.lua.j2 | 2 +- lmod/templates/SitePackage.lua.j2 | 2 +- lmod/templates/cshrc.j2 | 30 +++++++++++++ lmod/templates/modulepath.default.j2 | 2 +- lmod/templates/profile.j2 | 31 ++++++++++++++ 11 files changed, 79 insertions(+), 118 deletions(-) delete mode 100644 lmod/tasks/external.yaml create mode 100644 lmod/templates/cshrc.j2 create mode 100644 lmod/templates/profile.j2 diff --git a/lmod/meta/main.yaml b/lmod/meta/main.yaml index 33d37f3..9a35135 100644 --- a/lmod/meta/main.yaml +++ b/lmod/meta/main.yaml @@ -1,3 +1,2 @@ dependencies: - role: nsp - - role: init diff --git a/lmod/tasks/external.yaml b/lmod/tasks/external.yaml deleted file mode 100644 index a8c9ea0..0000000 --- a/lmod/tasks/external.yaml +++ /dev/null @@ -1,47 +0,0 @@ -- name: Insert LMOD Init profile Configuration - ansible.builtin.blockinfile: - block: | - export LMOD_SYSTEM_NAME={{ NSP_system_name }} - export LMOD_PACKAGE_PATH={{ [NSP_install_root, 'lmod/hooks'] | path_join }} - export LMOD_AVAIL_STYLE=nsp-pretty:system - export LMOD_MODULERCFILE={{ [NSP_install_root, 'lmod/etc/rc.lua'] | path_join }} - export LMOD_ADMIN_FILE={{ [NSP_install_root, 'lmod/etc/admin.list'] | path_join }} - export LMOD_RC={{ [NSP_install_root, 'lmod/etc/lmodrc.lua'] | path_join }} - - type module > /dev/null 2>&1 - if [ "$?" -eq 0 ]; then - module --initial_load --no_redirect restore - fi - path: "{{ [NSP_install_root, 'init', 'profile'] | path_join }}" - owner: "{{ NSP_user }}" - group: "{{ NSP_group }}" - mode: "{{ NSP_file_permissions }}" - marker: "# {mark} LMOD MANAGED" - append_newline: true - prepend_newline: true - tags: - - lmod - -- name: Insert LMOD Init cshrc Configuration - ansible.builtin.blockinfile: - block: | - setenv LMOD_SYSTEM_NAME {{ NSP_system_name }} - setenv LMOD_PACKAGE_PATH {{ [NSP_install_root, 'lmod/hooks'] | path_join }} - setenv LMOD_AVAIL_STYLE nsp-pretty:system - setenv LMOD_MODULERCFILE {{ [NSP_install_root, 'lmod/etc/rc.lua'] | path_join }} - setenv LMOD_ADMIN_FILE {{ [NSP_install_root, 'lmod/etc/admin.list'] | path_join }} - setenv LMOD_RC {{ [NSP_install_root, 'lmod/etc/lmodrc.lua'] | path_join }} - - type module >&/dev/null - if ($status == 0) then - module --initial_load --no_redirect restore - endif - path: "{{ [NSP_install_root, 'init', 'cshrc'] | path_join }}" - owner: "{{ NSP_user }}" - group: "{{ NSP_group }}" - mode: "{{ NSP_file_permissions }}" - marker: "# {mark} LMOD MANAGED" - append_newline: true - prepend_newline: true - tags: - - lmod diff --git a/lmod/tasks/internal.yaml b/lmod/tasks/internal.yaml index 3dbca63..da12b9c 100644 --- a/lmod/tasks/internal.yaml +++ b/lmod/tasks/internal.yaml @@ -31,61 +31,3 @@ mode: "{{ NSP_file_permissions }}" tags: - lmod - -- name: Insert LMOD Init profile Configuration - ansible.builtin.blockinfile: - block: | - type module > /dev/null 2>&1 - if [ "$?" -eq 0 ]; then - clearLmod -q > /dev/null 2>&1 - unset LMOD_MODULEPATH_INIT - fi - - export LMOD_SYSTEM_NAME={{ NSP_system_name }} - export LMOD_SYSTEM_DEFAULT_MODULES=DefApps - export LMOD_PACKAGE_PATH={{ [NSP_install_root, 'lmod/hooks'] | path_join }} - export LMOD_AVAIL_STYLE=nsp-pretty:system - export LMOD_MODULERCFILE={{ [NSP_install_root, 'lmod/etc/rc.lua'] | path_join }} - export LMOD_ADMIN_FILE={{ [NSP_install_root, 'lmod/etc/admin.list'] | path_join }} - export LMOD_RC={{ [NSP_install_root, 'lmod/etc/lmodrc.lua'] | path_join }} - - source {{ [NSP_install_root, 'lmod/lmod/init/profile'] | path_join }} - module --initial_load --no_redirect restore - path: "{{ [NSP_install_root, 'init', 'profile'] | path_join }}" - owner: "{{ NSP_user }}" - group: "{{ NSP_group }}" - mode: "{{ NSP_file_permissions }}" - marker: "# {mark} LMOD MANAGED" - append_newline: true - prepend_newline: true - tags: - - lmod - -- name: Insert LMOD Init cshrc Configuration - ansible.builtin.blockinfile: - block: | - type module >&/dev/null - if ($status == 0) then - clearLmod -q >&/dev/null - unset LMOD_MODULEPATH_INIT - endif - - setenv LMOD_SYSTEM_NAME {{ NSP_system_name }} - setenv LMOD_SYSTEM_DEFAULT_MODULES DefApps - setenv LMOD_PACKAGE_PATH {{ [NSP_install_root, 'lmod/hooks'] | path_join }} - setenv LMOD_AVAIL_STYLE nsp-pretty:system - setenv LMOD_MODULERCFILE {{ [NSP_install_root, 'lmod/etc/rc.lua'] | path_join }} - setenv LMOD_ADMIN_FILE {{ [NSP_install_root, 'lmod/etc/admin.list'] | path_join }} - setenv LMOD_RC {{ [NSP_install_root, 'lmod/etc/lmodrc.lua'] | path_join }} - - source {{ [NSP_install_root, 'lmod/lmod/init/cshrc'] | path_join }} - module --initial_load --no_redirect restore - path: "{{ [NSP_install_root, 'init', 'cshrc'] | path_join }}" - owner: "{{ NSP_user }}" - group: "{{ NSP_group }}" - mode: "{{ NSP_file_permissions }}" - marker: "# {mark} LMOD MANAGED" - append_newline: true - prepend_newline: true - tags: - - lmod diff --git a/lmod/tasks/main.yaml b/lmod/tasks/main.yaml index 6377477..97f8793 100644 --- a/lmod/tasks/main.yaml +++ b/lmod/tasks/main.yaml @@ -31,6 +31,19 @@ tags: - lmod +- name: Generate LMOD Init Scripts + ansible.builtin.template: + src: "{{ item }}.j2" + dest: "{{ [NSP_install_root, 'lmod/etc/{}'.format(item)] | path_join }}" + owner: "{{ NSP_user }}" + group: "{{ NSP_group }}" + mode: "{{ NSP_executable_permissions }}" + loop: + - profile + - cshrc + tags: + - lmod + - name: Generate LMOD Configuration Files ansible.builtin.template: src: "{{ [playbook_dir, 'lmod/{}.j2'.format(item)] | path_join }}" @@ -81,10 +94,3 @@ when: NSP_LMOD_install_type == "internal" tags: - lmod - -- name: Included External LMOD Tasks - ansible.builtin.include_tasks: - file: external.yaml - when: NSP_LMOD_install_type == "external" - tags: - - lmod diff --git a/lmod/templates/DefApps.lua.j2 b/lmod/templates/DefApps.lua.j2 index 7ddcc84..e409748 100644 --- a/lmod/templates/DefApps.lua.j2 +++ b/lmod/templates/DefApps.lua.j2 @@ -1,4 +1,4 @@ -{{ ansible_managed | comment(beginning='--[[', end=']]--', decoration='', prefix_count=0, postfix_count=0) }} +{{ NSP_template_header | comment(beginning='--[[', end=']]--', decoration='', prefix_count=0, postfix_count=0) }} {% for module in NSP_LMOD_DefApps_modules %} try_load("{{ module }}") diff --git a/lmod/templates/NSPHierarchyHook.lua.j2 b/lmod/templates/NSPHierarchyHook.lua.j2 index f4da805..7a3aa28 100644 --- a/lmod/templates/NSPHierarchyHook.lua.j2 +++ b/lmod/templates/NSPHierarchyHook.lua.j2 @@ -1,4 +1,4 @@ -{{ ansible_managed | comment(beginning='--[[', end=']]--', decoration='', prefix_count=0, postfix_count=0) }} +{{ NSP_template_header | comment(beginning='--[[', end=']]--', decoration='', prefix_count=0, postfix_count=0) }} -------------------------------------------------------------------------- -- NSP provided hooks diff --git a/lmod/templates/NSPLoggingHook.lua.j2 b/lmod/templates/NSPLoggingHook.lua.j2 index 53289ec..0d369c8 100644 --- a/lmod/templates/NSPLoggingHook.lua.j2 +++ b/lmod/templates/NSPLoggingHook.lua.j2 @@ -1,4 +1,4 @@ -{{ ansible_managed | comment(beginning='--[[', end=']]--', decoration='', prefix_count=0, postfix_count=0) }} +{{ NSP_template_header | comment(beginning='--[[', end=']]--', decoration='', prefix_count=0, postfix_count=0) }} local json = require("json") local cosmic = require("Cosmic"):singleton() diff --git a/lmod/templates/SitePackage.lua.j2 b/lmod/templates/SitePackage.lua.j2 index c5b8d38..0ba39ed 100644 --- a/lmod/templates/SitePackage.lua.j2 +++ b/lmod/templates/SitePackage.lua.j2 @@ -1,4 +1,4 @@ -{{ ansible_managed | comment(beginning='--[[', end=']]--', decoration='', prefix_count=0, postfix_count=0) }} +{{ NSP_template_header | comment(beginning='--[[', end=']]--', decoration='', prefix_count=0, postfix_count=0) }} -------------------------------------------------------------------------- -- @module SitePackage diff --git a/lmod/templates/cshrc.j2 b/lmod/templates/cshrc.j2 new file mode 100644 index 0000000..d4bd30a --- /dev/null +++ b/lmod/templates/cshrc.j2 @@ -0,0 +1,30 @@ +#!/usr/bin/env csh +{{ NSP_template_header | comment(beginning='##', end='##', decoration='#', prefix_count=0, postfix_count=0) }} + +# common variables +setenv LMOD_SYSTEM_NAME {{ NSP_system_name }} +setenv LMOD_PACKAGE_PATH {{ [NSP_install_root, 'lmod/hooks'] | path_join }} +setenv LMOD_AVAIL_STYLE nsp-pretty:system +setenv LMOD_MODULERCFILE {{ [NSP_install_root, 'lmod/etc/rc.lua'] | path_join }} +setenv LMOD_ADMIN_FILE {{ [NSP_install_root, 'lmod/etc/admin.list'] | path_join }} +setenv LMOD_RC {{ [NSP_install_root, 'lmod/etc/lmodrc.lua'] | path_join }} + +{% if NSP_LMOD_install_type == "internal" %} +# LMOD configuration for internal install +setenv LMOD_SYSTEM_DEFAULT_MODULES DefApps + +type module >&/dev/null +if ($status == 0) then + clearLmod -q >&/dev/null + unset LMOD_MODULEPATH_INIT +endif + +source {{ [NSP_install_root, 'lmod/lmod/init/cshrc'] | path_join }} +module --initial_load --no_redirect restore +{% elif NSP_LMOD_install_type == "external" %} +# LMOD configuration for external install +type module >&/dev/null +if ($status == 0) then + module --initial_load --no_redirect restore +endif +{% endif %} diff --git a/lmod/templates/modulepath.default.j2 b/lmod/templates/modulepath.default.j2 index 48dfd1f..edbf2eb 100644 --- a/lmod/templates/modulepath.default.j2 +++ b/lmod/templates/modulepath.default.j2 @@ -1,4 +1,4 @@ -{{ ansible_managed | comment(beginning='##', end='##', decoration='#', prefix_count=0, postfix_count=0) }} +{{ NSP_template_header | comment(beginning='##', end='##', decoration='#', prefix_count=0, postfix_count=0) }} {% for path in NSP_LMOD_default_module_paths %} {{ path }} diff --git a/lmod/templates/profile.j2 b/lmod/templates/profile.j2 new file mode 100644 index 0000000..c7b2151 --- /dev/null +++ b/lmod/templates/profile.j2 @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +{{ NSP_template_header | comment(beginning='##', end='##', decoration='#', prefix_count=0, postfix_count=0) }} + +# common variables +export LMOD_SYSTEM_NAME={{ NSP_system_name }} +export LMOD_PACKAGE_PATH={{ [NSP_install_root, 'lmod/hooks'] | path_join }} +export LMOD_AVAIL_STYLE=nsp-pretty:system +export LMOD_MODULERCFILE={{ [NSP_install_root, 'lmod/etc/rc.lua'] | path_join }} +export LMOD_ADMIN_FILE={{ [NSP_install_root, 'lmod/etc/admin.list'] | path_join }} +export LMOD_RC={{ [NSP_install_root, 'lmod/etc/lmodrc.lua'] | path_join }} + + +{% if NSP_LMOD_install_type == "internal" %} +# LMOD configuration for internal install +export LMOD_SYSTEM_DEFAULT_MODULES=DefApps + +type module > /dev/null 2>&1 +if [ "$?" -eq 0 ]; then + clearLmod -q > /dev/null 2>&1 + unset LMOD_MODULEPATH_INIT +fi + +source {{ [NSP_install_root, 'lmod/lmod/init/profile'] | path_join }} +module --initial_load --no_redirect restore +{% elif NSP_LMOD_install_type == "external" %} +# LMOD configuration for external install +type module > /dev/null 2>&1 +if [ "$?" -eq 0 ]; then + module --initial_load --no_redirect restore +fi +{% endif %} From 11b61dd7008cf67c64a060e6bc0a965a1b0e97a2 Mon Sep 17 00:00:00 2001 From: Asa Rentschler Date: Tue, 19 May 2026 15:46:40 -0400 Subject: [PATCH 4/4] Refactored for NSP_template_header Signed-off-by: Asa Rentschler --- .docs/source/starting/setup.rst | 14 +++++++------- .gitignore | 1 + ansible.cfg | 8 -------- aocc/templates/module.lua.j2 | 2 +- codee/templates/module.lua.j2 | 2 +- cuda/templates/module.lua.j2 | 2 +- gcc/templates/module.lua.j2 | 2 +- llvm/templates/module.lua.j2 | 2 +- miniforge3/templates/condarc.j2 | 2 +- miniforge3/templates/module.lua.j2 | 2 +- nvhpc/templates/module.lua.j2 | 2 +- oneapi/templates/module.lua.j2 | 2 +- openmpi/templates/module.lua.j2 | 2 +- spack/templates/spacktivate.sh.j2 | 2 +- xalt/templates/module.lua.j2 | 2 +- 15 files changed, 20 insertions(+), 27 deletions(-) diff --git a/.docs/source/starting/setup.rst b/.docs/source/starting/setup.rst index eb6f2c0..0418436 100644 --- a/.docs/source/starting/setup.rst +++ b/.docs/source/starting/setup.rst @@ -377,7 +377,7 @@ We will name our spack environments according to the following schema ``core