--- - name: Fetch latest Slurm backups from nodes to pvef hosts: slurm_cluster become: true gather_facts: false vars: remote_backup_base: /var/backups/slurm local_backup_base: "{{ playbook_dir }}/../../artifacts/backups" tasks: - name: Find latest remote backup directory ansible.builtin.shell: | set -euo pipefail ls -1dt {{ remote_backup_base }}/* | head -n 1 args: executable: /bin/bash register: latest_backup_dir changed_when: false - name: Create local backup directory on pvef ansible.builtin.file: path: "{{ local_backup_base }}/{{ inventory_hostname }}" state: directory mode: "0700" delegate_to: localhost become: false - name: Archive latest backup directory on remote node ansible.builtin.archive: path: "{{ latest_backup_dir.stdout }}" dest: "/tmp/{{ inventory_hostname }}-slurm-backup.tgz" format: gz force_archive: true changed_when: true - name: Fetch archive to pvef ansible.builtin.fetch: src: "/tmp/{{ inventory_hostname }}-slurm-backup.tgz" dest: "{{ local_backup_base }}/{{ inventory_hostname }}/" flat: true - name: Remove temporary remote archive ansible.builtin.file: path: "/tmp/{{ inventory_hostname }}-slurm-backup.tgz" state: absent