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 Example:
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 Example:
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, **kwargs)¶Send an event to the Salt Master
New in version 2014.7.0.
Parameters: |
|
---|
CLI Example:
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]