saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Install Salt from the Salt package repositories here:
https://docs.saltproject.io/salt/install-guide/en/latest/
Apache License 2.0
14.17k stars 5.48k forks source link

salt-ssh interprets kwargs as args #11609

Closed johtso closed 10 years ago

johtso commented 10 years ago
salt-ssh 'baobab' state.sls git test=True
Process Process-1:
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/human/.virtualenvs/baobab/lib/python2.7/site-packages/salt/client/ssh/__init__.py", line 334, in handle_routine
    stdout, stderr, retcode = single.run()
  File "/Users/human/.virtualenvs/baobab/lib/python2.7/site-packages/salt/client/ssh/__init__.py", line 574, in run
    stdout, stderr, retcode = self.run_wfunc()
  File "/Users/human/.virtualenvs/baobab/lib/python2.7/site-packages/salt/client/ssh/__init__.py", line 646, in run_wfunc
    ret = json.dumps(self.wfuncs[self.fun](*self.arg))
  File "/Users/human/.virtualenvs/baobab/lib/python2.7/site-packages/salt/client/ssh/wrapper/state.py", line 39, in sls
    high, errors = st_.render_highstate({saltenv: mods})
  File "/Users/human/.virtualenvs/baobab/lib/python2.7/site-packages/salt/state.py", line 2382, in render_highstate
    statefiles = fnmatch.filter(self.avail[saltenv], sls_match)
KeyError: 'test=True'

salt-ssh then hangs and has to be stopped with a keyboard interrupt.

basepi commented 10 years ago

That's very strange! Which version of salt are you using? It appears that the argument is being parsed as an arg, not a kwarg, and so it's trying to use it for the saltenv argument.

Thanks for the report, we'll investigate.

johtso commented 10 years ago

Happens with the latest version of salt 2014.1.0-4018-g9d82e8c

I have a feeling this is a troublesome spot: https://github.com/saltstack/salt/blob/develop/salt/client/ssh/__init__.py#L646

johtso commented 10 years ago

It seems that this is a general issue with the salt-ssh cli. There is no parsing of kwargs.

Another example, test=True was completely ignored when executing pkg.install:

❯ salt-ssh 'baobab' pkg.install fortune test=True
baobab:
    ----------
    fortune-mod:
        ----------
        new:
            1:1.99.1-4
        old:

    fortunes-min:
        ----------
        new:
            1:1.99.1-4
        old:

    librecode0:
        ----------
        new:
            3.6-18
        old:
basepi commented 10 years ago

Ya, we're definitely not handling those kwargs right. Thanks for the update.