I have an ansible variable question

Going through the Ansible series again and im looking at the host variables. The problem I have with this is that if I have 25 hosts and I add a package I have to add it to 25 different files as well as the play itself. So, is there a way to bind variables to the detected OS or package manager instead? The idea is to have Ansible choose the correct package name according to which distribution is being worked on instead of the hostname. This would greatly reduce the amount of work required to add packages when changes are made.

IDK how yours is set up that you have a separate file per host? We sort ours by system role (like workstations, server, cluster node, etc), then the package lists within that can by chosen by looking at the variable in the task:

- hosts: all_nodes
  tags: rpi_nodes
  become: true
  become_user: root

  tasks:

  - name: Install baseline packages on Manjaro ARM nodes
    pacman:
      name:
        - bash-completion
        - blas
        - clang
        - cmake
        - distcc
        - docker
        - docker-compose
        - git
        - glances
        - go
        - go-tools
        - golang-deepin-lib
        - hddtemp
        - htop
        - inetutils
        - influxdb
        - lldb
        - llvm
        - lm_sensors
        - lynis
        - neofetch
        - nut
        - opencv
        - openmp
        - podman
        - podman-compose
        - python-influxdb
        - python-opencv
        - screen
        - unrar
        - vim
        - yay
        - zlib
      state: latest
      force: yes
      update_cache: yes
    when: ansible_facts['lsb']['description'] == "Manjaro ARM Linux"

for example.

Im following Jay’s Ansible series and in this video he discusses setting up host variable pages so only one play need be created for installing a package, apache for example, and the play will pull the proper package name based on the host variable. In the Apache example it will use apache2 for Ubuntu and httpd for Centos based distros according to the host variable file created. Im trying to narrow it down to a “Distro” variable list instead of a host based one for manageability.

Edit: I just stumbled across a referance to Group Variables on the official documentation site. I have more reading to do but on first glance this seems like it may do what I want.