# mysql\_user cannot find an installed package

**URL:** <https://forum.ansible.com/t/mysql-user-cannot-find-an-installed-package/31279>\
**Category:** Ansible Project\
**Created:** [September 13, 2019, 6:55pm UTC](https://forum.ansible.com/t/mysql-user-cannot-find-an-installed-package/31279 "2019-09-13T18:55:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mauricio\_Tavares](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Mauricio\_Tavares](https://forum.ansible.com/u/Mauricio_Tavares)\
**Post date:** [September 13, 2019, 6:55pm UTC](https://forum.ansible.com/t/mysql-user-cannot-find-an-installed-package/31279/1 "2019-09-13T18:55:48Z")

</div>

Trying to add a user to a mysql DB. Some relevant lines from playbook are:

mysql\_packagelist:  
&nbsp;&nbsp;- python2-PyMySQL  
[...]  
- name: Install db prereqs  
&nbsp;&nbsp;package: name="{{mysql\_packagelist}}" state=latest  
[...]  
- name: Create a db user  
&nbsp;&nbsp;mysql\_user:  
&nbsp;&nbsp;&nbsp;&nbsp;name: "{{ db\_user }}"  
&nbsp;&nbsp;&nbsp;&nbsp;password: "{{ db\_password }}"  
&nbsp;&nbsp;&nbsp;&nbsp;host: localhost  
&nbsp;&nbsp;&nbsp;&nbsp;priv: '\*.\*:ALL'  
&nbsp;&nbsp;&nbsp;&nbsp;state: present

When I run it, I get  
[...]  
TASK [db : Install db prereqs] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [server]

TASK [db : Install db] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [server]

TASK [db : create mysql-files] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [server]

TASK [db : Install db] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: [server]

TASK [db : Create a db user] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /home/raub/dev/ansible/roles/db/tasks/main.yml:43  
\<box.in.example.com\> ESTABLISH SSH CONNECTION FOR USER: root  
\<box.in.example.com\> SSH: EXEC ssh -C -o ControlMaster=auto -o  
ControlPersist=60s -o Port=2027 -o  
'IdentityFile="/home/raub/.ssh/docker-test"' -o KbdInteractiveAuth  
entication=no -o  
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,p  
ublickey -o PasswordAuthentication=no -o 'User="root"' -o  
ConnectTimeout=10 -o Con  
trolPath=/home/raub/.ansible/cp/b6a1389d8c box.in.example.com '/bin/sh  
-c '"'"'ech  
o ~root && sleep 0'"'"''  
\<box.in.example.com\> (0, '/root\n', '')  
\<box.in.example.com\> ESTABLISH SSH CONNECTION FOR USER: root  
\<box.in.example.com\> SSH: EXEC ssh -C -o ControlMaster=auto -o  
ControlPersist=60s  
-o Port=2027 -o 'IdentityFile="/home/raub/.ssh/docker-test"' -o  
KbdInteractiveAuth  
entication=no -o  
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,p  
ublickey -o PasswordAuthentication=no -o 'User="root"' -o  
ConnectTimeout=10 -o Con  
trolPath=/home/raub/.ansible/cp/b6a1389d8c box.in.example.com '/bin/sh  
-c '"'"'( u  
mask 77 && mkdir -p "` echo  
/root/.ansible/tmp/ansible-tmp-1568390316.23-256200089  
709623 `" && echo ansible-tmp-1568390316.23-256200089709623="` echo  
/root/.ansible  
/tmp/ansible-tmp-1568390316.23-256200089709623 `" ) && sleep 0'"'"''  
\<box.in.example.com\> (0,  
'ansible-tmp-1568390316.23-256200089709623=/root/.ansible  
/tmp/ansible-tmp-1568390316.23-256200089709623\n', '')  
Using module file  
/usr/lib/python2.7/dist-packages/ansible/modules/database/mysql/  
mysql\_user.py  
\<box.in.example.com\> PUT  
/home/raub/.ansible/tmp/ansible-local-115939mceb1/tmpQXP2  
Mp TO /root/.ansible/tmp/ansible-tmp-1568390316.23-256200089709623/AnsiballZ\_mysql  
\_user.py  
\<box.in.example.com\> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o  
ControlPersis  
t=60s -o Port=2027 -o 'IdentityFile="/home/raub/.ssh/docker-test"' -o  
KbdInteracti  
veAuthentication=no -o  
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostb  
ased,publickey -o PasswordAuthentication=no -o 'User="root"' -o  
ConnectTimeout=10  
-o ControlPath=/home/raub/.ansible/cp/b6a1389d8c '[box.in.example.com]'  
\<box.in.example.com\> (0, 'sftp\> put  
/home/raub/.ansible/tmp/ansible-local-115939mc  
eb1/tmpQXP2Mp /root/.ansible/tmp/ansible-tmp-1568390316.23-256200089709623/Ansibal  
lZ\_mysql\_user.py\n', '')  
\<box.in.example.com\> ESTABLISH SSH CONNECTION FOR USER: root  
\<box.in.example.com\> SSH: EXEC ssh -C -o ControlMaster=auto -o  
ControlPersist=60s  
-o Port=2027 -o 'IdentityFile="/home/raub/.ssh/docker-test"' -o  
KbdInteractiveAuth  
entication=no -o  
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,p  
ublickey -o PasswordAuthentication=no -o 'User="root"' -o  
ConnectTimeout=10 -o Con  
trolPath=/home/raub/.ansible/cp/b6a1389d8c box.in.example.com '/bin/sh  
-c '"'"'chmod u+x  
/root/.ansible/tmp/ansible-tmp-1568390316.23-256200089709623/  
/root/.ansibl  
e/tmp/ansible-tmp-1568390316.23-256200089709623/AnsiballZ\_mysql\_user.py  
&& sleep 0  
'"'"''  
\<box.in.example.com\> (0, '', '')  
\<box.in.example.com\> ESTABLISH SSH CONNECTION FOR USER: root  
\<box.in.example.com\> SSH: EXEC ssh -C -o ControlMaster=auto -o  
ControlPersist=60s  
-o Port=2027 -o 'IdentityFile="/home/raub/.ssh/docker-test"' -o  
KbdInteractiveAuth  
entication=no -o  
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,p  
ublickey -o PasswordAuthentication=no -o 'User="root"' -o  
ConnectTimeout=10 -o Con  
trolPath=/home/raub/.ansible/cp/b6a1389d8c -tt box.in.example.com  
'/bin/sh -c '"'"  
'/usr/bin/python  
/root/.ansible/tmp/ansible-tmp-1568390316.23-256200089709623/Ansi  
ballZ\_mysql\_user.py && sleep 0'"'"''  
\<box.in.example.com\> (1, '\r\n{"msg": "The PyMySQL (Python 2.7 and  
Python 3.X) or  
MySQL-python (Python 2.X) module is required.", "failed": true,  
"invocation": {"mo  
dule\_args": {"update\_password": "always", "login\_user": null,  
"host\_all": false, "  
priv": "\*.\*:ALL", "sql\_log\_bin": true, "state": "present",  
"encrypted": false, "cl  
ient\_key": null, "connect\_timeout": 30, "config\_file":  
"/root/.my.cnf", "ca\_cert":  
null, "login\_host": "localhost", "append\_privs": false,  
"login\_unix\_socket": null  
, "host": "localhost", "user": "safeuser", "login\_password": null,  
"check\_implicit  
\_admin": false, "password": "VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER",  
"login\_port": 3  
306, "name": "safeuser", "client\_cert": null}}}\r\n', 'Shared  
connection to box.in  
.example.com closed.\r\n')  
\<box.in.example.com\> Failed to connect to the host via ssh: Shared  
connection to b  
ox.in.example.com closed.  
\<box.in.example.com\> ESTABLISH SSH CONNECTION FOR USER: root  
\<box.in.example.com\> SSH: EXEC ssh -C -o ControlMaster=auto -o  
ControlPersist=60s  
-o Port=2027 -o 'IdentityFile="/home/raub/.ssh/docker-test"' -o  
KbdInteractiveAuth  
entication=no -o  
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,p  
ublickey -o PasswordAuthentication=no -o 'User="root"' -o  
ConnectTimeout=10 -o Con  
trolPath=/home/raub/.ansible/cp/b6a1389d8c box.in.example.com '/bin/sh  
-c '"'"'rm  
-f -r /root/.ansible/tmp/ansible-tmp-1568390316.23-256200089709623/ \>  
/dev/null 2\>  
&1 && sleep 0'"'"''  
\<box.in.example.com\> (0, '', '')  
fatal: [safebank]: FAILED! =\> {  
&nbsp;&nbsp;&nbsp;&nbsp;"changed": false,  
&nbsp;&nbsp;&nbsp;&nbsp;"invocation": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"module\_args": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"append\_privs": false,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ca\_cert": null,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"check\_implicit\_admin": false,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"client\_cert": null,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"client\_key": null,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"config\_file": "/root/.my.cnf",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"connect\_timeout": 30,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"encrypted": false,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"host": "localhost",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"host\_all": false,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"login\_host": "localhost",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"login\_password": null,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"login\_port": 3306,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"login\_unix\_socket": null,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"login\_user": null,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"name": "safeuser",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"password": "VALUE\_SPECIFIED\_IN\_NO\_LOG\_PARAMETER",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"priv": "\*.\*:ALL",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"sql\_log\_bin": true,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"state": "present",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"update\_password": "always",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"user": "safeuser"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;},  
&nbsp;&nbsp;&nbsp;&nbsp;"msg": "The PyMySQL (Python 2.7 and Python 3.X) or MySQL-python  
(Python 2.X) m  
odule is required."  
}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
server : ok=12 changed=1 unreachable=0  
failed=1 skipped=8 rescued=0 ignored=0

raub@desktop:~/dev/ansible$

However (this box only has python 2.7, not 3.X), the package it wants is there:

[root@box ~]# rpm -qav | grep -i pymysql  
python2-PyMySQL-0.9.2-2.el7.noarch  
[root@box ~]# yum list installed | grep -i pymysql  
python2-PyMySQL.noarch 0.9.2-2.el7 @epel  
[root@box ~]#

And that is the only package matched when I do "yum search pymysql":

============================= N/S matched: pymysql =============================  
python2-PyMySQL.noarch : Pure-Python MySQL client library  
python36-PyMySQL.noarch : Pure-Python MySQL client library
