我已经连接了 master 和 minion,并且尝试通过 master 上的 react 系统设置一些监控。但我还没有取得任何进展,因为据我所知,master 上没有发生任何事件。只需执行以下命令:
salt-call event.send "foo/bar" '{key:value}' -l debug
来自 minion 似乎尝试发送事件:
[DEBUG ] Sending event - data = {'_stamp': '2015-11-20T21:40:35.414647'}
[DEBUG ] Sending event - data = {'pretag': None, '_stamp': '2015-11-20T21:40:36.415859', 'tag': 'foo/bar', 'data': {'__pub_fun': 'event.send', '__pub_jid': '20151120154035413430', '__pub_pid': 59391, '__pub_tgt': 'salt-call'}, 'events': None}
但是,主服务器似乎不太想处理这个问题。我一直在运行主服务器并开启调试,唯一与 foo 相关的行似乎是:
[DEBUG ] Sending event - data = {'tgt_type': 'glob', 'fun_args': ['foo/bar', '{key:value}'], 'jid': '20151120164246710357', 'return': True, 'retcode': 0, 'tgt': 'myminion', 'cmd': '_return', '_stamp': '2015-11-20T21:42:46.712050', 'arg': ['foo/bar', '{key:value}'], 'fun': 'event.send', 'id': 'myminion'}
[DEBUG ] Gathering reactors for tag salt/job/20151120164246710357/ret/myminion
[DEBUG ] Reading configuration from /etc/salt/master
[DEBUG ] Including configuration from '/etc/salt/minion.d/ca.conf'
[DEBUG ] Reading configuration from /etc/salt/minion.d/ca.conf
[DEBUG ] Using cached minion ID from /etc/salt/minion_id: saltmaster
[DEBUG ] Reading configuration from /etc/salt/master
[DEBUG ] Including configuration from '/etc/salt/master.d/reactor.conf'
[DEBUG ] Reading configuration from /etc/salt/master.d/reactor.conf
如果我错了,请纠正我,但我认为第一行发送的事件是 event.send 作业的事件,而不是该作业发送的实际事件。输出
salt-run state.event pretty=True
似乎同意,因为它没有看到任何标记为 foo/bar 的事件,但它确实看到了由作业触发的事件:
salt/auth {
"_stamp": "2015-11-20T21:47:39.128795",
"act": "accept",
"id": "myminion",
"pub": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu1eiIALNfjxI2JN+SUop\nsZGEDUnWy30J5TJsiSmWezfpDbIklb4zl1RmfoCx529KhK349nvDMtlCP0/F4Yq1\nSlKH4FDt8x4XzkErEGFGkbQ1+2a9LXYpA61hHCnq8mLSPCqX6dS3EVq0hzyaQMP2\nt3bquyXTjtlzcQ1/5+9egaHv21ofArBZzU7PDV2pGP9pI4yg4rjg6RJIOHSRyqYb\nEwhkUtWhZUBc/Yx5PL9Ji543JCyXi8jDc7NSyBZyTMadxSZkKmqXBlhdQsa4OVP2\nFuuoyjjvqF6O3P7qOl0kX45O/mBOudDdrskAv/8m1Emh6kuP4Yy/fKCryzcBhiRg\n4QIDAQAB\n-----END PUBLIC KEY-----\n",
"result": true
}
salt/job/20151120164745515025/ret/myminion {
"_stamp": "2015-11-20T21:47:45.517110",
"arg": [
"foo/bar",
"{key:value}"
],
"cmd": "_return",
"fun": "event.send",
"fun_args": [
"foo/bar",
"{key:value}"
],
"id": "myminion",
"jid": "20151120164745515025",
"retcode": 0,
"return": true,
"tgt": "myminion",
"tgt_type": "glob"
}
我觉得我忽略了一些非常简单的东西,但我说不上来。我猜想我的反应堆没有反应的原因是没有响应的东西。没有尝试收集 foo/bar 的反应堆,但以下是配置/etc/salt/master.d/reactor.conf
:
reactor:
- 'foo/bar':
- /srv/salt/reactor/foo.sls
以及以下内容/srv/salt/reactor/foo.sls
:
log_foo:
local.file.append:
- tgt: myminion
- arg:
- /tmp/reactor_example.txt
- {{ data }}
/tmp/reactor_example.txt
当然是空的。
有人能看出我做错了什么吗?任何帮助都非常感谢。主版本是salt-master 2015.5.3 (Lithium)
,从版本salt-minion 2015.5.3 (Lithium)
也是。两个系统都是 Ubuntu。
答案1
在你的主配置中你取消注释了以下行
default_include: master.d/*.conf
如果不这样做,你添加的 react.conf 将永远不会起作用