mysql_user module and LOCK TABLES

355 views
Skip to first unread message

Jonathan Rowlands

unread,
Oct 2, 2013, 4:49:55 PM10/2/13
to ansible...@googlegroups.com
I am trying to run the following:

- name: gitlab | mysql | ensure database user gitlab has necessary privleges
  mysql_user: state=present name=gitlab priv=gitlabhq_production.*:SELECT,LOCK TABLES,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER

The "LOCK TABLES" priv is a problem though since it has a space. Is there any way around this?
Message has been deleted

Jonathan Rowlands

unread,
Oct 2, 2013, 4:57:33 PM10/2/13
to ansible...@googlegroups.com
TASK: [gitlab | mysql | ensure database user gitlab has necessary privileges] *** 
failed: [192.168.0.13] => {"failed": true, "item": ""}
msg: this module requires key=value arguments (['state=present', 'name=gitlab', 'priv=gitlabhq_production.*:SELECT,LOCK', 'TABLES,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER'])

James Cammarata

unread,
Oct 2, 2013, 5:00:21 PM10/2/13
to ansible...@googlegroups.com
Escape the space: "LOCK\ TABLES". The parsing is done by the python shlex module if I remember right, so this should get you past the issue.


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--

James Cammarata <jcamm...@ansibleworks.com>
Sr. Software Engineer, AnsibleWorks, Inc.
http://www.ansibleworks.com/

Jonathan Rowlands

unread,
Oct 2, 2013, 5:04:45 PM10/2/13
to ansible...@googlegroups.com
Doh, I should have known. Thanks that worked.

Michael DeHaan

unread,
Oct 2, 2013, 5:51:31 PM10/2/13
to ansible...@googlegroups.com
An easier way do to this would be to just quote the entire string.

shlex understands quotes and is pretty smart.

priv="gitlabhq_production.*:SELECT,LOCK TABLES,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER"




Michael DeHaan <mic...@ansibleworks.com>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/

prateek gupta

unread,
Apr 15, 2014, 6:53:37 AM4/15/14
to ansible...@googlegroups.com
Can you please cross check this 
Im trying to create a user but it gets executed but the user is not getting created in my RDS mysql DB .


--------------------
---
#creating a sql user
 - hosts: localhost
   tasks:
    #- name: test
   - mysql_user: login_host=abcde.us-west-2.rds.amazonaws.com priv=*.*:SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,RELOAD,PROCESS,REFERENCES,INDEX,ALTER,SHOWDATABASES,CREATETEMPORARYTABLES,LOCKTABLES,EXECUTE,REPLICATIONSLAVE,REPLICATIONCLIENT,CREATEVIEW,SHOWVIEW,CREATEROUTINE,ALTERROUTINE,CREATEUSER,EVENT login_port=3306 login_user=klm login_password=abc name=marley password=klmsrib123 state=absent
Reply all
Reply to author
Forward
0 new messages