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
---
rhel_5_repo: redhat-5-rpms-stable <-- name of the repo which i will use to install latest kernel patches
rhel_6_repo: redhat-6-rpms-stable
rhel_7_repo: redhat-7-rpms-stable
ubuntu_12_repo: ubuntu-12-deb-stable
I would like to use use repo keys into roles based on fact ansible_distribution_major_version and fetch the variable from group_vars
- set_fact: repo_name="rhel_{{ ansible_distribution_major_version }}_repo"
- name: 'Upgrading packages to latest'
yum:
name: "*"
state: latest
enablerepo: "{{ repo_name }}"
when: ansible_distribution == "RedHat" or ansible__distribution == "CentOS"
How can i achieve this..Please suggest.
Thanks
Sri