--- - hosts: '{{ target | default("all") }}' become: yes become_method: sudo tasks: - name: Save world ansible.builtin.command: echo "saveworld" | nc -w 5 localhost 8081 - name: Shutdown server ansible.builtin.command: echo "shutdown" | nc -w 5 localhost 8081 - name: Stop service ansible.builtin.service: name: 7days state: stopped - name: Create a directory if it does not exist ansible.builtin.file: path: /data/backup state: directory mode: '0755' - name: Make save backup community.general.archive: path: /data/Saves dest: /data/backup/{{ ansible_date_time.date }}_{{ ansible_date_time.hour }}-{{ ansible_date_time.minute }}.tar.gz format: gz