Php_extensions_custom must be formatted as dicts

If you try to add custom PHP extensions via group_vars/all/main.yml using the syntax suggested in several answers (e.g. to install ImageMagick)…

  - php-imagick

You’ll get this error:

The following variables must be formatted as dicts:
  - php_extensions_custom

This is the right syntax:

  php-imagick: "{{ apt_package_state }}"

Bye :wink:


I ran into this when updating a copy of Trellis for a site that needed soap. I figured it out, too, but I wonder if a commented-out example would help future generations.

1 Like


Can anyone explain what that apt_package_state part does?


Sorry for reviving this discussion, but will WordPress use ImageMagick/Imagick instead of PHP GD?
Must a plugin be used for forcing WordPress to use ImageMagick/Imagick instead of PHP GD?

Three years later, I needed php-gd for a plugin which relies on createimagefromstring().

While setting php_extensions_custom to php-gd: "{{ apt_package_state }}" output a success: changed: [] => (item=php-gd), it DID NOT install the file(s) into /etc/php/8.0/mods-available/.

It needed to be php8.0-gd: "{{ apt_package_state }}"

I was hoping to use "php{{ php_version }}-gd": "{{ apt_package_state }}", but that tried to install, literally and:

No package matching 'php{{ php_version }}-gd' is available

Hopefully that’s worth reviving this dusty old thread for.