简体   繁体   English

从salt-master获取salt-minion的密码mysql

[英]Get the mysql password of salt-minion from salt-master

I want to execute a query from salt-master to salt-minion using mysql.query.我想使用 mysql.query 执行从 salt-master 到 salt-minion 的查询。

I am setting the mysql information of salt-minion as follows.我设置salt-minion的mysql信息如下。

/etc/salt/minion file /etc/salt/minion 文件

mysql.host: 'localhost'
mysql.port: 3306
mysql.user: 'root'
mysql.pass: 'root123'
mysql.db: 'mysql'
mysql.unix_socket: '/var/lib/mysql/tmp/mysql.sock'
mysql.charset: 'utf8'

Is there any way to get the mysql password specified in salt-master from salt-minion?有没有办法从salt-minion获取salt-master中指定的密码mysql?

salt-master setting /etc/salt/pillar/mysql.sls salt-master 设置 /etc/salt/pillar/mysql.sls

mysql:
  mysqlrootpassword: 'root123'

salt-minion /etc/salt/minion盐仆从/etc/salt/minion

mysql.pass: salt['pillar.get']('mysql:mysqlrootpassword', '')
mysql.pass: {{ pillar['mysql']['mysqlrootpassword'] }}
mysql.pass: {{ salt['pillar.get']('mysql:mysqlrootpassword', '') }}

All three of the above do not bring the password.以上三个都不带密码。

You cannot use jinja templates in the minion config.您不能在 minion 配置中使用 jinja 模板。

The mysql module will also take config directly from pillar, so simply change your pillar definition to: mysql 模块也将直接从支柱获取配置,因此只需将支柱定义更改为:

mysql.pass: 'root123'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM