使用 SaltStack 使用密码创建 MySql 授权

Create MySql grants with password using SaltStack

要为数据库创建授权,我使用以下盐模块

keystone_grants:
mysql_grants.present:
  - database: keystone.*
  - grant: ALL PRIVILEGES
  - user: keystone
  - host: localhost

但它创造了我这个

 ID: Keystone_database
 Function: mysql_grants.present
 Result: True
 Comment: Grant ALL PRIVILEGES on keystone.* to keystone@localhost has been added
Started: 19:42:18.428882
Duration: 4.089 ms
Changes:

即它为我创造了这笔补助金

Grant ALL PRIVILEGES on keystone.* to keystone@localhost

但是我需要创建这个补助金

授予 keystone 上的所有权限。* 至 'keystone'@'localhost' 由 'password';

识别

有人可以建议我如何使用 SaltStack 添加带密码的授权

This state is not able to set password for the permission from the specified host. See salt.states.mysql_user for further instructions.

这句话是写在salt.modules.mysql_grants. They point from there to salt.states.mysql_user的文档里的。遗憾的是,这份文档并没有说明很多关于赠款的信息。

This state is not able to grant permissions for the user. See salt.states.mysql_grants for further instructions.

也许两者都用就够了:

keystone_grants:
  mysql_grants.present:
    - host: localhost
    - database: keystone.*
    - grant: ALL PRIVILEGES
    - user: keystone
    - host: localhost

keystone:
  mysql_user.present:
    - host: localhost
    - password: somesecret

此外,我会推荐 mysql-formula