---

- name: Setup deb.sury.org repository - Add GPG key
  get_url:
    url: https://packages.sury.org/php/apt.gpg
    dest: /etc/apt/trusted.gpg.d/sury.gpg
    mode: "0644"

- name: Setup deb.sury.org repository - Install apt-transport-https
  apt:
    state: present
    name: apt-transport-https

- name: Setup deb.sury.org repository - Add preferences file
  copy:
    src: sury.preferences
    dest: /etc/apt/preferences.d/z-sury

- name: Setup deb.sury.org repository - Add source list
  apt_repository:
    repo: "deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main"
    filename: sury
    state: present

- name: "Override package list for Sury (Debian 9 or later)"
  set_fact:
    php_stretch_packages:
      - php-cli
      - php-gd
      - php-intl
      - php-imap
      - php-ldap
      - php-mysql
      # php-mcrypt is no longer packaged for PHP 7.2
      - php-pgsql
      - php-gettext
      - php-curl
      - php-ssh2
      - composer
      - libphp-phpmailer
