---


- name: Install apt packages
  ansible.builtin.apt:
    name:
      - git
      - mosh
      - mg
      - screen
      - tree
      - ncdu
      - pipx
      - fd-find
    state: present

- name: Download Docker installer
  ansible.builtin.get_url:
    url: https://get.docker.com
    dest: /tmp/docker.sh
    mode: "0755"

- name: Install Docker
  ansible.builtin.command: /tmp/docker.sh
  args:
    creates: /usr/bin/docker


- name: Clone dotfiles repository
  ansible.builtin.git:
    repo: https://github.com/insanity54/dotfiles
    dest: /root/dotfiles
    update: true
    version: 9d99960e49e1d4a315a49333d5030b483f27c8ef

- name: Copy .screenrc to root home directory
  ansible.builtin.copy:
    src: /root/dotfiles/.screenrc
    dest: /root/.screenrc
    mode: "0644"
    remote_src: true

- name: Download lazydocker installer
  ansible.builtin.get_url:
    url: https://raw.githubusercontent.com/jesseduffield/lazydocker/master/scripts/install_update_linux.sh
    dest: /tmp/lazydocker.sh
    mode: "0755"

- name: Install lazydocker
  environment:
    DIR: /usr/local/bin
  ansible.builtin.command: /tmp/lazydocker.sh
  args:
    creates: /usr/local/bin/lazydocker

- name: Allow UDP ports 60000-61000 for mosh
  community.general.ufw:
    rule: allow
    port: "60000:61000"
    proto: udp