Thanks Kai! Came across vars & hostvars from FAQ section of ansible. Missed it, thanks for the response.
Regards Sri On Fri, Feb 2, 2018 at 12:52 AM, Kai Stian Olstad < [email protected]> wrote: > On Wednesday, 31 January 2018 05.43.36 CET sriman dharba wrote: > > - 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" > > - 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" > > > -- > Kai Stian Olstad > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/ansible-project/12765257.BGxFR1VXkv%40x1. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAF9AceEnhqLbjP7%2BV%2BjkVu-TjXyvgBE9KNpBrVcd1cyS0DOpTA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
