Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass grains in minion start event #54087

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
# - id
#
# 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 @@ -2066,6 +2066,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
- id

.. 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 @@ -1283,6 +1283,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 @@ -1475,6 +1475,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