This is how I managed to test your scenario manually against the php:7.0-apache
docker image. Note that this image is based on debian:stretch
. In your question, you are following the install guide for ubuntu which will fail anyway in debian stretch.
I'm using the correct scenario below. See the ansible install documentation for more details. I also kept the install of sudo which was in your initial provisioning script.
apt-get update
apt-get install -y gnupg sudo
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
echo deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main >> /etc/apt/sources.list
apt-get update
apt-get install -y ansible
apt-get clean
After playing this, result:
root@18ab6da8ac92:/var/www/html# ansible --version
ansible 2.9.4
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516]
Now, the above is installing ansible from deb packages that will run in python 2.7 that has been obsoleted. I much rather prefer the following scenario using pip that will install ansible as well but in python3 and does not need to add a supplementary apt repo neither requires to install gnupg
apt-get update
apt-get install -y python3-pip
pip3 install --upgrade pip
pip install ansible
apt-get clean
And the result
root@e6b73a5f1d59:/var/www/html# ansible --version
ansible 2.9.4
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.5/dist-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.5.3 (default, Sep 27 2018, 17:25:39) [GCC 6.3.0 20170516]