Skip to content

Commit 318ace0

Browse files
authored
Merge pull request #7 from btravouillon/feat/nhc_custom_configs
feat: Add support of custom NHC config files
2 parents 1d788e1 + bc1486e commit 318ace0

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ nhc_upgrade: false
3838
# * || check_hw_cpuinfo 2 8 8
3939
# * || check_hw_physmem 1k 1TB
4040

41+
# List of custom NHC configuration files
42+
# Example:
43+
# nhc_custom_configs:
44+
# - name: nhc_epilog.conf
45+
# config:
46+
# * || check_ib_link_raw_ber
47+
# # Remove a configuration file
48+
# - name: nhc_foo.conf
49+
# state: absent
50+
4151
# List of NHC environment variables
4252
# See https://github.com/mej/nhc?tab=readme-ov-file#supported-variables
4353
# Example:

defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# * || check_something
66
# *.foo || another_check 1 2 3
77

8+
# List of custom NHC configuration files
9+
nhc_custom_configs: []
10+
811
nhc_packages: nhc
912

1013
# List of custom NHC scripts

tasks/main.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@
3030
group: root
3131
mode: "0640"
3232

33+
- name: Configure custom NHC configuration files
34+
loop: "{{ nhc_custom_configs }}"
35+
loop_control:
36+
label: "Configure /etc/nhc/{{ item.name }}"
37+
when: item.state is not defined or item.state != 'absent'
38+
ansible.builtin.copy:
39+
content: "{{ item.config | mandatory }}"
40+
dest: "/etc/nhc/{{ item.name | mandatory }}"
41+
owner: root
42+
group: root
43+
mode: "0640"
44+
3345
- name: Configure NHC variables
3446
when: nhc_variables is defined
3547
ansible.builtin.template:
@@ -47,3 +59,14 @@
4759
ansible.builtin.file:
4860
path: "{{ item.dest | default('/etc/nhc/scripts/' + item.src | basename) }}"
4961
state: absent
62+
63+
- name: Remove NHC custom configuration files
64+
loop: "{{ nhc_custom_configs }}"
65+
loop_control:
66+
label: "Remove /etc/nhc/{{ item.name }}"
67+
when:
68+
- item.state is defined
69+
- item.state == 'absent'
70+
ansible.builtin.file:
71+
path: "/etc/nhc/{{ item.name | mandatory }}"
72+
state: absent

0 commit comments

Comments
 (0)