From 1eb0998cddcc2230dcec005db94308fe90471259 Mon Sep 17 00:00:00 2001 From: Christian Krause <christian.krause@idiv.de> Date: Wed, 18 Dec 2019 18:51:23 +0100 Subject: [PATCH] adds support for administrative messages --- README.md | 21 +++++++++++++++++++++ tasks/config.yml | 22 ++++++++++++++++++++++ tasks/main.yml | 8 +++++++- templates/admin.list.j2 | 4 ++++ vars/main.yml | 6 ++++-- 5 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 tasks/config.yml create mode 100644 templates/admin.list.j2 diff --git a/README.md b/README.md index 07b6b64..d21e9f1 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Table of Contents * [System Spider Cache](#system-spider-cache) * [Shell Configuration](#shell-configuration) * [Incremental Roll-Out](#incremental-roll-out) + * [Administrative Messages](#administrative-messages) - [Dependencies](#dependencies) - [Example Playbook](#example-playbook) * [Top-Level Playbook](#top-level-playbook) @@ -162,6 +163,26 @@ your users know that they need to `touch ~/.lmod-yes` for **opt-in**, `touch ~/.lmod-no` for **opt-out** and to remove these files if they want to fallback to the respective default behavior. +### Administrative Messages + +Optionally, you can define administrative messages for modules to be shown when +they are loaded: + +```yml +lmod_admin_messages: + + - pattern: gcc/2%.95 + message: >- + This module is deprecated and will be removed from the system on Jan 1 + 1999. Please switch to a newer compiler. + + - pattern: /opt/apps/modulefiles/Compiler/gcc/4.7.2/boost/1.55.0 + message: We are having issues. + + - pattern: boost/1%.[5-7].* + message: We are having more issues. +``` + Dependencies ------------ diff --git a/tasks/config.yml b/tasks/config.yml new file mode 100644 index 0000000..521fa93 --- /dev/null +++ b/tasks/config.yml @@ -0,0 +1,22 @@ +--- + +- name: create lmod etc directory + file: + path: '{{ lmod_base_dir }}/etc' + state: directory + owner: root + group: root + mode: 0755 + when: > + lmod_admin_messages is defined + +- name: install admin file + template: + src: admin.list.j2 + dest: '{{ lmod_base_dir }}/etc/admin.list' + owner: root + group: root + mode: 0644 + when: lmod_admin_messages is defined + +... diff --git a/tasks/main.yml b/tasks/main.yml index bf43fbf..5a95f20 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -17,12 +17,18 @@ not lmod_install_dir_s.stat.exists failed_when: no -- name: install lmod +- name: installation include_tasks: install.yml when: > lmod_install and not lmod_install_dir_s.stat.exists +- name: configuration + import_tasks: config.yml + when: lmod_install + tags: + - lmod-config + - name: module path file template: src: 'modulespath.j2' diff --git a/templates/admin.list.j2 b/templates/admin.list.j2 new file mode 100644 index 0000000..7a67f30 --- /dev/null +++ b/templates/admin.list.j2 @@ -0,0 +1,4 @@ +{% for item in lmod_admin_messages %} +{{ item.pattern }}: {{ item.message }} + +{% endfor %} diff --git a/vars/main.yml b/vars/main.yml index b2f77ca..0d30612 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,8 +1,10 @@ --- -lmod_install_dir: '{{ lmod_prefix }}/lmod/{{ lmod_version }}' +lmod_base_dir: '{{ lmod_prefix }}/lmod' -lmod_install_link: '{{ lmod_prefix }}/lmod/lmod' +lmod_install_dir: '{{ lmod_base_dir }}/{{ lmod_version }}' + +lmod_install_link: '{{ lmod_base_dir }}/lmod' # ----------------------------------------------------------------------------- # source -- GitLab