ansible-role-php-versions/tasks/setup-Debian.yml
luminouw 93f3fd3c34 Added Ondřej Surý GPG key ID for Debian repo
This commit adds the new key ID for the Debian repo of Ondřej Surý
to ensure the GPG key won't be downloaded by the apt_key module if
it's already installed on the system.

This modification is made for systems behind several firewalls or
filtering proxies on which the key is pre-deployed and when the
Ansible module doesn't work well with proxy env vars (eg. apt_key)
2021-02-22 16:43:14 +01:00

60 lines
1.6 KiB
YAML

---
- name: Set the correct opcache filename (Ubuntu/Debian).
set_fact:
php_opcache_conf_filename: "10-opcache.ini"
- name: Ensure dirmngr is installed (gnupg dependency).
apt:
name: dirmngr
state: present
- 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:
name:
- apt-transport-https
- ca-certificates
state: present
when: ansible_distribution == "Debian"
- name: Add Ondrej Sury's apt key (Debian).
apt_key:
url: https://packages.sury.org/php/apt.gpg
id: 15058500A0235D97F5D10063B188E2B695BD4743
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).
apt: update_cache=true
when:
- php_ondrej_debian_repo.changed
- ansible_distribution == "Debian"
tags: ['skip_ansible_lint']
- 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