Use the Salt Event System to fire events from the master to the minion and vice-versa.
salt.modules.event.
fire
(data, tag)¶Fire an event on the local minion event bus. Data must be formed as a dict.
CLI 范例:
salt '*' event.fire '{"data":"my event data"}' 'tag'
salt.modules.event.
fire_master
(data, tag, preload=None)¶Fire an event off up to the master server
CLI 范例:
salt '*' event.fire_master '{"data":"my event data"}' 'tag'
salt.modules.event.
send
(tag, data=None, preload=None, with_env=False, with_grains=False, with_pillar=False, with_env_opts=False, **kwargs)¶Send an event to the Salt Master
2014.7.0 新版功能.
参数: |
|
---|
CLI 范例:
salt-call event.send myco/mytag foo=Foo bar=Bar
salt-call event.send 'myco/mytag' '{foo: Foo, bar: Bar}'
A convenient way to allow Jenkins to execute salt-call
is via sudo. The
following rule in sudoers will allow the jenkins
user to run only the
following command.
/etc/sudoers
(allow preserving the environment):
jenkins ALL=(ALL) NOPASSWD:SETENV: /usr/bin/salt-call event.send*
Call Jenkins via sudo (preserve the environment):
sudo -E salt-call event.send myco/jenkins/build/success with_env=[BUILD_ID, BUILD_URL, GIT_BRANCH, GIT_COMMIT]