salt icon indicating copy to clipboard operation
salt copied to clipboard

"Got unknown grain from master: roles" when grains are in minion.d files

Open borgstrom opened this issue 14 years ago • 9 comments

When we put our roles into a conf file in the minion.d directory we get an error message when applying highstate:

[#14]: salt-call state.highstate
[INFO    ] Loaded configuration file: /etc/salt/minion
[INFO    ] Loading fresh modules for state activity
[ERROR   ] Got unknown grain from master: roles
[ERROR   ] Got unknown grain from master: roles
[INFO    ] Loading fresh modules for state activity
...

The interesting thing is that this doesn't seem to actually affect anything and the proper states are applied.

If we move the grains into the main minion config then the error goes away.

borgstrom avatar Sep 22 '12 21:09 borgstrom

does the grain show up on the minion with salt-call -g ?

thatch45 avatar Sep 22 '12 21:09 thatch45

Yes they do.

borgstrom avatar Sep 22 '12 21:09 borgstrom

well, it is worth a look :)

thatch45 avatar Sep 22 '12 21:09 thatch45

I can replicate this (for salt-minion-0.10.2-2.el6.noarch) , so looks like a bug to me as well. i.e when I put a grain: entry in /etc/salt/minion.d/grains.conf like

grains:
  type: test1
  location: outside

and try to use it in top.sls file and 'salt '*' state.highstate' . I get an error

 [ERROR   ] Got unknown grain from master: type  

I move same grains: entry in /etc/salt/minion (main conf file) and error goes away.

mlister2006 avatar Oct 02 '12 02:10 mlister2006

I will try to replicate this with the latest code and get it fixed, thanks!

thatch45 avatar Oct 02 '12 16:10 thatch45

I think it is little convenience bug :). On minions, If I uncomment a 'default_include' line in /etc/salt/minion, then it works for salt.highstate, else it is ignored.

(1) Workaround for current version of salt (0.10.3) #default_include: minion.d/*.conf <==uncomment this line.

But I suggest to better fix a code. Here is a little patch for 'salt/loader.py' file. (2) Lazy patch :).

@@ -132,7 +132,9 @@
         salt.config.load_config(
             pre_opts, opts['conf_file'], 'SALT_MINION_CONFIG'
         )
-        default_include = pre_opts.get('default_include', [])
+        #default_include = pre_opts.get('default_include', [])
+        default_include = pre_opts.get('default_include', 'minion.d/*.conf')
+
         include = pre_opts.get('include', [])
         pre_opts = salt.config.include_config(
             default_include, pre_opts, opts['conf_file'], verbose=False

(3) Better patch: As 'default_include' variable is already predefined in 'config.py' file, that is parsed earlier, so there is no point in redefining that again in 'loader.py' so a better version of patch for 'loader.py' file may be

@@ -132,7 +132,15 @@
         salt.config.load_config(
             pre_opts, opts['conf_file'], 'SALT_MINION_CONFIG'
         )
-        default_include = pre_opts.get('default_include', [])
+        #default_include = pre_opts.get('default_include', [])
+       #-- if 'default_include' is missing(or commented out) in minion
+       #-- config file then look for predefined default_config
+       if 'default_include' in opts:
+           predef_default_include = opts['default_include']
+       else:
+           predef_default_include = []
+        default_include = pre_opts.get('default_include', predef_default_include)
+
         include = pre_opts.get('include', [])
         pre_opts = salt.config.include_config(
             default_include, pre_opts, opts['conf_file'], verbose=False

hope this helps.

mlister2006 avatar Oct 08 '12 02:10 mlister2006

Yes, this looks good. I will most likely get to this in a few more days when I finish up the major features for 0.10.4

thatch45 avatar Oct 08 '12 03:10 thatch45

Nice job @UtahDave ! This is a very clean fix :)

thatch45 avatar Oct 16 '12 22:10 thatch45

Nice and clean indeed! Thanks @UtahDave.

borgstrom avatar Oct 16 '12 22:10 borgstrom