ansible.mysql_user(3) - Linux man page

Name

mysql_user - Adds or removes a user from a MySQL database.

Description

Adds or removes a user from a MySQL database.

Options

host

the 'host' part of the MySQL username (default: localhost)

login_host
Host running the database (default: localhost)
login_password
The password used to authenticate with
login_user
The username used to authenticate with
name

name of the user (role) to add or remove(required)

password
set the user's password
priv

MySQL privileges string in the format: db.table:priv1,priv2

state

The database state Choices: present,absent. (default: present)."

Notes

Requires the MySQLdb Python package on the remote host. For Ubuntu, this is as easy as apt-get install python-mysqldb.

Both login_password and login_username are required when you are passing credentials. If none are present, the module will attempt to read the credentials from ~/.my.cnf, and finally fall back to using the MySQL default login of 'root' with no password.

Examples

Create database user with name 'bob' and password '12345' with all database privileges

mysql_user: name=bob password=12345 priv=*.*:ALL state=present
Ensure no user named 'sally' exists, also passing in the auth credentials.
mysql_user: login_user=root login_password=123456 name=sally state=absent
Example privileges string format
mydb.*:INSERT,UPDATE/anotherdb.*:SELECT/yetanotherdb.*:ALL

Author

Mark Theunissen

See Also

ansible(1), http://ansible.github.com/modules.html#mysql-user