Hello!
I'm struggling with using the RunnerClient Python API to run an orchestrate job while also passing in 'normal' command line parameters.
Here's an equivalent command-line version of what I'm trying to do:
salt-run state.orch service.orchestrate --config_dir=/tmp/workspace --out=json
I can put together a RunnerClient and fire the orchestrate command easily enough:
master_opts = salt.config.client_config('/etc/salt/master')
master_opts['quiet'] = True
runner = salt.runner.RunnerClient(master_opts)
result = runner.cmd(fun='state.orch', arg=['service.orchestrate'] )
This works. However, when I try to introduce a command-line argument via the kwarg parameter:
result = runner.cmd(fun='state.orch', arg=['service.orchestrate'], kwarg={'config_dir':'/tmp/workspace', 'out':'json'} )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/salt/runner.py", line 130, in cmd
print_event)
File "/usr/lib/python2.7/site-packages/salt/client/mixins.py", line 226, in cmd
self.functions[fun], arglist, pub_data
File "/usr/lib/python2.7/site-packages/salt/minion.py", line 347, in load_args_and_kwargs
else:
File "/usr/lib/python2.7/site-packages/salt/utils/__init__.py", line 2979, in invalid_kwargs
raise SaltInvocationError(msg)
salt.exceptions.SaltInvocationError: The following keyword arguments are not valid: config_dir=/tmp/1b0d6163fdc2-0, out=json
It looks like Salt is rejecting this because 'config_dir' and 'out' are not valid kwargs for 'state.orch'. I agree that they're not but my intention is to pass them to the salt-runner, not the function.
What do I need to do in order to pass 'command line' arguments to a RunnerClient?
Thanks in advance!
- Drew