--- - name: "Install required PHP versions and extensions" ansible.builtin.apt: name: # Core PHP - "php{{ item }}" - "php{{ item }}-fpm" - "php{{ item }}-cli" # Common Laravel Extensions - "php{{ item }}-common" - "php{{ item }}-mysql" - "php{{ item }}-pgsql" - "php{{ item }}-xml" - "php{{ item }}-zip" - "php{{ item }}-mbstring" - "php{{ item }}-curl" - "php{{ item }}-bcmath" state: present loop: "{{ php_versions_to_install }}" when: php_versions_to_install is defined and php_versions_to_install | length > 0 - name: "Ensure all PHP-FPM services are enabled and started" ansible.builtin.service: name: "php{{ item }}-fpm" enabled: yes state: started loop: "{{ php_versions_to_install }}" when: php_versions_to_install is defined and php_versions_to_install | length > 0