---
- name: Ensure Nginx is installed
  chocolatey.chocolatey.win_chocolatey:
    name: nginx
    state: present
    package_params: /installLocation:{{ nginx_install_path }}

- name: Ensure PHP packages are installed
  chocolatey.chocolatey.win_chocolatey:
    name: "{{ php_packages }}"
    state: present
    package_params: /InstallDir:{{ php_conf_paths[0] }}

- name: Fetch APCu DLL Archive
  ansible.windows.win_get_url:
    url: "{{ apcu_url }}"
    dest: "{{ php_conf_paths[0] }}/apcu.zip"

- name: Ensure to install APCu
  community.windows.win_unzip:
    src: "{{ php_conf_paths[0] }}/apcu.zip"
    dest: "{{ php_conf_paths[0] }}/ext"
    delete_archive: true

- name: Configure PHP Components
  block:
    - name: Configure php.ini
      include_tasks: windows/ini.yml

    - name: Configure apcu
      include_tasks: windows/apcu.yml

    - name: Configure opcache
      include_tasks: windows/opcache.yml

    - name: Configure fpm
      include_tasks: windows/fpm.yml
