# Dynamic Package Installs?

**URL:** <https://forum.ansible.com/t/dynamic-package-installs/18706>\
**Category:** Ansible Project\
**Created:** [July 7, 2015, 6:08pm UTC](https://forum.ansible.com/t/dynamic-package-installs/18706 "2015-07-07T18:08:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joaquin\_Menchaca](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@Joaquin\_Menchaca](https://forum.ansible.com/u/Joaquin_Menchaca)\
**Post date:** [July 7, 2015, 6:08pm UTC](https://forum.ansible.com/t/dynamic-package-installs/18706/1 "2015-07-07T18:08:51Z")

</div>

Currently I have the following.

tasks:

- name: install the Debian packages  
apt: name={{ item }} state=latest  
with\_items: “{{ packages }}”  
when: ansible\_os\_family == “Debian”

- name: install the RedHat packages  
yum: pkg={{ item }} state=latest  
with\_items: “{{ packages }}”  
when: ansible\_os\_family == “RedHat”

Is there anyway to have one task? I have packages array dynamically created. I wish at least I can just have tasks completely ignored if it is on the wrong OS, so it won’t be included…

---

<div class="post-metadata">

**Author:** ![Joaquin\_Menchaca](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@Joaquin\_Menchaca](https://forum.ansible.com/u/Joaquin_Menchaca)\
**Post date:** [July 7, 2015, 6:26pm UTC](https://forum.ansible.com/t/dynamic-package-installs/18706/2 "2015-07-07T18:26:17Z")

</div>

Would it be possible to do something like this?

tasks:

- include: “tasks/{{ ansible\_os\_family }}.yml”

I get this error

ERROR: file could not read: /Users/testuser/testarea/provisioning/tasks/{{ ansible\_os\_family }}.yml  
Ansible failed to complete successfully. Any error output should be  
visible above. Please fix these errors and try again.
