Skip to content

Commit

Permalink
fix templating of tmpdisk script
Browse files Browse the repository at this point in the history
  • Loading branch information
cat-bro committed Feb 5, 2024
1 parent 6a55056 commit de446a0
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 15 deletions.
1 change: 1 addition & 0 deletions dev-workers_playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- cyverse-ansible.singularity
- dj-wasabi.telegraf
- acl-on-startup
- clean-tmpdisk
post_tasks:
- name: restart munge
systemd:
Expand Down
2 changes: 1 addition & 1 deletion galaxy-workers_playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
- usegalaxy_eu.apptainer
- geerlingguy.docker
- acl-on-startup
# - clean-tmpdisk
- clean-tmpdisk
post_tasks:
- name: restart munge
systemd:
Expand Down
2 changes: 1 addition & 1 deletion pulsar-high-mem1_playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
- pulsar-post-tasks
- slurm-post-tasks
- slg.galaxy_stats
# - clean-tmpdisk
- clean-tmpdisk
post_tasks:
- name: Create worker tmpdir on /mnt
file:
Expand Down
2 changes: 1 addition & 1 deletion pulsar-high-mem2_playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
- pulsar-post-tasks
- slurm-post-tasks
- slg.galaxy_stats
# - clean-tmpdisk
- clean-tmpdisk
post_tasks:
- name: Create worker tmpdir on /mnt
file:
Expand Down
2 changes: 1 addition & 1 deletion pulsar-mel2_worker_playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- geerlingguy.docker
- acl-on-startup
- dj-wasabi.telegraf
# - clean-tmpdisk
- clean-tmpdisk
post_tasks:
- name: Restart munge service
service:
Expand Down
2 changes: 1 addition & 1 deletion pulsar-mel3_worker_playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- geerlingguy.docker
- acl-on-startup
- dj-wasabi.telegraf
# - clean-tmpdisk
- clean-tmpdisk
post_tasks:
- name: Restart munge service
service:
Expand Down
2 changes: 1 addition & 1 deletion pulsar-nci-training_workers_playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
- geerlingguy.docker
- acl-on-startup
- dj-wasabi.telegraf
# - clean-tmpdisk
- clean-tmpdisk
post_tasks:
- name: Restart munge service
service:
Expand Down
2 changes: 1 addition & 1 deletion pulsar-paw_worker_playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
- geerlingguy.docker
- acl-on-startup
- dj-wasabi.telegraf
# - clean-tmpdisk
- clean-tmpdisk
post_tasks:
- name: Restart munge service
service:
Expand Down
2 changes: 1 addition & 1 deletion pulsar-qld-high-mem_playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
- pulsar-post-tasks
- slurm-post-tasks
- slg.galaxy_stats
# - clean-tmpdisk
- clean-tmpdisk
post_tasks:
- name: Create worker tmpdir on /mnt
file:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import subprocess
import argparse
import re
import os
import yaml

MINUTES_IN_DAY=1440
MINUTES_IN_HOUR=60

worker_node = "{{ clean_tmpdisk_worker_node_name }}"
tmp_dir = "{{ clean_tmpdisk_tmp_dir }}"

squeue_format="%8i %.50j %.9T %.12M %.40N" # slurm_id, name, state, runtime, node

vars_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'clean_tmpdisk_variables.yml')

with open(vars_file) as handle:
vars = yaml.safe_load(handle)
worker_node = vars['worker_node']
tmp_dir = vars['tmp_dir']

# integrity check for tmp_dir variable:
accepted_tmp_dirs = ['/tmp', '/mnt/tmpdisk']
if not tmp_dir in accepted_tmp_dirs: # safety feature to stop this from accidentally being set to something we don't want
raise Exception(f'specified clean_tmpdisk_tmp_dir must be one of {str(accepted_tmp_dirs)}')
Expand Down
13 changes: 9 additions & 4 deletions roles/clean-tmpdisk/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
file:
state: directory
path: "{{ clean_tmpdisk_script_dir }}"
- name: Template cleanup script
- name: Template variables
template:
src: clean_tmpdisk.py.j2
src: clean_tmpdisk_variables.yml.j2
dest: "{{ clean_tmpdisk_script_dir }}/clean_tmpdisk_variables.yml"
- name: Copy script
copy:
src: clean_tmpdisk.py
dest: "{{ clean_tmpdisk_script_dir }}/clean_tmpdisk.py"
- cron:
hour: clean_tmpdisk_cron_hour
minute: clean_tmpdisk_cron_minute
name: clean_tmpdisk
hour: "{{ clean_tmpdisk_cron_hour }}"
minute: "{{ clean_tmpdisk_cron_minute }}"
job: "python {{ clean_tmpdisk_script_dir }}/clean_tmpdisk.py"
disabled: "{{ not clean_tmpdisk_enable_cron_job }}" # set clean_tmpdisk_enable_cron_job to false at first
become: true
Expand Down
2 changes: 2 additions & 0 deletions roles/clean-tmpdisk/templates/clean_tmpdisk_variables.yml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
worker_node: "{{ clean_tmpdisk_worker_node_name }}"
tmp_dir: "{{ clean_tmpdisk_tmp_dir }}"

0 comments on commit de446a0

Please sign in to comment.