---
- name: Update apt cache
  apt:
    cache_valid_time: 86400
    update_cache: true

- name: Ensure PHP packages are installed
  apt:
    name: "{{ php_packages + php_packages_extra }}"
    state: present
    install_recommends: true
  register: php_package_install
  notify: restart webserver

- name: Delete APCu configuration file if this role will provide one
  file:
    path: "{{ item }}/{{ php_apc_conf_filename }}"
    state: absent
  loop: "{{ php_extension_conf_paths }}"
  when:
    - php_enable_apc
    - php_package_install.changed
  notify: restart webserver

- name: Delete OpCache configuration file if this role will provide one
  file:
    path: "{{ item }}/{{ php_opcache_conf_filename }}"
    state: absent
  loop: "{{ php_extension_conf_paths }}"
  when:
    - php_opcache_enable | bool
    - php_package_install.changed
  notify: restart webserver

- name: Run generic Linux tasks
  include_tasks: setup-Linux.yml
