I have a playbook that goes like this:
- name: Install php extensions
ansible.builtin.apt:
pkg:
- php{{ php_version }}{{ item.pkg_extension }}
loop:
- { pkg_extension: -mysql }
- { pkg_extension: -bz2 }
- { pkg_extension: -curl }
- { pkg_extension: -gd }
- { pkg_extension: -imap }
- { pkg_extension: -mbstring }
- { pkg_extension: -xml }
- { pkg_extension: -zip }
when: php_key_setup is succeeded and nginx_install is succeeded and php_base_install is succeeded
register: php_install
Sometimes for reasons unknown to me, this fails for one of the packages in the loop. I want to pass these packages as a list or a dictionary to the apt module instead, like in
- name: Optimal yum
ansible.builtin.yum:
name: "{{ list_of_packages }}"
state: present
How can I create this list from this loop, concatenating everything without adding an extra step to create this list and reuse it afterwards?