geerlingguy / ansible-role-php-versions

Ansible Role - PHP Versions
https://galaxy.ansible.com/geerlingguy/php-versions/
MIT License
98 stars 73 forks source link

PHP 7.3 CLI gets installed if purging 7.2 and installing 7.1 #41

Closed geerlingguy closed 5 years ago

geerlingguy commented 5 years ago

This is a weird corner case that currently only seems to occur if you already have PHP 7.2 installed (as the geerlingguy/drupal-vm base box for Vagrant does), and you set php_version to 7.1... see https://github.com/geerlingguy/drupal-vm/issues/1963 for all the gory details.

In local testing, adding the following task in tasks/setup-Debian.yml seems to fix the issue:

- name: Purge PHP version packages (besides the currently chosen php_version).
  apt:
    name: "{{ php_versions_debian | reject('search', 'php' ~ php_version) | list }}"
    state: absent
    purge: true
    force: true
  register: php_version_purge

- name: Also purge php-common package if any versions were just purged.
  apt:
    name: php-common
    state: absent
    purge: true
    force: true
  when: php_version_purge.changed | bool