Commit a5cc64bf authored by Andreas Hamacher's avatar Andreas Hamacher
Browse files

Merge branch 'symlink-cronjob' into 'master'

Symlink cronjob role and template

See merge request !537
parents e76d9f86 4cec637f
---
- name: Create a directory for the symlink scripts
ansible.builtin.file:
path: /opt/symlinker/
state: directory
mode: '0755'
- name: Template project symlink script to /opt/symlinker/symlinker-{{ lustre_storage_type }}.sh
ansible.builtin.template:
src: symlinker.sh.j2
dest: /opt/symlinker/symlinker-{{ lustre_storage_type }}.sh
owner: root
group: root
mode: '0700'
vars:
lustre_storage_type: "{{ item }}"
with_items:
"{{ lustre_storage_types }}"
- name: Ensure a job that runs every 15 minutes exists. This updates the symlinks
ansible.builtin.cron:
name: "Update lustre symlinks (node local)"
minute: "*/15"
job: "/opt/symlinker-{{ item }}.sh"
user: root
with_items:
"{{ lustre_storage_types }}"
\ No newline at end of file
#!/bin/bash
originallfs={{ lustre_mount }}/{{ lustre_storage_type }}
symlinkdest={{ local_directory_path }}/{{ lustre_storage_type }}
# Check that original lustre filesystem is mounted, exit if it isn't
if [ ! -d $originallfs ]; then
exit 1
fi
# Check that the symlink destination exists, has the correct permissions etc
if [ ! -d $symlinkdest ]; then
echo "Creating $symlinkdest as it does not exist yet";
mkdir -p $symlinkdest;
chown root:root $symlinkdest;
chmod 0755 $symlinkdest;
fi
# Iterate over directories inside the original fs, create symlinks if they do _not_ exist
for subpath in `ls -1d "$originallfs"/*`; do
foldername=`basename "$subpath"`;
linkpath="$symlinkdest/$foldername";
if [ ! -L $linkpath ]; then
#echo "Symlink does not exist";
ln -sT $subpath $linkpath;
fi
done
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment