ansible/ansible — pull request #730 by marktheunissen (2012-07-30 22:35:15+00:00)
Title: Changing the parameter names to be consistent, and adding root user

This changes the parameters to be consistent with postgres module.

It also makes a minor tweak - if no login user/password is given, and there's no .my.cnf, it will default to using 'root' with an empty password. This makes the module more consistent with what the 'mysql' command line application does. MySQL database ships by default with this user/password, typically the first thing you want to do is remove it and set a secure one. Previously trying to do this in a playbook created a chicken-and-egg problem.

Now, it's possible to do this:

- name: Set the root password.
action: mysql_user user=root password=$mysql_root_password host=localhost

- name: MySQL config for easy access as root user.
action: template src=templates/root-my-cnf.j2 dest=/root/.my.cnf

The first run of the playbook, there won't be a .my.cnf file, so the default "root"/"" credentials will be used on the first call, which will succeed. On subsequent runs, the .my.cnf will be set with the correct secure password, and the playbook will succeed again. This wasn't possible before.