How to add os based variables into group_vars

Hello,

I wanted to manage repo names from group_vars based on OS type. I have a requirement to set reponames for different OS & versions like Centos/Redhat/Ubuntu with all stable versions. The goal is to manage future repo names from group_vars

My variables looks like this

group_vars/all.yml

- name: 'Upgrading packages to latest'
  yum:
     name: "*"
     state: latest
     enablerepo: "{{ vars[repo_name] }}"
  when: ansible_distribution == "RedHat" or ansible__distribution == "CentOS"

or just drop the set_fact and use

- name: 'Upgrading packages to latest'
  yum:
     name: "*"
     state: latest
     enablerepo: "{{ vars['repo_' ~ ansible_distribution_major_version ~ '_repo'] }}"
  when: ansible_distribution == "RedHat" or ansible__distribution == "CentOS"

Thanks Kai! Came across vars & hostvars from FAQ section of ansible. Missed it, thanks for the response.

Regards
Sri