I would like to automatically set the state of a node in a SLURM cluster before/after running my Ansible playbook (from idle to drained and after applying the playbook back to idle). The scontrol
command that is required for this, is only available on the head node of the cluster. The Ansible playbook, however, is applied to the compute nodes of the cluster. Is there any way to run a remote command on another host than the one currently connected to? I could think of just using the built-in shell
module and then SSH to the head node. But maybe there's a nicer way of doing it?
I already looked for ready-to-go Ansible modules but couldn't find any for my use case. The existing ones are all focused on installing/configuring a SLURM cluster.
My idea is then to use a do-until
loop that sets the new cluster node state and then repeatedly checks whether the node already switched to the new state (as there still could be running jobs).