title: Hiera isn't resolving Facts
body: <p>I'm having some trouble with Puppet and Hiera, in that Hiera seems to not be using the facts I ask for in the templates.</p>
  
  <p>I have a <code>/etc/puppetlabs/puppet/hiera.yaml</code> file, with a simple sample hierarchy in it:</p>
  
  <pre><code>---
  version: 5
  
  defaults:
    datadir: "/etc/puppetlabs/code/environments/%{::environment}/hieradata"
    data_hash: yaml_data
  
  hierarchy:
    - name: "Per-node data"
      path: "nodes/%{trusted.certname}.yaml"
  
    - name: "Per-OS defaults"
      path: "os/%{facts.os.family}.yaml"
  
    - name: "Common data"
      path: "common.yaml"
  </code></pre>
  
  <p>I then have a puppet agent which has run and sent it's facts to Puppet. When I test a lookup on it, the variables all expand out to empty strings:</p>
  
  <pre><code>&gt; puppet lookup profiles --environment production --node puppet.example.local --explain
  
  Searching for "lookup_options"
    Global Data Provider (hiera configuration version 5)
      Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
      Merge strategy hash
        Hierarchy entry "Per-node data"
          Path "/etc/puppetlabs/code/environments/production/hieradata/nodes/test-.yaml"
            Original path: "nodes/test-%{trusted.certname}.yaml"
            Path not found
        Hierarchy entry "Per-OS defaults"
          Path "/etc/puppetlabs/code/environments/production/hieradata/os/.yaml"
            Original path: "os/%{facts.os.family}.yaml"
            Path not found
        Hierarchy entry "Common data"
          Path "/etc/puppetlabs/code/environments/production/hieradata/common.yaml"
            Original path: "common.yaml"
            No such key: "lookup_options"
  Searching for "profiles"
    Global Data Provider (hiera configuration version 5)
      Using configuration "/etc/puppetlabs/puppet/hiera.yaml"
      Hierarchy entry "Per-node data"
        Path "/etc/puppetlabs/code/environments/production/hieradata/nodes/.yaml"
          Original path: "nodes/test-%{trusted.certname}.yaml"
          Path not found
      Hierarchy entry "Per-OS defaults"
        Path "/etc/puppetlabs/code/environments/production/hieradata/os/.yaml"
          Original path: "os/%{facts.os.family}.yaml"
          Path not found
      Hierarchy entry "Common data"
        Path "/etc/puppetlabs/code/environments/production/hieradata/common.yaml"
          Original path: "common.yaml"
          No such key: "profiles"
  Function lookup() did not find a value for the name 'profiles'
  </code></pre>
  
  <p>The value isn't found, but I figure that's irrelevant because it isn't even looking for any real files, that are all showing as <code>nodes/.yaml</code> and <code>os/.yaml</code>.</p>
  
  <p>If I run the command again with <code>--debug</code>, I can see a dump of information about the node that includes the facts:</p>
  
  <pre><code>Debug: Facter: fact "osfamily" has resolved to "RedHat".
  ...
  Debug: Facter: fact "os" has resolved to {
    architecture =&gt; "x86_64",
    family =&gt; "RedHat",
    hardware =&gt; "x86_64",
    name =&gt; "CentOS",
    release =&gt; {
      full =&gt; "7.4.1708",
      major =&gt; "7",
      minor =&gt; "4"
    },
  </code></pre>
  
  <p>Puppet: 5.4.0</p>