--- - name: Create backup directory ansible.builtin.file: path: "{{ WORKDIR }}/backup/MySQL_DB" state: directory - name: Find lastest MySQL DB dump ansible.builtin.shell: "cd /mnt/volumes; ls -tr mysql-server_dumps/data/mysql_dump-mysql_*" register: MySQL_dump - name: Find lastest applications DB dump ansible.builtin.shell: "cd /mnt/volumes; ls -tr mysql-server_dumps/data/mysql_dump_*" register: DBs_dump - name: Copy last DB dumps in backup directory ansible.builtin.command: "cp -a /mnt/volumes/{{ MySQL_dump.stdout_lines | last }} /mnt/volumes/{{ DBs_dump.stdout_lines | last }} {{ WORKDIR }}/backup/MySQL_DB/"