diff --git a/conf/minion b/conf/minion index 8bc64e61f53a..3950877d3e25 100644 --- a/conf/minion +++ b/conf/minion @@ -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: '' diff --git a/doc/ref/configuration/minion.rst b/doc/ref/configuration/minion.rst index f25afe90a9ea..b6d802029e81 100644 --- a/doc/ref/configuration/minion.rst +++ b/doc/ref/configuration/minion.rst @@ -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`` diff --git a/salt/config/__init__.py b/salt/config/__init__.py index 422a5c644c7b..b89bdd447a12 100644 --- a/salt/config/__init__.py +++ b/salt/config/__init__.py @@ -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', diff --git a/salt/minion.py b/salt/minion.py index 8666c2fe4160..87dff7fafddd 100644 --- a/salt/minion.py +++ b/salt/minion.py @@ -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)