Ansible + Ubuntu 18.04 + MySQL = "The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is required." : <p>I’m seeing the above message on multiple playbooks using Ansible 2.8 on Ubuntu 18.04. In the interests of simplicity I’ve reproduced it using this basic playbook for a single node Drupal server. <a href="https://github.com/geerlingguy/ansible-for-devops/tree/master/drupal" rel="noreferrer">https://github.com/geerlingguy/ansible-for-devops/tree/master/drupal</a>; this playbook works fine on earlier versions of ubuntu, but not on 18.04 which I understand includes python3 by default.</p>

<p>I’ve used vagrant to create the base machine, which shows the following:</p>

<pre><code>$ which python
/usr/bin/python
$ which python2
/usr/bin/python2
$ which python3
/usr/bin/python3
$ python --version
Python 2.7.15rc1
$ python2 --version
Python 2.7.15rc1
$ python3 --version
Python 3.6.7
</code></pre>

<p>Which seems to be telling me that both python 2 and python 3 are installed, but that 2.7 is the default as that is what responds to $ python --version. </p>

<p>I have tried all the suggestions described in this article: <a href="https://www.rollnorocks.com/2018/12/ansible-python-and-mysql-untangling-the-mess/" rel="noreferrer">https://www.rollnorocks.com/2018/12/ansible-python-and-mysql-untangling-the-mess/</a>
Including specifying the </p>

<pre><code>ansible_python_interpreter=/usr/bin/python3
</code></pre>

<p>But nothing affects the message. The edited -vvv output from the playbook run is below. Has anyone got any more ideas about either the problem or solution.</p>

<pre><code>TASK [Remove the MySQL test database.] ****************************************************************************************************************************
task path: /vagrant/provisioning/playbook.yml:96
&lt;10.1.1.11&gt; ESTABLISH SSH CONNECTION FOR USER: mt-ansible-user
&lt;10.1.1.11&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 
.
.
.
Using module file /usr/local/lib/python2.7/dist-packages/ansible/modules/database/mysql/mysql_db.py
&lt;10.1.1.11&gt; PUT /home/mt-tools-user/.ansible/tmp/ansible-local-21287bh5dK5/tmp7pOKOH TO /home/mt-ansible-user/.ansible/tmp/ansible-tmp-1558868136.49-16683638151793
1/AnsiballZ_mysql_db.py                                                                                                                                                                                                                       
&lt;10.1.1.11&gt; SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/mt-tools-user/.ssh/mt_ansible_rsa"' -o KbdInteractiveAuthent
ication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="mt-ansible-user"' -o ConnectTimeout=                                                                          
10 -o ControlPath=/home/mt-tools-user/.ansible/cp/af4de51057 '[10.1.1.11]'                                                                                                                                                                    
&lt;10.1.1.11&gt; (0, 'sftp&gt; put /home/mt-tools-user/.ansible/tmp/ansible-local-21287bh5dK5/tmp7pOKOH /home/mt-ansible-user/.ansible/tmp/ansible-tmp-1558868136.49-166836
381517931/AnsiballZ_mysql_db.py\n', '')                                                                                                                                                                                                       
&lt;10.1.1.11&gt; ESTABLISH SSH CONNECTION FOR USER: mt-ansible-user
&lt;10.1.1.11&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/mt-tools-user/.ssh/mt_ansible_rsa"' -o KbdInteractiveAuthenticatio
n=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="mt-ansible-user"' -o ConnectTimeout=10 -o                                                                           
ControlPath=/home/mt-tools-user/.ansible/cp/af4de51057 10.1.1.11 '/bin/sh -c '"'"'chmod u+x /home/mt-ansible-user/.ansible/tmp/ansible-tmp-1558868136.49-1668363815                                                                          
17931/ /home/mt-ansible-user/.ansible/tmp/ansible-tmp-1558868136.49-166836381517931/AnsiballZ_mysql_db.py &amp;&amp; sleep 0'"'"''                                                                                                                    
&lt;10.1.1.11&gt; (0, '', '')
&lt;10.1.1.11&gt; ESTABLISH SSH CONNECTION FOR USER: mt-ansible-user
&lt;10.1.1.11&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/mt-tools-user/.ssh/mt_ansible_rsa"' -o KbdInteractiveAuthenticatio
n=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="mt-ansible-user"' -o ConnectTimeout=10 -o                                                                           
ControlPath=/home/mt-tools-user/.ansible/cp/af4de51057 -tt 10.1.1.11 '/bin/sh -c '"'"'sudo -H -S -n  -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-qwjewg                                                                          
qckuyapsxnkbqoegainrkyiinc ; /usr/bin/python3 /home/mt-ansible-user/.ansible/tmp/ansible-tmp-1558868136.49-166836381517931/AnsiballZ_mysql_db.py'"'"'"'"'"'"'"'"' &amp;
&amp; sleep 0'"'"''
&lt;10.1.1.11&gt; (1, 'BECOME-SUCCESS-qwjewgqckuyapsxnkbqoegainrkyiinc\r\n\r\n{"msg": "The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python (Python 2.X) module is req
uired.", "failed": true, "invocation": {"module_args": {"db": "test", "state": "absent", "name": "test", "login_host": "localhost", "login_port": 3306, "encoding":
"", "collation": "", "connect_timeout": 30, "config_file": "/root/.my.cnf", "single_transaction": false, "quick": true, "ignore_tables": [], "login_user": null, "
login_password": null, "login_unix_socket": null, "target": null, "client_cert": null, "client_key": null, "ca_cert": null}}}\r\n', 'Shared connection to 10.1.1.11
closed.\r\n')
&lt;10.1.1.11&gt; Failed to connect to the host via ssh: Shared connection to 10.1.1.11 closed.
&lt;10.1.1.11&gt; ESTABLISH SSH CONNECTION FOR USER: mt-ansible-user
&lt;10.1.1.11&gt; SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'IdentityFile="/home/mt-tools-user/.ssh/mt_ansible_rsa"' -o KbdInteractiveAuthenticatio
n=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="mt-ansible-user"' -o ConnectTimeout=10 -o
ControlPath=/home/mt-tools-user/.ansible/cp/af4de51057 10.1.1.11 '/bin/sh -c '"'"'rm -f -r /home/mt-ansible-user/.ansible/tmp/ansible-tmp-1558868136.49-16683638151
7931/ &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'"'"''
&lt;10.1.1.11&gt; (0, '', '')
</code></pre>
