I'm trying to find the most efficient way to install every PHP version and packages for each version without duplication.
I currently have this:
- name: Install PHP
apt:
name: "{{ packages.php_version }}-{{ packages.packages }}"
vars:
packages:
- { php_version: 5.6, packages: ['common', 'cli', 'opcache', 'mysql', 'mbstring', 'simplexml', 'curl', 'bcmath', 'ldap', 'gd', 'dom', 'zip', 'xml', 'readline', 'json', 'fpm', 'imagick']}
- { php_version: 7.0, packages: ['common', 'cli', 'opcache', 'mysql', 'mbstring', 'simplexml', 'curl', 'bcmath', 'ldap', 'gd', 'dom', 'zip', 'xml', 'readline', 'json', 'fpm', 'imagick']}
However, i cannot workout the selector to itterate over the packages.
I would like to have something where it basically loops over each php version and the packages for each, as they may be different.
Thanks
EDIT TO ANSWER Pretty much there for me! Thanks so much. I wanted to install all the PHP versions just just a selected one. So i did the following:
- name: Install PHP
apt:
name: "php{{ item.0.key }}-{{ item.1 }}"
loop: "{{ packages_dict | dict2items | subelements('value') }}"
Not sure if thats the best way? seems inefficient really but it works!