title: Puppet: Access hashkey in dynamic variable path
body: <p>I've got a puppet hash type data structure like this to store ssh keys:</p>
  <pre><code>class users::sshkeys {
    $user1 = {
        user1 =&gt; {
            key =&gt; 'AAAAAA',
            type =&gt; 'ssh-rsa'
         }
    }
    $user2 = {
        user2 =&gt; {
            key =&gt; 'BBBBBB',
            type =&gt; 'ed25519'
        }
    }
  }
  </code></pre>
  <p>I can access a key like this:</p>
  <pre><code>$users::sshkeys::user1['user1']['key']
  </code></pre>
  <p>I would like to access a key dynamically (e.g. in a loop), like this:</p>
  <pre><code>$users = ['user1', 'user2']
  
  $users.each |$user| {
    $users::sshkeys::$user[$user]['key']
  }
  </code></pre>
  <p>I found a solution to access a dynamic class/variable like this:</p>
  <pre><code>$mydynamicvar = getvar(&quot;users::sshkeys::${user1}&quot;)
  notify{&quot;$mydynamicvar&quot;:}
  </code></pre>
  <p>This seems to return a String, so that  I can't access the hashkeys inside:</p>
  <pre><code>notify{&quot;$mydynamicuser[$user]['key']&quot;:}
  </code></pre>
  <p>Any Ideas?</p>