Search code examples
cluster-computingsudohpcsudoers

How to give everyone sudo permission on all nodes in HPC cluster


I have a 100 node CentOS 7.5 HPC cluster and I want to give everyone permission to run a script owned by root on all nodes, /usr/sbin/dropcaches.sh

Logging into all 100 nodes and doing visudo would be extremely painful and prone to mistakes.

Is it possible to create a file in /etc/sudoers.d on the head node and just cp it to every node in the cluster that gives everyone permission to execute /usr/sbin/dropcaches.sh please?

Many thanks M


Solution

  • I'll answer my question.

    I am using Centos 7.5 and you can just add a file in /etc/sudoers.d with the command in it that you want.

    So for me I wanted everyone to be able to drop_caches before running their HPC job:

    I created a file called /etc/sudoers.d/dropcaches which looked like:

    ALL ALL=NOPASSWD:/usr/sbin/dropcaches.sh
    

    and the contents of /usr/sbin/drop_caches.sh :

    #!/bin/bash
    echo 3 > /proc/sys/vm/drop_caches
    

    So now everyone is able to issue

    sudo dropcaches

    on each node in the cluster that they wanted to use