title: get dict value from variable key in ansible
body: <p>Here is my problem I need to get a dict value from key. But the key is also a var.
  For example, I had an ansible role.</p>
  
  <p>In <strong>vars/main.yml</strong>, I defined vars as below:</p>
  
  <pre><code>---
  location:   "USA"
  source:     {
               "China":  "/net/server1/patha",
               "USA":  "/net/server2/pathb",
               "Japan": "/net/server3/pathc"
              }
  </code></pre>
  
  <p>So in my tasks: <strong>tasks/main.yml</strong>. How do get "/net/server2/pathb" using the vars. I tried below in tasks, all did not work.</p>
  
  <p><code>-shell: "perl run.perl {{ source.location }}/script.pl"</code></p>
  
  <p><code>-shell: "perl run.perl {{ source.{{ location }} }}/script.pl"</code></p>
  
  <p>This may be a simple question. But I searched many posts for a long time and still cannot get a right answer. So please help and many thanks.</p>