Okay on my last post I wrote that the expect command to handle PECL install prompt is difficult to put into an Ansible playbook.
I just figured out a much easier solution.

printf "\n" | sudo pecl install zmq channel://pecl.php.net/zmq-1.1.2

This will act like an expect and automatically send “\n” to any prompt. It cannot send different messages conditionally like expect, but if you just want to throw in some Enter-keys, this’ll do the job.

So that’s an easy one-liner to include in my Ansible cookbook!