<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:14pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Hi there,<br>
</p>
<p><br>
</p>
<p>I use the following cron job that runs every night to add new users:<br>
</p>
<p><br>
</p>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">#!/bin/bash</span></div>
<div><br style="font-family: Consolas, monospace; font-size: 10pt;">
</div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">function usersInGrp {</span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">    echo -n $(getent group "$*" | cut -d':' -f 4- | awk -F',' '$1=$1')</span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">}</span></div>
<div><br style="font-family: Consolas, monospace; font-size: 10pt;">
</div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">for user in $(usersInGrp 'cluster.users'<span style="font-family: Consolas, monospace; font-size: 13.3333px; background-color: rgb(255, 255, 255);">; usersInGrp 'ALT_</span><span style="font-family: Consolas, monospace; font-size: 13.3333px; background-color: rgb(255, 255, 255);">DOMAIN</span><span style="font-family: Consolas, monospace; font-size: 13.3333px; background-color: rgb(255, 255, 255);">1</span><span style="font-family: Consolas, monospace; font-size: 13.3333px; background-color: rgb(255, 255, 255);">+cluster.users'</span><span style="font-family: Consolas, monospace; font-size: 13.3333px; background-color: rgb(255, 255, 255);">;
 usersInGrp 'ALT_</span><span style="font-family: Consolas, monospace; font-size: 13.3333px; background-color: rgb(255, 255, 255);">DOMAIN</span><span style="font-family: Consolas, monospace; font-size: 13.3333px; background-color: rgb(255, 255, 255);">2</span><span style="font-family: Consolas, monospace; font-size: 13.3333px; background-color: rgb(255, 255, 255);">+cluster.users'</span>​)</span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">do</span></div>
<div><span style=""><font face="Consolas, monospace"><span style="font-size: 10pt;">    #
</span><span style="font-size: 13.3333px;">Check for existing </span><span style="font-size: 10pt;">account.</span></font></span><br style="font-family: Consolas, monospace;">
</div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">    if [ "</span><span style="font-family: Consolas, monospace; font-size: 13.3333px;">$(sacctmgr -nP show user $user | awk -F'|' '{print $2}')</span><span style="font-family: Consolas, monospace; font-size: 10pt;">"
 == "" ];</span><br>
</div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">    then</span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">        # User has no default account. Add one.</span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">        sacctmgr add user $user DefaultAccount=nullAccount</span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">    fi</span></div>
<div><span style="font-family: Consolas, monospace; font-size: 10pt;">done</span></div>
<div><br>
</div>
<div>There's also a relatively simple inverse script to remove users who are no longer in the group.<br>
</div>
<div><br>
</div>
<div>Regards,<br>
</div>
<div>   Sam<br>
</div>
<p><br>
</p>
<p><br>
</p>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div class="BodyFragment">
<hr style="font-family:Calibri,Arial,Helvetica,sans-serif; text-align:center">
<div class="PlainText">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; text-align:right"><span style="font-size:large">Sam Hawarden</span></div>
<font size="4">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; text-align:right">Assistant Research Fellow</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; text-align:right">Pathology Department</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; text-align:right">Dunedin School of Medicine</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; text-align:right">sam.hawarden(at)otago.ac.nz</div>
<div style="text-align:right">DDI: +64 (0)3 470 3455</div>
<div style="text-align:right"><span style="background-color:rgb(255,255,255)">Mb: +64 (0)21 898 895</span></div>
<div style="text-align:right">
<div>Rm 228 Hercus Building</div>
</div>
</font></div>
</div>
</div>
</div>
<div style="color: rgb(33, 33, 33);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> slurm-users <slurm-users-bounces@lists.schedmd.com> on behalf of Fulcomer, Samuel <samuel_fulcomer@brown.edu><br>
<b>Sent:</b> Friday, 21 December 2018 12:02<br>
<b>To:</b> Slurm User Community List<br>
<b>Subject:</b> Re: [slurm-users] Accounting: Default Associations for Unknown Accounts</font>
<div> </div>
</div>
<div>
<div dir="ltr">Yes, in a way. In thinking about this for Brown (we haven't implemented it, yet), we've the idea of having a Linux cron job periodically query the group membership of the AD group granted access to the HPC resource, and adding any new users to
 the SLURM accounting database.
<div><br>
</div>
<div>We're at the point of using AD for ssh/login authentication via sssd, but still maintain an cluster/internal NIS database for pwent and cluster-specific group info (i.e., only the login gateways do AD authentication). Our SLURM associations are updated
 automatically when the NIS account is created or modified (via webmin).</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Thu, Dec 20, 2018 at 5:46 PM Ulf <<a href="mailto:mopp@gmx.net">mopp@gmx.net</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div>
<div style="font-family:Verdana; font-size:12px">
<div>Hello,</div>
<div> </div>
<div>we think about switch to SLURM. Currently we grant access to the cluster using a active directory group, everyone in this group is allowed to run jobs.</div>
<div>So the users are not known to the SLURM accounting database.</div>
<div>Is it possible to automatically add every new user to an default account without manually adding the user with "sacctmgr add user user123 Account=test".</div>
<div> </div>
<div>Regards</div>
<div>Ulf</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</body>
</html>