Trying to add a user to a mysql DB. Some relevant lines from playbook are:
mysql_packagelist:
- python2-PyMySQL
[...]
- name: Install db prereqs
package: name="{{mysql_packagelist}}" state=latest
[...]
- name: Create a db user
mysql_user:
name: "{{ db_user }}"
password: "{{ db_password }}"
host: localhost
priv: '*.*:ALL'
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! => {
"changed": false,
"invocation": {
"module_args": {
"append_privs": false,
"ca_cert": null,
"check_implicit_admin": false,
"client_cert": null,
"client_key": null,
"config_file": "/root/.my.cnf",
"connect_timeout": 30,
"encrypted": false,
"host": "localhost",
"host_all": false,
"login_host": "localhost",
"login_password": null,
"login_port": 3306,
"login_unix_socket": null,
"login_user": null,
"name": "safeuser",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"priv": "*.*:ALL",
"sql_log_bin": true,
"state": "present",
"update_password": "always",
"user": "safeuser"
}
},
"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