亚军中的盐键命令
Salt-key command in runner
我正在编写一个自定义的 Salt Stack runner 来包装接受和拒绝 minions。我如何从我的 python runner 调用 salt-key 相当于从命令行
salt-key -a {minion_name}
我无法为您提供明确的答案,但这是我的两分钱:
salt-key脚本的源代码是this one. Following the call chain, I reached this module,其中包含几个类做密钥处理。
该模块的文档如下:
The Salt Key backend API and interface used by the CLI. The Key class can be
used to manage salt keys directly without interfacing with the CLI.
基于 this code,我推测它的用法如下:
import salt.client
import salt.key
client = salt.client.LocalClient()
key_manager = salt.key.Key(client.opts)
key_manager.accept('web*')
我知道自从回答这个问题以来已经有一段时间了,我想在这个问题上加两分钱。
为了以编程方式进行关键交互,我们使用 Wheel in salt。用法相当简单明了:
from salt import config
from salt import wheel
masterOpts = config.master_config('/etc/salt/master')
wheelClient = wheel.WheelClient(masterOpts)
wheelClient.cmd('key.accept', ['minionId1'])
中找到大量其他操作
我正在编写一个自定义的 Salt Stack runner 来包装接受和拒绝 minions。我如何从我的 python runner 调用 salt-key 相当于从命令行
salt-key -a {minion_name}
我无法为您提供明确的答案,但这是我的两分钱:
salt-key脚本的源代码是this one. Following the call chain, I reached this module,其中包含几个类做密钥处理。
该模块的文档如下:
The Salt Key backend API and interface used by the CLI. The Key class can be used to manage salt keys directly without interfacing with the CLI.
基于 this code,我推测它的用法如下:
import salt.client
import salt.key
client = salt.client.LocalClient()
key_manager = salt.key.Key(client.opts)
key_manager.accept('web*')
我知道自从回答这个问题以来已经有一段时间了,我想在这个问题上加两分钱。
为了以编程方式进行关键交互,我们使用 Wheel in salt。用法相当简单明了:
from salt import config
from salt import wheel
masterOpts = config.master_config('/etc/salt/master')
wheelClient = wheel.WheelClient(masterOpts)
wheelClient.cmd('key.accept', ['minionId1'])
中找到大量其他操作