When you install mysql-server with Ansible like this:
- name: Install Mysql
apt: pkg=mysql-server state=latest
The package manager will prompt for a root password, but ansible will just enter nothing or null...
And change the password before can be a pain in the ass.
So, the way you can set the root password you want is pretty simple:
- name: Mysql | Set root password
shell: debconf-set-selections <<< 'mysql-server mysql-server/root_password password put_your_root_password'
- name: Mysql | Set root repassword
shell: debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password put_your_root_password'
This way the package manager won't ask for a password and will use this one instead.
Tested with: 1.5 (devel)
Here is a way to change the password when you already installed mysql, but didn't work for me: