title: How to access variable name which include a hyphen in Ansible
body: <p>I have a simple vlan config file which I like to have the keys to match with JunOS syntax (this way I can pass them as aggrogate if I need to), so I'm using the <code>vlan-id</code> key like this example variable file.</p>
  <pre class="lang-yaml prettyprint-override"><code># vlans.yaml
  vlans:
      - name: general
        description: &quot;General&quot;
        vlan-id: 100
      - name: hotline
        description: &quot;Accounting&quot;
        vlan-id: 110
  </code></pre>
  <p>but i can't access the vlan-id key because of the hyphen</p>
  <pre class="lang-yaml prettyprint-override"><code>    - debug:
          msg: &quot;{{ item.vlan-id }}&quot;
        loop: &quot;{{ vlans }}&quot;
        tags: debug
  
  </code></pre>
  <pre><code>&quot;msg&quot;: &quot;The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'vlan'
  </code></pre>
  <p>if I output the item directly I can see the key</p>
  <pre><code>    - debug:
          msg: &quot;{{ item }}&quot;
        loop: &quot;{{ vlans }}
  </code></pre>
  <pre><code>ok: [SW02] =&gt; (item={'name': 'external', 'description': 'External', 'vlan-id': 209}) =&gt; {
      &quot;msg&quot;: {
          &quot;description&quot;: &quot;External&quot;,
          &quot;name&quot;: &quot;external&quot;,
          &quot;vlan-id&quot;: 209
      }
  }
  ok: [SW01] =&gt; (item={'name': 'external', 'description': 'External', 'vlan-id': 209}) =&gt; {
      &quot;msg&quot;: {
          &quot;description&quot;: &quot;External&quot;,
          &quot;name&quot;: &quot;external&quot;,
          &quot;vlan-id&quot;: 209
      }
  }
  </code></pre>
  <p>Any ideas how to solve this?</p>