61 lines
1.7 KiB
YAML
61 lines
1.7 KiB
YAML
---
|
|
- name: Submit CPU test job
|
|
hosts: slurm_controller
|
|
become: true
|
|
gather_facts: false
|
|
|
|
tasks:
|
|
- name: Submit test job to debug partition
|
|
ansible.builtin.shell: |
|
|
set -euo pipefail
|
|
|
|
job_id="$(
|
|
sudo -iu slurmuser sbatch --parsable <<'SBATCH'
|
|
#!/bin/bash
|
|
#SBATCH --job-name=cpu-test
|
|
#SBATCH --partition=debug
|
|
#SBATCH --cpus-per-task=1
|
|
#SBATCH --mem=512M
|
|
#SBATCH --time=00:02:00
|
|
#SBATCH --output=/shared/cpu-test-%j.out
|
|
|
|
echo "HOST=$(hostname)"
|
|
echo "USER=$(whoami)"
|
|
echo "SLURM_JOB_ID=$SLURM_JOB_ID"
|
|
echo "SLURM_JOB_NODELIST=$SLURM_JOB_NODELIST"
|
|
echo "CPUS_ALLOWED=$(grep Cpus_allowed_list /proc/self/status)"
|
|
date
|
|
SBATCH
|
|
)"
|
|
|
|
echo "JOB_ID=$job_id"
|
|
|
|
for i in $(seq 1 60); do
|
|
if sudo -iu slurmuser squeue -h -j "$job_id" | grep -q .; then
|
|
sudo -iu slurmuser squeue -j "$job_id"
|
|
sleep 1
|
|
else
|
|
break
|
|
fi
|
|
done
|
|
|
|
echo "### sacct"
|
|
sudo -iu slurmuser sacct -j "$job_id" --format=JobID,JobName,Partition,State,ExitCode 2>/dev/null || true
|
|
|
|
echo "### output"
|
|
if [ -f "/shared/cpu-test-${job_id}.out" ]; then
|
|
cat "/shared/cpu-test-${job_id}.out"
|
|
else
|
|
echo "Output file not found: /shared/cpu-test-${job_id}.out"
|
|
find /shared -maxdepth 1 -name "cpu-test-*.out" -ls | tail -5 || true
|
|
exit 1
|
|
fi
|
|
args:
|
|
executable: /bin/bash
|
|
register: cpu_job_result
|
|
changed_when: true
|
|
|
|
- name: Show CPU job result
|
|
ansible.builtin.debug:
|
|
var: cpu_job_result.stdout_lines
|