实现配置相对简单,在/etc/salt/master中增加:
master_job_cache: redis
redis.db: '0'
redis.host: 'redis-host-addr'
redis.port: 6379
需要注意的是,需要在salt的Python包中安装redis模块,不然会报错。
pip install redis
报错信息:
- minion端return_redis报错
如果在minion端增加redis配置,没有安装redis会报错:
salt "*" test.ping --return redis
2021-04-08 12:59:41,356 [salt.utils.lazy :102 ][DEBUG ][10568] LazyLoaded nagios.list_plugins
2021-04-08 12:59:41,369 [salt.utils.lazy :106 ][DEBUG ][10568] Could not LazyLoad redis.returner: 'redis.returner' is not available.
2021-04-08 12:59:41,369 [salt.minion :2052][ERROR ][10568] Returner redis.returner could not be loaded: 'redis.returner' is not available.
2021-04-08 12:59:42,217 [salt.utils.process:1055][DEBUG ][10303] Subprocess ProcessPayload-Job-20210408045940409389 cleaned up
2021-04-08 13:59:29,218 [salt.utils.schedule:1722][DEBUG ][10303] schedule: Job __mine_interval was scheduled with jid_include, adding to cache (jid_include defaults to True)
- master端return redis报错:
2021-04-07 16:48:18,996 [salt.master :2335][ERROR ][29820] Failed to allocate a jid. The requested returner 'redis' could not be loaded.
2021-04-07 16:48:18,997 [salt.transport.zeromq:879 ][ERROR ][29820] Some exception handling a payload from minion
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/salt/transport/zeromq.py", line 875, in handle_message
ret, req_opts = yield self.payload_handler(payload)
File "/usr/lib/python3.6/site-packages/salt/ext/tornado/gen.py", line 1056, in run
value = future.result()
File "/usr/lib/python3.6/site-packages/salt/ext/tornado/concurrent.py", line 249, in result
raise_exc_info(self._exc_info)
File "<string>", line 4, in raise_exc_info
File "/usr/lib/python3.6/site-packages/salt/ext/tornado/gen.py", line 294, in wrapper
result = func(*args, **kwargs)
File "/usr/lib64/python3.6/types.py", line 248, in wrapped
coro = func(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/salt/master.py", line 1060, in _handle_payload
ret = {"aes": self._handle_aes, "clear": self._handle_clear}[key](load)
File "/usr/lib/python3.6/site-packages/salt/master.py", line 1101, in _handle_clear
ret = method(load), {"fun": "send_clear"}
File "/usr/lib/python3.6/site-packages/salt/master.py", line 2286, in publish
payload = self._prep_pub(minions, jid, clear_load, extra, missing)
File "/usr/lib/python3.6/site-packages/salt/master.py", line 2373, in _prep_pub
self.event.fire_event({"minions": minions}, clear_load["jid"])
File "/usr/lib/python3.6/site-packages/salt/utils/event.py", line 808, in fire_event
salt.utils.stringutils.to_bytes(tag),
File "/usr/lib/python3.6/site-packages/salt/utils/stringutils.py", line 54, in to_bytes
raise TypeError("expected str, bytes, or bytearray not {}".format(type(s)))
TypeError: expected str, bytes, or bytearray not <class 'dict'>
2021-04-07 16:48:18,998 [tornado.general :462 ][ERROR ][29820] Uncaught exception in zmqstream callback
Traceback (most recent call last):
File "/usr/lib64/python3.6/site-packages/zmq/sugar/socket.py", line 426, in send_multipart
memoryview(msg)
TypeError: memoryview: a bytes-like object is required, not 'str'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib64/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 454, in _handle_events
self._handle_send()
File "/usr/lib64/python3.6/site-packages/zmq/eventloop/zmqstream.py", line 493, in _handle_send
status = self.socket.send_multipart(msg, **kwargs)
File "/usr/lib64/python3.6/site-packages/zmq/sugar/socket.py", line 433, in send_multipart
i, rmsg,
TypeError: Frame 0 ('Some exception handling minion ...) does not support the buffer interface.
2021-04-07 16:48:18,999 [tornado.application:640 ][ERROR ][29820] Exception in callback functools.partial(<function wrap.<locals>.null_wrapper at 0x7f857a9be950>)
Traceback (most recent call last):