title: Salt custom grains
body: <p>I am trying to write custom grains.
  I put this code in <code>/etc/salt/grains</code></p>
  
  <pre><code>#!/usr/bin/env python
  def function():
      grains = {}
      grains['test'] = "test"
      return grains
  </code></pre>
  
  <p>and to test it I created this script:</p>
  
  <pre><code>import salt.config
  import salt.loader
  __opts__ = salt.config.minion_config('/etc/salt/minion')
  __grains__ = salt.loader.grains(__opts__)
  test = __grains__['test']
  print test
  </code></pre>
  
  <p>I've got this error:</p>
  
  <pre><code>dirs = __grains__['test']
  KeyError: 'test'
  </code></pre>
  
  <p>What's wrong with this ? </p>