Hi
I am trying to add multiple users with mysql_user module:
- name: Create local DB users and set permissions
action: mysql_user login_user=root login_password=xxxxxxx name={{ item[0] }} password={{ item[1] }} priv=.:ALL host={{ item[2] }}
with_nested: - [‘user1’, ‘user2’, ‘user3’]
- [‘pass1’, ‘pass2’, ‘pass3’]
- [‘localhost’, ‘localhost’, ‘%’]
Is this correct syntax? Because it does not work:
failed: [localhost] => (item=[‘user1’, ‘pass1’, ‘localhost’]) => {“failed”: true, “item”: [“user1”, “pass1”, “localhost”], “parsed”: false}
invalid output was: Traceback (most recent call last):
File “/root/.ansible/tmp/ansible-1379784647.74-7643490092735/mysql_user”, line 1348, in
main()
File “/root/.ansible/tmp/ansible-1379784647.74-7643490092735/mysql_user”, line 409, in main
changed = user_add(cursor, user, host, password, priv)
File “/root/.ansible/tmp/ansible-1379784647.74-7643490092735/mysql_user”, line 140, in user_add
cursor.execute(“CREATE USER %s@%s IDENTIFIED BY %s”, (user,host,password))
File “/usr/lib64/python2.6/site-packages/MySQLdb/cursors.py”, line 173, in execute
self.errorhandler(self, exc, value)
File “/usr/lib64/python2.6/site-packages/MySQLdb/connections.py”, line 36, in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.OperationalError: (1396, “Operation CREATE USER failed for ‘user1’@‘localhost’”)
Edgars