--- - when: php_sury_repo block: - name: sury.org repo requirements apt: pkg: - apt-transport-https - ca-certificates - name: sury.org repo key get_url: url: https://packages.sury.org/php/apt.gpg dest: /etc/apt/trusted.gpg.d/php.gpg checksum: sha256:ace18406ecfe44292566bba8fc2d922370bc9531808a6319019bada3f7b3eab0 - name: sury.org repo apt_repository: repo: deb https://packages.sury.org/php/ {{ansible_distribution_release}} main filename: php - name: ensure sury.org repo is not present file: path: /etc/apt/sources.list.d/php.list state: absent - when: not php_version is defined block: - name: debian php-cli package apt: pkg: php-cli - name: get installed php version command: php args: stdin: '' register: _get_installed_php_version changed_when: false - set_fact: php_version: "{{ _get_installed_php_version.stdout.split('.')[0:2]|join('.') }}" - name: debian packages apt: pkg: - php{{php_version}}-cli - libapache2-mod-php{{php_version}} - php{{php_version}}-xml - php{{php_version}}-json - php{{php_version}}-mbstring