---
- name: Run apt-update script
  hosts: "{{ all | default('all', true) }}"
  become: true
  become_user: root
  tasks:
    # - name: Copy update script to remote hosts
    #   copy:
    #     src: Linux/bin/update
    #     dest: /usr/local/bin/update
    #     mode: '0755'

    - name: Run update commands
      ansible.builtin.shell: |
        echo "Updating the system...";
        NEEDRESTART_MODE=a;
        sudo apt-get update --yes;
        sudo apt-get upgrade --yes;
        sudo apt-get full-upgrade --yes;
        sudo apt-get dist-upgrade --yes;
        sudo apt-get autoremove --yes;
        sudo apt-get autoclean --yes;
        echo "Updated!";
        exit 0;