我对我使用的saltstack,state文件是个新手:
mybd:
mysql_database.present
user22:
mysql_grants.present:
- grant: ALL PRIVILEGES
- database: 'mybd.*'
- user: user22
- host: localhost
- connection_user: root
- connection_host: localhost
- connection_pass: ''
- connection_unix_socket: /tmp/mysql.sock
- connection_charset: utf8我在应用mysql状态时遇到以下错误:
ID: mybd
Function: mysql_database.present
Result: True
Comment: Database mybd is already present
Started: 09:05:09.366441
Duration: 5.835 ms
Changes: ID: user22
Function: mysql_grants.present
Result: False
Comment: Failed to execute: "GRANT ALL PRIVILEGES ON mybd.* TO user22@localhost"
Started: 09:05:09.372849
Duration: 76.012 ms
Changes: 用户摘要
成功:1失败:1
但是当我转到mysql时,我注意到特权被添加了!我不知道我做错了什么。有没有人知道如何在mysql中通过salt-stack正确地授予用户权限?
Salt版本:
Salt Version:
Salt: 2015.8.0
Dependency Versions:
Jinja2: 2.7.2
M2Crypto: 0.31.0
Mako: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
Python: 2.7.5 (default, Nov 16 2020, 22:23:17)
RAET: Not Installed
Tornado: 4.2.1
ZMQ: 4.1.4
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
libnacl: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.6.2
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: 2.6.1
pygit2: Not Installed
python-gnupg: Not Installed
smmap: Not Installed
timelib: Not Installed
System Versions:
dist: centos 7.9.2009 Core
machine: x86_64
release: 3.10.0-1160.15.2.el7.x86_64
system: CentOS Linux 7.9.2009 Coremysql版本:
mysql Ver 15.1 Distrib 10.3.31-MariaDB, for Linux (x86_64) using readline 5.1发布于 2021-10-14 17:18:49
要知道真正的答案,您必须查看minion日志文件。如果列出了任何错误,这就是mysql.grant_add失败的原因。
但是,该状态的工作方式是,它尝试通过使用mysql模块运行mysql.grant_exists并在数据库中查找授权来确定授权是否已经存在。如果没有找到,它将运行mysql.grant_add函数。
mysql.grant_add将根据这些信息生成对授权的查询,运行查询,如果这些进程中的任何一个失败,它将在minion日志中报告失败。
在此之后,mysql.grant_add将运行mysql.grant_exists来查看是否添加了授权。如果没有正确返回,它将报告故障。所以问题是mysql.grant_exists是否可以看到这笔拨款。
同样,如果您使用的是这样一个旧版本的salt,但是使用的是较新版本的mysql,那么授权表可能不会以mysql.grant_exists能够检测到授权的方式返回。在这种情况下,它将检测为故障,并且仍然能够添加。
https://stackoverflow.com/questions/69205749
复制相似问题