#放大一
import salt.client local = salt.client.LocalClient() res = local.cmd(f'{minion_id}', 'test.ping', timeout=10)
#方法二
import salt.config import salt.loader __opts__ = salt.config.minion_config('/etc/salt/minion') __grains__ = salt.loader.grains(__opts__) __opts__['grains'] = __grains__ __utils__ = salt.loader.utils(__opts__) __salt__ = salt.loader.minion_mods(__opts__, utils=__utils__) __salt__['test.ping']()