saltstack / pepper

A library and stand-alone CLI tools to access a salt-api instance
Other
247 stars 124 forks source link

[BUG] Can't send pillar data in kwarg #204

Closed SammyTbeile closed 4 years ago

SammyTbeile commented 4 years ago

When trying to run a state.sls command and supplying pillar data as a kwarg, I'm receiving the following error. I have tried this via the cli and via libpepper. Sample libpepper command: api.local(tgt='minion',fun='state.sls', arg='state', kwarg='pillar:{"foo":"bar"}')

Sample pepper cli command: pepper -H -a ldap 'minion' state.sls 'state' pillar='{"foo":"bar"}' Output:

send: 'POST /login HTTP/1.1\r\nAccept-Encoding: identity\r\nContent-Length: 82\r\nConnection: close\r\nAccept: application/json\r\nUser-Agent: Python-urllib/2.7\r\nHost: master:XXXX\r\nX-Requested-With: XMLHttpRequest\r\nContent-Type: application/json\r\n\r\n{"username": "user", "password": "pass", "eauth": "ldap"}'
reply: 'HTTP/1.1 200 OK\r\n'
header: Content-Length: 410
header: Access-Control-Expose-Headers: GET, POST
header: Vary: Accept-Encoding
header: Server: CherryPy/10.2.2
header: Allow: GET, HEAD, POST
header: Access-Control-Allow-Credentials: true
header: Date: Thu, 12 Mar 2020 20:55:24 GMT
header: Access-Control-Allow-Origin: *
header: X-Auth-Token: token
header: Content-Type: application/json
header: Set-Cookie: session_id=id; expires=Fri, 13 Mar 2020 06:55:24 GMT; Max-Age=36000; Path=/
header: Connection: close
send: 'POST / HTTP/1.1\r\nAccept-Encoding: identity\r\nContent-Length: 235\r\nConnection: close\r\nAccept: application/json\r\nX-Auth-Token: token\r\nHost: master:XXXX\r\nX-Requested-With: XMLHttpRequest\r\nUser-Agent: Python-urllib/2.7\r\nContent-Type: application/json\r\n\r\n[{"tgt_type": "glob", "full_return": true, "tgt": "minion", "batch": null, "client": "local", "arg": ["state", "pillar={\\"foo\\":\\"bar\\"}"], "fun": "state.sls"}]'
reply: 'HTTP/1.1 500 Internal Server Error\r\n'
header: Content-Length: 57
header: Access-Control-Expose-Headers: GET, POST
header: Cache-Control: private
header: Vary: Accept-Encoding
header: Server: CherryPy/10.2.2
header: Allow: GET, HEAD, POST
header: Access-Control-Allow-Credentials: true
header: Date: Thu, 12 Mar 2020 20:55:24 GMT
header: Access-Control-Allow-Origin: *
header: Content-Type: application/json
header: Set-Cookie: session_id=id; expires=Fri, 13 Mar 2020 06:55:24 GMT; Max-Age=36000; Path=/
header: Connection: close
Pepper error: Server error.

Error on salt-master:

[ERROR   ] Some exception handling a payload from minion
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/transport/zeromq.py", line 773, in handle_message
    ret, req_opts = yield self.payload_handler(payload)
  File "/usr/lib/python2.7/dist-packages/salt/ext/tornado/gen.py", line 1056, in run
    value = future.result()
  File "/usr/lib/python2.7/dist-packages/salt/ext/tornado/concurrent.py", line 239, in result
    raise_exc_info(self._exc_info)
  File "/usr/lib/python2.7/dist-packages/salt/ext/tornado/gen.py", line 294, in wrapper
    result = func(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1065, in _handle_payload
    'clear': self._handle_clear}[key](load)
  File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1096, in _handle_clear
    ret = getattr(self.clear_funcs, cmd)(load), {'fun': 'send_clear'}
  File "/usr/lib/python2.7/dist-packages/salt/master.py", line 2101, in publish
    whitelist=['saltutil.find_job'],
  File "/usr/lib/python2.7/dist-packages/salt/utils/minions.py", line 962, in auth_check
    if self.__fun_check(ind[valid], fun, fun_args, fun_kwargs):
  File "/usr/lib/python2.7/dist-packages/salt/utils/minions.py", line 1073, in __fun_check
    if self.__args_check(cond[fname_cond], args, kwargs):
  File "/usr/lib/python2.7/dist-packages/salt/utils/minions.py", line 1103, in __args_check
    for k, v in six.iteritems(cond_kwargs):
  File "/usr/lib/python2.7/dist-packages/salt/ext/six.py", line 606, in iteritems
    return d.iteritems(**kw)
AttributeError: 'list' object has no attribute 'iteritems'
[ERROR   ] Uncaught exception in zmqstream callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 454, in _handle_events
    self._handle_send()
  File "/usr/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 493, in _handle_send
    status = self.socket.send_multipart(msg, **kwargs)
  File "/usr/lib/python2.7/dist-packages/zmq/sugar/socket.py", line 434, in send_multipart
    i, rmsg,
TypeError: Frame 0 (u'Some exception handling minion...) does not support the buffer interface.
[ERROR   ] Exception in callback <functools.partial object at 0x7fa8d6ea94c8>
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/ext/tornado/ioloop.py", line 606, in _run_callback
    ret = callback()
  File "/usr/lib/python2.7/dist-packages/salt/ext/tornado/stack_context.py", line 278, in null_wrapper
    return fn(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 536, in <lambda>
    self.io_loop.add_callback(lambda : self._handle_events(self.socket, 0))
  File "/usr/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 454, in _handle_events
    self._handle_send()
  File "/usr/lib/python2.7/dist-packages/zmq/eventloop/zmqstream.py", line 493, in _handle_send
    status = self.socket.send_multipart(msg, **kwargs)
  File "/usr/lib/python2.7/dist-packages/zmq/sugar/socket.py", line 434, in send_multipart
    i, rmsg,
TypeError: Frame 0 (u'Some exception handling minion...) does not support the buffer interface.
SammyTbeile commented 4 years ago

pepper version: 0.7.5, salt-master/api version: 3000

SammyTbeile commented 4 years ago

This was due to me not setting kwargs as a dict in eauth