# Dynamic variables includes  in roles

**URL:** <https://forum.ansible.com/t/dynamic-variables-includes-in-roles/20689>\
**Category:** Ansible Project\
**Created:** [February 26, 2016, 3:14pm UTC](https://forum.ansible.com/t/dynamic-variables-includes-in-roles/20689 "2016-02-26T15:14:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris\_scott](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@chris\_scott](https://forum.ansible.com/u/chris_scott)\
**Post date:** [February 26, 2016, 3:14pm UTC](https://forum.ansible.com/t/dynamic-variables-includes-in-roles/20689/1 "2016-02-26T15:14:18Z")

</div>

This should be simple but I cant figure it. I want to read in a list of packages to install dependent on the os major version. However I want to do this at the role level.

eg

I have 3 package lists, one for RHEL5, one for RHEL6 machines and one for RHEL7 machines. I want to dynamically pick the one I want depending on what the target machine is with something below. I could duplicate the action below 3x and condition it with a when, but surely there must be a more elegant way than that?

- name: install packages  
action: yum  
name={{item}}

state=present  
tags:

- packages  
with\_items:
- “{{packages}}”

I have monkeyed around with the playbook with includes but none seem to work. I’m on ansible 2.x (latest from pip), but cannt seem to figure this right now, and I keep gettting the following which isnt overly helpful (adding -vvvv, doesnt reveal much more)

TASK [ora\_pre : install packages] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /usr/local/ansible/roles/ora\_pre/tasks/main.yml:39  
[DEPRECATION WARNING]: Skipping task due to undefined Error, in the future this will be a fatal error… This feature will be removed in a future release. Deprecation warnings can be disabled by setting  
deprecation\_warnings=False in ansible.cfg.

playbook attempts
