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 <
ansible-project+l...@olstad.com> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> 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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
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.

Reply via email to