Issue using apt with prefix

207 views
Skip to first unread message

Patrick Heeney

unread,
Dec 3, 2013, 11:08:58 PM12/3/13
to ansible...@googlegroups.com
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. 

# 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

# in a perfect world (works)

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

This looks related to: https://github.com/ansible/ansible/commit/7ac5e462efbc850dd39ce5746accf3012530ed98

James Tanner

unread,
Dec 3, 2013, 11:15:09 PM12/3/13
to ansible...@googlegroups.com
--
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-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

One possible solution is to add a pkg_prefix option to the apt and yum modules.

Michael DeHaan

unread,
Dec 4, 2013, 9:51:23 AM12/4/13
to ansible...@googlegroups.com
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

Patrick Heeney

unread,
Dec 4, 2013, 10:46:36 AM12/4/13
to ansible...@googlegroups.com

Tom Bamford

unread,
Mar 28, 2014, 8:26:28 PM3/28/14
to ansible...@googlegroups.com
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)
Reply all
Reply to author
Forward
0 new messages