---
- name: Do tasks that need 'root'
  hosts: all
  become: yes
  tasks:
    - name: Update the system
      tags: upgrade
      apk:
        available: yes
        upgrade: yes
        update_cache: yes

    # Install mesa-dri-gallium or mesa-dri-classic as well for a working
    # desktop environment
    - name: Install dependencies
      tags: depend
      apk:
        name: >-
          aerc, amfora, ansible-lint, atool, bash, bat, brillo, build-base, pv,
          buildah, cargo, clang, clang-analyzer, clang-extra-tools, go, age, xz,
          clipman, cmake, cppcheck, curl, docs, dunst, editorconfig, exa, syft,
          emacs-x11, extra-cmake-modules, exiftool, fd, ffmpeg, ethtool, chafa,
          ffmpegthumbnailer, flatpak, font-noto, font-iosevka-aile, foot, inxi,
          font-iosevka-etoile, font-iosevka-slab, font-iosevka-base, ddgr,
          font-noto-emoji, gdb, git-email, git-lfs, gpg, grim, buku, drill,
          gnupg-doc, jq, iproute2, gst-plugins-pipewire, sops, imagemagick,
          libarchive-tools, libffi-dev, qalc, love, bombadillo, mupdf-tools,
          man-pages-posix, man-pages, meson, mpc, mpd, mpdris2, pavucontrol-qt,
          mpv, mpv-mpris, ncmpcpp, neovim, npm, yarn, pandoc, k9s, rustscan,
          py3-pynvim, newsboat, ngrep, nmap, nushell, packer, rsync,
          pcmanfm-qt, pinentry-qt, podman, pipewire, sway, swappy, sshfs,
          pipewire-pulse, playerctl, qimgv, qt5ct, pipewire-tools, kubectl,
          py3-virtualenv, py3-setuptools, ripgrep, senpai, shellcheck, castero,
          slurp, sqlite, starship, strace, stylua, swayidle, swaylock, cosign,
          tcpdump, texlive-full, tokei, trivy, vifm, valgrind, steghide,
          vulkan-loader, waybar, wireplumber, wf-recorder, wlr-randr, lite-xl,
          xdg-desktop-portal-wlr, xdg-desktop-portal-gtk, xdg-user-dirs,
          xwayland, zathura, zathura-cb, zathura-ps, zoxide, openssh-doc,
          zathura-pdf-mupdf, openssh-client-default, btop, zellij, gallery-dl,
          alacritty, unifont, python3-dev, py3-proxmoxer, lua5.4-posix, abook,
          rofi-calc, rofi-wayland, rofi-file-browser-extended, rofi-emoji,
          automake, autoconf, libtool, mbuffer, onefetch, flawfinder, weechat,
          weechat-lua, weechat-python, py3-websocket-client, weechat-spell,
          aspell-en, aspell
        state: present

    # https://superuser.com/questions/1333563/disable-history-in-chromium
    - block:
        - name: Create Chromium policy directory
          file:
            path: /etc/chromium/policies/managed
            state: directory
            mode: 0755

        - name: Add custom Chromium policies
          copy:
            src: files/policy.json
            dest: /etc/chromium/policies/managed/custom_policy.json
            owner: root
            group: root
            mode: 0444
      tags: chromium
