Skip to content

Commit

Permalink
enable passing grains to start event based on 'start_event_grains' co…
Browse files Browse the repository at this point in the history
…nfiguration parameter
  • Loading branch information
admd committed Oct 29, 2019
1 parent 4e0ba6e commit 6aedf58
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions conf/minion
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@
# - edit.vim
# - hyper
#
# List of grains to pass in start event when minion starts up:
#start_event_grains:
# - machine_id
# - uuid
#
# Top file to execute if startup_states is 'top':
#top_file: ''

Expand Down
15 changes: 15 additions & 0 deletions doc/ref/configuration/minion.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1999,6 +1999,21 @@ List of states to run when the minion starts up if ``startup_states`` is set to
- edit.vim
- hyper
.. conf_minion:: start_event_grains

``start_event_grains``
----------------------

Default: ``[]``

List of grains to pass in start event when minion starts up.

.. code-block:: yaml
start_event_grains:
- machine_id
- uuid
.. conf_minion:: top_file

``top_file``
Expand Down
1 change: 1 addition & 0 deletions salt/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,7 @@ def _gather_buffer_space():
'state_top_saltenv': None,
'startup_states': '',
'sls_list': [],
'start_event_grains': [],
'top_file': '',
'thoriumenv': None,
'thorium_top': 'top.sls',
Expand Down
5 changes: 5 additions & 0 deletions salt/minion.py
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,11 @@ def _fire_master(self, data=None, tag=None, events=None, pretag=None, timeout=60
else:
return

if self.opts['start_event_grains']:
grains_to_add = dict(
[(k, v) for k, v in six.iteritems(self.opts.get('grains', {})) if k in self.opts['start_event_grains']])
load['grains'] = grains_to_add

if sync:
try:
self._send_req_sync(load, timeout)
Expand Down

0 comments on commit 6aedf58

Please sign in to comment.