# auto package version selection?

**URL:** <https://forum.ansible.com/t/auto-package-version-selection/22867>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [October 24, 2016, 2:06pm UTC](https://forum.ansible.com/t/auto-package-version-selection/22867 "2016-10-24T14:06:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![david1](https://avatars.discourse-cdn.com/v4/letter/d/73ab20/32.png) [@david1](https://forum.ansible.com/u/david1)\
**Post date:** [October 24, 2016, 2:06pm UTC](https://forum.ansible.com/t/auto-package-version-selection/22867/1 "2016-10-24T14:06:13Z")

</div>

Hi,

I’m deploying an application via Ansible on Ubuntu. The application’s .deb requires several php modules but misses some so in my playbook I have the following.

- name: Install php packages  
apt: name={{item}} state=installed  
with\_items:
- php5-gd
- php5-imagick
- php5-pgsql

Is there a way to do the above without specifying ‘5’ so that apt or Ansible will automatically select the version of php modules to install based on the existing php package versions installed?

---

<div class="post-metadata">

**Author:** ![Alexander\_H\_Laughlin](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@Alexander\_H\_Laughlin](https://forum.ansible.com/u/Alexander_H_Laughlin)\
**Post date:** [October 24, 2016, 11:38pm UTC](https://forum.ansible.com/t/auto-package-version-selection/22867/2 "2016-10-24T23:38:18Z")

</div>

Assuming you know ahead of time or have a way of finding out during playbook execution which version is installed I don’t see why it wouldn’t be possible. You could create a couple of yaml dictionaries for the purpose and iterate over whichever one is appropriate using a when statement.
