title: Access Environmental Variables with SaltStack Grains
body: <p>I would like to know how to correctly access <code>Environmental Variables</code> with <code>SaltStack Grains</code>.  </p>
  
  <p>I have been following the <a href="http://docs.saltstack.com/en/latest/topics/targeting/grains.html" rel="nofollow">documentation</a> but have been unable to get it working.  Here is the code that I have:</p>
  
  <p><em>/srv/salt/_grains/env_vars.py</em></p>
  
  <pre><code>import os
  
  def env_vars():
      return {'T17_SECRET_KEY': os.environ.get('T17_SECRET_KEY','')}
  </code></pre>
  
  <p>I then run <code>salt '*' saltutil.sync_grains</code></p>
  
  <p>And I get this response:</p>
  
  <pre><code>salt:
      - grains.env_vars
  </code></pre>
  
  <p>But when I run <code>salt '*' grains.items</code> it shows:</p>
  
  <pre><code>salt:
      ----------
      SSDs:
      T17_SECRET_KEY:
      # other vars ...
  </code></pre>
  
  <p>So the key is there, but the value is not.  When I run <code>os.environ.get('T17_SECRET_KEY','')</code> from the Python Command Line, the value is there. </p>
  
  <p>What could be causing this?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I have changed this:</p>
  
  <p><em>/srv/salt/_grains/env_vars.py</em></p>
  
  <pre><code>from salt.modules import environ
  
  def env_vars():
      return {'T17_SECRET_KEY': environ.get('T17_SECRET_KEY','')}
  </code></pre>
  
  <p>When I execute this function from the Python Command line, it returns the Key:Value, but still when running <code>salt '*' saltutil.sync_grains</code> and <code>salt '*' grains.items</code> I cannot see the Value, only the Key.  </p>
  
  <p>I even ran <code>salt '*' state.highstate</code> to reload everything.</p>
  
  <p>Is this possibly being caused by some other configuration?  </p>