---
- name: Converge
  hosts: all
  become: true

  vars:
    php_enable_webserver: false
    php_install_from_source: true
    php_source_clone_dir: /root/php-src
    php_source_make_command: "make --jobs=2"
    php_version: "7.4.8"
    php_source_version: "php-{{ php_version }}"
    php_memory_limit: "192M"

  pre_tasks:
    - name: Update apt cache.
      apt: update_cache=true cache_valid_time=600
      when: ansible_os_family == 'Debian'
      changed_when: false

  roles:
    - role: geerlingguy.git
    - role: geerlingguy.php

  post_tasks:
    - name: Confirm PHP configuration is correct.
      shell: php -i | grep 'memory_limit.*192'
      changed_when: false

    - name: Check the installed PHP version.
      shell: '/usr/bin/php --version | grep -qF "PHP {{ php_version }}"'
      changed_when: false
