No packages matching ** is available in ansible

ansiblepackages

I'm trying to install a list of packages with ansible, and I can't seem to understand what the problem is.

- name: Add PHP 7.2 repo
  apt_repository:
         repo: ppa:ondrej/php
         state: present
  register: ppastable

- name: install php7.2-fpm and all necessary modules
  apt: name={{ item }} state=present
  with_items:
     - php7.2-fpm
     - php7.2-gd
     - php7.2-curl
     - php7.2-mysql
     - php7.2-mcrypt
     - php7.2-mbstring
     - php7.2-xml
  update_cache: true
  when: ppastable is success

However, when I run the playbook, I get the following error:

failed: [172.31.110.103] (item=[u'php7.2-fpm', u'php7.2-gd', u'php7.2-curl', u'php7.2-mysql', u'php7.2-mcrypt', u'php7.2-mbstring', u'php7.2-xml']) => {"changed": false, "item": ["php7.2-fpm", "php7.2-gd", "php7.2-curl", "php7.2-mysql", "php7.2-mcrypt", "php7.2-mbstring", "php7.2-xml"], "msg": "No package matching 'php7.2-mcrypt' is available"}

On the server I'm testing this on, all the packages can be installed. That's not a problem. Any ideas what's going on?
I'm running ansible 2.6.3 on ubuntu 16.04 and I'm trying to install the packages also on another system running the same OS.

Best Answer

The error you received states, in relevant part:

No package matching 'php7.2-mcrypt' is available

This is because this feature was removed from PHP in 7.2, so there is no longer a corresponding Ubuntu/Debian package.

The docs state:

This feature was DEPRECATED in PHP 7.1.0, and REMOVED in PHP 7.2.0.

The feature is still available as an external PECL package. But unlike in Red Hat/Fedora, which has a package for PECL mcrypt for PHP 7.2, Ubuntu/Debian packagers have chosen not to package it. You may still be able to install it manually from PECL if you have ancient PHP code that needs it.