- name: Setup Docker Server
  hosts: "bohr"
  become: yes
  tasks:
    - name: Update package lists
      ansible.builtin.apt:
        update_cache: yes
        cache_valid_time: 3600

    - name: Update all packages to their latest version
      ansible.builtin.apt:
        name: "*"
        state: latest

    - name: Remove useless packages from the cache
      ansible.builtin.apt:
        autoclean: yes

    - name: Remove dependencies that are no longer required and purge their configuration files
      ansible.builtin.apt:
        autoremove: yes
        purge: true

    - name: Run the equivalent of "apt-get clean" as a separate step
      ansible.builtin.apt:
        clean: yes

    - name: Install Applications
      ansible.builtin.apt:
        name:
          - git
          - tar
          - p7zip
          - unzip
          - curl
          - wget
          - make
          - vim
          - zsh
          - python3
          - ripgrep
          - fd-find
          - fontconfig
          - qemu-guest-agent
          - vainfo
          - radeontop
          - iperf
          - htop
          - btop
          - dosfstools
        state: present

    - name: Download AMDGPU Installer
      ansible.builtin.get_url:
        url: https://repo.radeon.com/amdgpu-install/6.3.1/ubuntu/jammy/amdgpu-install_6.3.60301-1_all.deb
        dest: /tmp/amdgpu-install_6.3.60301-1_all.deb

    - name: Setup AMDGPU Drivers
      ansible.builtin.shell: |
        sudo apt install -y /tmp/amdgpu-install_6.3.60301-1_all.deb
        amdgpu-install -y

    - name: Setup Neovim
      ansible.builtin.shell: |
        curl -sL https://github.com/neovim/neovim/releases/latest/download/nvim-linux64.tar.gz | sudo tar -xzf - --strip-components=1 --overwrite -C /usr
        rm -rf ~/.config/nvim
        git clone https://github.com/LazyVim/starter ~/.config/nvim
        rm -rf ~/.config/nvim/.git
