# Incomprehensible error message

**URL:** <https://forum.ansible.com/t/incomprehensible-error-message/38654>\
**Category:** Ansible Project\
**Created:** [January 18, 2024, 4:47am UTC](https://forum.ansible.com/t/incomprehensible-error-message/38654 "2024-01-18T04:47:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HobsonI](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/hobsoni/32/4960_2.png) [@HobsonI](https://forum.ansible.com/u/HobsonI)\
**Post date:** [January 18, 2024, 4:47am UTC](https://forum.ansible.com/t/incomprehensible-error-message/38654/1 "2024-01-18T04:47:46Z")

</div>

Hi All,

I am attempting to use Ansible to create a MySQL backup user. It should be able to read and lock tables for everything. The step in the playbook is this.

- name: create user - GRANT SELECT, PROCESS, LOCK TABLES ON \*.\* TO `backup`@`localhost`  
&nbsp;&nbsp;&nbsp;community.mysql.mysql\_user:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user: backup  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;host: localhost  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;login\_password: \<redacted\>  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;priv: '\*.\*:SELECT, PROCESS, LOCK TABLES'

The error message is:  
fatal: [ubuntu2004.hcs]: FAILED! =\> {"changed": false, "msg": "invalid privileges string: Invalid privileges specified: frozenset({' PROCESS, LOCK TABLES'})"}

I can see nothing wrong with the priv line. Can someone spot it?

Regards

Ian

---

<div class="post-metadata">

**Author:** ![skratbag](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/skratbag/32/4836_2.png) [@skratbag](https://forum.ansible.com/u/skratbag)\
**Post date:** [January 18, 2024, 5:36am UTC](https://forum.ansible.com/t/incomprehensible-error-message/38654/2 "2024-01-18T05:36:05Z")

</div>

Hi Ian,

There was a similar issue back in 2015/16, see [https://github.com/ansible/ansible/issues/29611](https://github.com/ansible/ansible/issues/29611) and also [https://stackoverflow.com/questions/28908155/ansible-mysql-user-priv-invalid-privileges-string-invalid-privileges-specifi](https://stackoverflow.com/questions/28908155/ansible-mysql-user-priv-invalid-privileges-string-invalid-privileges-specifi) amongst quite a few others. They all referenced spaces being in the privilege string.

Are you able to try that without the spaces between privileges?

Cheers  
David

---

<div class="post-metadata">

**Author:** ![Andy\_Smith](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@Andy\_Smith](https://forum.ansible.com/u/Andy_Smith)\
**Post date:** [January 18, 2024, 3:12pm UTC](https://forum.ansible.com/t/incomprehensible-error-message/38654/3 "2024-01-18T15:12:11Z")

</div>

Hi Ian,

> &nbsp;&nbsp;community.mysql.mysql\_user:  
> &nbsp;&nbsp;&nbsp;&nbsp;user: backup  
> &nbsp;&nbsp;&nbsp;&nbsp;host: localhost  
> &nbsp;&nbsp;&nbsp;&nbsp;login\_password: \<redacted\>  
> &nbsp;&nbsp;&nbsp;&nbsp;priv: '\*.\*:SELECT, PROCESS, LOCK TABLES'
> 
> The error message is:  
> fatal: [ubuntu2004.hcs]: FAILED! =\> {"changed": false, "msg": "invalid  
> privileges string: Invalid privileges specified: frozenset({' PROCESS, LOCK  
> TABLES'})"}
> 
> I can see nothing wrong with the priv line. Can someone spot it?

I've found the format of the mysql privileges to be extremely picky.  
Aside from having to get the syntax correct, also look out for it  
seeing privileges in a different order, so applying them again at  
every run.

I found that whole-table privileges required no space between, while  
column-based privs need spaces between. Example:

priv:  
&nbsp;&nbsp;"somedb.sometable": "SELECT,INSERT,UPDATE,DELETE"  
&nbsp;&nbsp;"somedb.othertable": "SELECT (ID, ACOL, BCOL),\  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INSERT"

If you run ansible with two or three -v you'll see the MySQL  
commands it executes so you can check what it's doing.

Thanks,  
Andy
