Skip to content

Commit

Permalink
SVCPLAN-6599: mailprog.sh email wrapper for scheduler
Browse files Browse the repository at this point in the history
If profile_slurm::scheduler::mailprog::sendas_address is
specified, create an /etc/slurm/mailprog.sh script that
can be used as MailProg in slurm.conf.
  • Loading branch information
jakerundall committed Feb 18, 2025
1 parent 2fe8257 commit 9b6885d
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ profile_slurm::files::files:
...
```
To set up a mailprog.sh script to use as MailProg, you should define
`profile_slurm::scheduler::mailprog::sendas_address`. You will still
need set set MailProg in slurm.conf using the `slurm` Puppet module.

### Telegraf Monitoring

You will want to set these hiera variables for a node running the telegraf monitoring:
Expand Down
2 changes: 2 additions & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ profile_slurm::scheduler::firewall::slurmdbd_port: 6819
profile_slurm::scheduler::firewall::slurmctld_port: 6817
profile_slurm::scheduler::firewall::sources: []

profile_slurm::scheduler::mailprog::sendas_address: null

# note: there are no "official" IDs for slurmrestd, but
# slurm is usually 93 and 94 doesn't seem to be widely used
profile_slurm::slurmrestd::dependencies:
Expand Down
1 change: 1 addition & 0 deletions manifests/scheduler.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
include profile_slurm::files
include profile_slurm::id_check
include profile_slurm::scheduler::firewall
include profile_slurm::scheduler::mailprog
include systemd

$dependencies.each | $dependency | {
Expand Down
25 changes: 25 additions & 0 deletions manifests/scheduler/mailprog.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# @summary Creates a mailprog.sh script that can be used as MailProg in slurm.conf.
#
# Creates a mailprog.sh script that can be used as MailProg in slurm.conf. MailProg
# must still be set in slurm.conf using the slurm Puppet module.
#
# @param sendas_address
# Email address that should be used to send email (the FROM address).
# THIS PARAMETER MUST BE DEFINED TO CREATE THE SCRIPT!
#
# @example
# include profile_slurm::scheduler::mailprog
class profile_slurm::scheduler::mailprog (
$sendas_address,
) {
# create the mailprog.sh script
if $sendas_address {
file { '/etc/slurm/mailprog.sh':
ensure => file,
content => epp( 'profile_slurm/mailprog.sh.epp' ),
owner => 'root',
group => 'root',
mode => '0755',
}
}
}
13 changes: 13 additions & 0 deletions spec/classes/scheduler/mailprog_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'profile_slurm::scheduler::mailprog' do
on_supported_os.each do |os, os_facts|
context "on #{os}" do
let(:facts) { os_facts }

it { is_expected.to compile.with_all_deps }
end
end
end
12 changes: 12 additions & 0 deletions templates/mailprog.sh.epp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# mailprog.sh: Managed by Puppet

# SCRIPT ARGS SENT BY SLURM:
# first arg is '-s'
# last arg is recipient email address
recipient=${@: -1}
# all middle args are the subject
subject=${@:2:$#-2}

# send email with empty body and appropriate subject to the recipient
echo "" | /bin/mail -r <%= $profile_slurm::scheduler::mailprog::sendas_address %> -s "$subject" $recipient

0 comments on commit 9b6885d

Please sign in to comment.