How to set root password using salt states

Yeah, we're going to add a 'default_user' and 'default_pass' setting so you can handle this situation. It should be in 0.17.0


Just in case someone stumbles upon this question while starting to manage mysql with saltstack.

Here is how it works in the current salt version (salt 2015.5.0 (Lithium)). Notice that the mysql_user.present-state is smart enough to try it without a password at first. In subsequent runs the state will use the root password to connect and realize that the password for root is in the right state.

root:
  mysql_user.present:
    - host: localhost
    - password: s3cure_root_password

another_user:
  mysql_user.present:
    - host: localhost
    - password: anoth3r_user_password
    - connection_user: root
    - connection_pass: s3cure_root_password

Tags:

Salt Stack