# Issue using apt with prefix

**URL:** <https://forum.ansible.com/t/issue-using-apt-with-prefix/14056>\
**Category:** Ansible Project\
**Created:** [December 4, 2013, 4:08am UTC](https://forum.ansible.com/t/issue-using-apt-with-prefix/14056 "2013-12-04T04:08:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Heeney](https://avatars.discourse-cdn.com/v4/letter/p/f475e1/32.png) [@Patrick\_Heeney](https://forum.ansible.com/u/Patrick_Heeney)\
**Post date:** [December 4, 2013, 4:08am UTC](https://forum.ansible.com/t/issue-using-apt-with-prefix/14056/1 "2013-12-04T04:08:58Z")

</div>

```auto
I am using a third party yaml file to load in php packages (the yaml file can't really change) using a prefix on apt. 

```

```auto

```

```auto
# doesn't work

- name: PHP | MAIN | Install php packages - intl1
  apt: >
    pkg=php5-{{ item }}
    state=latest
  with_items: 
    - cli
    - intl
    - mcrypt
    - curl
  sudo: yes

# error

failed: [localhost] => (item=cli,intl,mcrypt,curl) => {"failed": true, "item": "cli,intl,mcrypt,curl"}
msg: No package matching 'intl' is available

# works

- name: PHP | MAIN | Install php packages - intl2
  apt: >
    pkg=php5-{{ item }}
    state=latest
  with_items: 
    - intl
    - mcrypt
    - curl
  sudo: yes

```

```auto

```

```auto
# in a perfect world (works)

```

```auto

```

---

<div class="post-metadata">

**Author:** ![tannerjc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/tannerjc/32/985_2.png) [@tannerjc](https://forum.ansible.com/u/tannerjc)\
**Post date:** [December 4, 2013, 4:15am UTC](https://forum.ansible.com/t/issue-using-apt-with-prefix/14056/2 "2013-12-04T04:15:09Z")

</div>

One possible solution is to add a pkg\_prefix option to the apt and yum modules.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [December 4, 2013, 2:51pm UTC](https://forum.ansible.com/t/issue-using-apt-with-prefix/14056/3 "2013-12-04T14:51:23Z")

</div>

Don’t prefix it for now and please make sure there is an open ticket, we can easily template the series prior to listification.

The linked commit is, I am pretty sure, not directly related.

– Michael

---

<div class="post-metadata">

**Author:** ![Patrick\_Heeney](https://avatars.discourse-cdn.com/v4/letter/p/f475e1/32.png) [@Patrick\_Heeney](https://forum.ansible.com/u/Patrick_Heeney)\
**Post date:** [December 4, 2013, 3:46pm UTC](https://forum.ansible.com/t/issue-using-apt-with-prefix/14056/4 "2013-12-04T15:46:36Z")

</div>

For completeness, posted at [https://github.com/ansible/ansible/issues/5166](https://github.com/ansible/ansible/issues/5166)

---

<div class="post-metadata">

**Author:** ![Tom\_Bamford1](https://avatars.discourse-cdn.com/v4/letter/t/43a26b/32.png) [@Tom\_Bamford1](https://forum.ansible.com/u/Tom_Bamford1)\
**Post date:** [March 29, 2014, 12:26am UTC](https://forum.ansible.com/t/issue-using-apt-with-prefix/14056/5 "2014-03-29T00:26:28Z")

</div>

If you really don’t want to expand all your package names, something like this may work for you:

- name: set apache module package prefix  
set\_fact: apache\_mod\_prefix=libapache2-mod-
- name: install additional modules  
apt: pkg=“{{ apache\_mod\_prefix }}{{ modules|join(‘,’ + apache\_mod\_prefix) }}”

(where `modules` is an array of package suffixes)
