4

I am trying to completely remove the grains from the system. I have one master and one minion setup(minion id= minion1). I am doing

salt minion1 grains.ls

that is listing me all the grains

Now I removed data.p which is the cache memory for the grains in master

path : /var/cache/salt/master/minions/minion1/data.p

Without running a salt_sync or any other command for sync I am again doing.

 `salt minion1 grains.ls`,

It's returning the same result.(The grains are still somewhere stored.

Where exactly it is storing the grains and how to delete that?

1

These are built-in grains, which are collected at minion startup. Here's the code responsible for generating them.

You cannot remove them, but you can overwrite them, for example to an empty value in /etc/salt/grains:

osfinger: null

or with grains execution module: salt minion1 grains.delval osfinger.

Keep in mind that some of the core grains are essential for the correct functioning of salt, e.g. module providers for pkg module rely on them.

| improve this answer | |
  • so there is no location as such of grains storage in minion and master. – Dheeraj Chelaramani Aug 3 '18 at 7:12
  • Yes, there's only cache which you can clear with salt-run cache.clear_grains or sync grains with salt-run saltutil.sync_grains. – A. Z. Aug 3 '18 at 8:04
  • I tried something: 1.Created some grains in minion 2 Synced the grains with the master 3 Cleared cache from the master 4 Then also it is showing the grains PS: This condition is after clearing cache and not syncing – Dheeraj Chelaramani Aug 3 '18 at 9:09
  • Yes, the cache is just that, a cache. When the grains are needed, and they are not in cache, they will get synchronized automatically. It's impossible to remove core grains. – A. Z. Aug 3 '18 at 9:15
  • I tried the same with custom grains but they are still present. – Dheeraj Chelaramani Aug 3 '18 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.