title: Ansible: Using a dictionary variable within a lookup
body: <p>I am attempting to deploy ssh keys with ansible using a file lookup task that utilizes {{ item.key }} which is simply a username and I am trying to find the appropriate syntax to call for the lookup value. </p>
  
  <pre><code># Deploy Key Task
  - name: add user ssh keys
    authorized_key:
      user={{ item.key }}
      key={{ lookup('file', 'files/{{ item.key }}.pub') }}
    with_dict: users
  </code></pre>
  
  <p>Where users is</p>
  
  <pre><code>users:
    example:
      state: present
      comment: "Example User"
      shell: "/bin/bash"
      uid: 5001
      gid: 5001
  </code></pre>
  
  <p>From the dictionary, I am wanting to use item.key to populate the user.pub file.</p>
  
  <p>Within the files directory I simply have a file called example.pub with the users public key.</p>
  
  <p>Blockquote</p>