---
- name: Install common tools
  apt:
    update_cache: true
    install_recommends: false
    name:
      - acl  # advanced ACL
      - apt  # better than apt-get
      - apt-file
      - aptitude  # nice to have for Ansible
      - bash-completion  # because bash
      - curl  # placeholder
      - debsums
      - emacs-nox  # for maman
      - fish  # to motivate @edpibu
      - git  # code versioning
      - htop  # better than top
      - iotop  # monitor i/o
      - less  # i like cats
      - lsb-release  # needed to autodetect Debian version
      - lsscsi  # to list SCSI devices
      - molly-guard  # prevent reboot
      - nano  # for vulcain
      - needrestart  # ask to restart services after upgrade
      - resolvconf  # for dns configuration in network interfaces
      - screen  # Vulcain asked for this
      - sudo
      - tmux  # better than screen
      - tree  # create a graphical tree of files
      - vim  # better than nano
      - vlock  # virtual console lock
      - zsh  # to be able to ssh @erdnaxe
  register: apt_result
  retries: 3
  until: apt_result is succeeded

- name: Clean up unused packages
  apt:
    state: absent
    name:
      - doc-debian  # graphical
      - debian-faq  # graphical
      - os-prober  # makes grub-install lag
      # - oidentd  # kill the monster, https://youtu.be/yhNB0vO7FxI
      - python3-reportbug
  register: apt_result
  retries: 3
  until: apt_result is succeeded

- name: Set permissions on screen
  file:
    path: /usr/bin/screen
    owner: root
    group: utmp
    mode: '4755'
  check_mode: false

- name: Deploy screen tmpfile
  template:
    src: tmpfiles.d/screen-cleanup.conf.j2
    dest: /etc/tmpfiles.d/screen-cleanup.conf
    mode: 0644