title: How do i add the contents of a pillar variable to a file with salt?
body: <p>In a salt state file, how do I add the contents of a pillar to a file on the remote salt-minion?</p>
  
  <p>For instance, if I have pillar data like:</p>
  
  <pre><code>ssl:
      some-domain.com:
          key:
              -----BEGIN RSA PRIVATE KEY-----
              MIICX... snip ...
  </code></pre>
  
  <p>And on the remote salt-minion, I want to have a file like, <code>/etc/nginx/ssl/som-domain.com.key</code> that contains the contents of that private key, how would I do it?  I'm also open to an answer like, "You're doing it all wrong, dummy."  As long as you give me some insight and point me in the right direction it will help tremendously.</p>
  
  <p>I know about salt's <code>file.managed</code>, and <code>file.*</code> friends from some testing, but I'm not sure if there's a best / preferred way to add arbitrary pillar data to a remote file as I'm trying to do.</p>
  
  <p>I'm still learning / hacking around with salt, so I'm also still using Yaml + Jinja for templating, if it matters to you in formulating an appropriate answer.</p>
  
  <p>Thanks!</p>
  
  <p><strong>Edit:</strong>  By the way current, hacky solution is:</p>
  
  <p>Create a file in my file_root /srv/salt/, like <code>/srv/salt/ssl/some-domain.com.key</code> that contains something like <code>{{ salt[pillar.get]('ssl:some-domain.com:key') }}</code></p>
  
  <p>But that just seems so hacky.  Looking for a better solution here.</p>