5

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 Answer 1

2

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.

6
  • so there is no location as such of grains storage in minion and master. Aug 3, 2018 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, 2018 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 Aug 3, 2018 at 9:09
  • 1
    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, 2018 at 9:15
  • I tried the same with custom grains but they are still present. Aug 3, 2018 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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