- name: Ensure common packages are installed
  apt:
    name:
      # Needed for handling GPG keys for repositories
      - debian-keyring
      - debian-archive-keyring
      - apt-transport-https
      - ca-certificates
      - lsb-release
      - gnupg

      # Easy to edit files
      - vim
      - tmux
      - htop

      # Spam prevention
      - fail2ban

      # Disk monitoring
      - smartmontools

      # Periodic tasks
      - cron

      # General compression tools
      - bzip2

      # Working with BTRFS file systems
      - btrfs-progs
    state: present

- name: Ensure cron service is enabled
  service:
    name: cron
    state: started
    enabled: true

- name: Ensure fail2ban service is enabled
  service:
    name: fail2ban
    state: started
    enabled: true

- name: Ensure Vim config is present
  get_url:
    url: 'https://r8r.be/vim'
    dest: '{{ item.dest }}'
    owner: "{{ item.user }}"
    group: "{{ item.user }}"
    mode: '644'
  with_items:
    - user: debian
      dest: "/home/debian/.vimrc"
    - user: root
      dest: "/root/.vimrc"
