Skip to content

Commit 95390c7

Browse files
committed
feat: Add support for custom NHC scripts
It is now possible to add custom scripts using the list `nhc_scripts`.
1 parent df712d4 commit 95390c7

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ nhc_upgrade: false
4444
# nhc_variables:
4545
# - NHC_RM=slurm
4646
# - HELPERDIR=/opt/nhc/libexec/nhc/
47+
48+
# List of NHC custom scripts
49+
# `src` is mandatory
50+
# `dest` and `state` are optional
51+
nhc_scripts:
52+
# Add a custom script
53+
- src: "{{ inventory_dir }}/files/nhc/custom_script.nhc"
54+
# Add my custom script to custom INCDIR
55+
- src: "{{ inventory_dir }}/files/nhc/custom_script_foo.nhc"
56+
dest: '/opt/nhc/scripts/custom_script_foo.nhc'
57+
# Remove a custom script
58+
- src: "{{ inventory_dir }}/files/nhc/custom_script_bar.nhc"
59+
state: absent
4760
```
4861
4962
## Example Playbook

defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
nhc_packages: nhc
99

10+
# List of custom NHC scripts
11+
# See https://github.com/mej/nhc?tab=readme-ov-file#writing-checks
12+
nhc_scripts: []
13+
1014
# Whether to upgrade existing NHC installation
1115
# Set to true to upgrade to latest version
1216
nhc_upgrade: false

tasks/main.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,19 @@
2828
owner: root
2929
group: root
3030
mode: "0640"
31+
32+
- name: Install NHC scripts
33+
loop: "{{ nhc_scripts }}"
34+
ansible.builtin.copy:
35+
src: "{{ item.src }}"
36+
dest: "{{ item.dest | default('/etc/nhc/scripts/' + item.src | basename) }}"
37+
owner: root
38+
group: root
39+
mode: "0644"
40+
41+
- name: Remove NHC scripts
42+
loop: "{{ nhc_scripts }}"
43+
when: item.state == 'absent'
44+
ansible.builtin.file:
45+
path: "{{ item.dest | default('/etc/nhc/scripts/' + item.src | basename) }}"
46+
state: absent

0 commit comments

Comments
 (0)