Puppet has official support to managing users and grants through a community maintained module. Click here for documentation. There's more modules to manage different aspects of Mysql, you can definitely do a lot more as code using Puppet. Make sure to read the documentation to know all the features, know every input option and all the use cases supported.

Create a user with SELECT and UPDATE permissions

mysql::db { 'mydb': user => 'myuser', password => 'mypass', host => 'localhost', grant => ['SELECT', 'UPDATE'], }

Create a user with a pre hashed password and the same SELECT and UPDATE permissions

mysql::db { 'mydb': user => 'myuser', password => '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4', host => 'localhost', grant => ['SELECT', 'UPDATE'], }

Why Puppet for managing Mysql users/grants

Ansible is a configuration management tool that provides you the ability to manage your infrastructure as code. [TODO]

Why manage users/grants as code?

[TODO].