Hello. I'm trying to figure out how to submit a bug report and patch,
but am not very familiar with git. I'm on a Red Hat Enterprise Linux 7
box running Ansible installed from the EPEL repository:
# rpm -q ansible
ansible-2.3.1.0-1.el7.noarch
The problem is in the mysql_user module. It seems to not parse
permissions correctly if the database name includes a colon character
(:). For example:
- name: Ensure database users are present.
mysql_user: name="wordpress" host="localhost"
password="SECRET_PASSWORD" state=present
priv="*.*:USAGE/`lnx-www-prod:wordpress`.*:ALL"
append_privs="no"
That will fail like so:
failed: [lnx-www-prod] (item={u'password': u'SECRET_PASSWORD', u'name':
u'wordpress', u'priv': u'*.*:USAGE/`lnx-www-prod:wordpress`.*:ALL'}) =>
{"failed": true, "item": {"name": "wordpress", "password":
"SECRET_PASSWORD", "priv": "*.*:USAGE/`lnx-www-prod:wordpress`.*:ALL"},
"msg": "invalid privileges string: Invalid privileges specified:
frozenset(['WORDPRESS`.*'])"}
I tracked down the problem and have a really simple patch for it. I'm
not sure if this is the best way to fix the problem, but it works for me:
--- mysql_user.py~ 2017-06-01 12:00:04.000000000 -0500
+++ mysql_user.py 2017-06-27 16:29:25.047686016 -0500
@@ -471,7 +471,7 @@
output = {}
privs =
for item in priv.strip().split('/'):
- pieces = item.strip().split(':')
+ pieces = item.strip().rsplit(':', 1)
dbpriv = pieces[0].rsplit(".", 1)
# Do not escape if privilege is for database or table, i.e.
# neither quote *. nor .*
Is this the right place to post the fix so that it can be reviewed and
possibly included?
Thanks in advance,
Dan