Skip to content

Instantly share code, notes, and snippets.

@pcn
Created October 11, 2018 15:23
Show Gist options
  • Save pcn/cf69a85fbb7bcea0f6f61c47e929c6b3 to your computer and use it in GitHub Desktop.
Save pcn/cf69a85fbb7bcea0f6f61c47e929c6b3 to your computer and use it in GitHub Desktop.
This seems to allow for running a salt client, ala salt-call, from within a python script
import salt.cli.call
call = salt.cli.call.SaltCall()
call.parse_args(args=['state.highstate'])
# It's initialized but it's going to try to parse the command line,
# so override those properties
if call.options.master:
call.config['master'] = call.options.master
# Setup file logging!
call.setup_logfile_logger()
verify_log(call.config)
caller = salt.cli.caller.Caller.factory(call.config)
caller.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment