2017-05-19 19:36:36 +02:00
|
|
|
---
|
2017-05-24 03:58:57 +02:00
|
|
|
- name: Set the correct opcache filename (Ubuntu/Debian).
|
2017-05-19 19:36:36 +02:00
|
|
|
set_fact:
|
|
|
|
php_opcache_conf_filename: "10-opcache.ini"
|
|
|
|
|
2020-02-20 23:44:42 +01:00
|
|
|
- name: Ensure dirmngr is installed (gnupg dependency).
|
|
|
|
apt:
|
|
|
|
name: dirmngr
|
|
|
|
state: present
|
|
|
|
|
2017-05-19 19:36:36 +02:00
|
|
|
- name: Add repository for PHP versions (Ubuntu).
|
|
|
|
apt_repository: repo='ppa:ondrej/php'
|
|
|
|
when: ansible_distribution == "Ubuntu"
|
|
|
|
|
|
|
|
# Debian-specific tasks.
|
|
|
|
- name: Add dependencies for PHP versions (Debian).
|
|
|
|
apt:
|
2018-09-30 19:45:02 +02:00
|
|
|
name:
|
|
|
|
- apt-transport-https
|
|
|
|
- ca-certificates
|
|
|
|
state: present
|
2017-05-19 19:36:36 +02:00
|
|
|
when: ansible_distribution == "Debian"
|
|
|
|
|
|
|
|
- name: Add Ondrej Sury's apt key (Debian).
|
|
|
|
apt_key:
|
|
|
|
url: https://packages.sury.org/php/apt.gpg
|
|
|
|
state: present
|
|
|
|
when: ansible_distribution == "Debian"
|
|
|
|
|
|
|
|
- name: Add Ondrej Sury's repo (Debian).
|
|
|
|
apt_repository:
|
|
|
|
repo: "deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main"
|
|
|
|
state: present
|
|
|
|
register: php_ondrej_debian_repo
|
|
|
|
when: ansible_distribution == "Debian"
|
|
|
|
|
|
|
|
- name: Update apt caches after repo is added (Debian).
|
2018-09-30 19:45:02 +02:00
|
|
|
apt: update_cache=true
|
2019-03-24 01:19:36 +01:00
|
|
|
when:
|
|
|
|
- php_ondrej_debian_repo.changed
|
|
|
|
- ansible_distribution == "Debian"
|
|
|
|
tags: ['skip_ansible_lint']
|
2017-05-19 19:36:36 +02:00
|
|
|
|
2019-04-18 19:24:49 +02:00
|
|
|
- name: Purge PHP version packages (besides the currently chosen php_version).
|
2017-05-19 19:36:36 +02:00
|
|
|
apt:
|
2019-04-18 19:24:49 +02:00
|
|
|
name: "{{ php_versions_debian | reject('search', 'php' ~ php_version) | list }}"
|
2017-05-19 19:36:36 +02:00
|
|
|
state: absent
|
2018-09-30 19:45:02 +02:00
|
|
|
purge: true
|
|
|
|
force: true
|
2019-08-29 21:34:30 +02:00
|
|
|
register: php_version_purge
|
2019-08-29 21:28:54 +02:00
|
|
|
|
|
|
|
- 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
|