title: Referencing dictionary values
body: <p>Global variable <code>group_vars/all.yml</code></p>
  
  <pre><code>---
  dir:
    website_A: /var/www/html/a
    website_B: /var/www/html/b
  </code></pre>
  
  <p>I have created Ansible role <code>health-check</code> which accepts input variable <code>site</code>, it can have values <code>website_A</code> or <code>website_B</code>. This role will perform some actions based on the input variable <code>site</code>. I tried with the following settings, but it didn't worked. </p>
  
  <p><code>chdir: "{{ "dir." + site }}"</code> </p>
  
  <p>As per the <a href="http://docs.ansible.com/ansible/latest/faq.html" rel="nofollow noreferrer">FAQ</a>, we can make this work using hostvars or vars dictionary, but I didn't succeed in that.</p>