title: Groups in my Ansible inventory does not work as expected
body: <p>My yaml inventory (dev environment) is like this:</p>
  
  <pre><code>$&gt; more inventory/dev/hosts.yml 
  
  all:
    children:
      dmz1:
        children:
          ch:
            children:
              amq:
                hosts:
                  myamqdev01.company.net: nodeId=1
                  myamqdev02.company.net: nodeId=2
              smx:
                hosts:
                  mysmxdev01.company.net: nodeId=1
                  mysmxdev02.company.net: nodeId=2
      intranet:
        children:
          ch:
            children:
              amq:
                hosts:
                  amqintradev01.company.net: nodeId=1
                  amqintradev02.company.net: nodeId=2
              smx:
                hosts:
                  smxintradev01.company.net: nodeId=1
                  smxintradev02.company.net: nodeId=2  
  </code></pre>
  
  <p>and when I try to ping (with <code>ansible -i inventory/dev -m ping all</code> I got the error:</p>
  
  <pre><code>children: | UNREACHABLE! =&gt; {
      "changed": false, 
      "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname children:: Temporary failure in name resolution", 
      "unreachable": true
  }
  ch: | UNREACHABLE! =&gt; {
      "changed": false, 
      "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname ch:: Temporary failure in name resolution", 
      "unreachable": true
  }
  all: | UNREACHABLE! =&gt; {
      "changed": false, 
      "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname all:: Temporary failure in name resolution", 
      "unreachable": true
  }
  lan: | UNREACHABLE! =&gt; {
      "changed": false, 
      "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname lan:: Temporary failure in name resolution", 
      "unreachable": true
  }
  amq: | UNREACHABLE! =&gt; {
      "changed": false, 
      "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname amq:: Temporary failure in name resolution", 
      "unreachable": true
  }
  hosts: | UNREACHABLE! =&gt; {
      "changed": false, 
      "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname hosts:: Temporary failure in name resolution", 
      "unreachable": true
  }
  
  etc...
  </code></pre>
  
  <p>For troubleshooting, when I execute <code>ansible -i inventory/dev --list-hosts all</code> I got: </p>
  
  <pre><code>hosts (16):
    all:
    children:
    dmz1:
    ch:
    amq:
    hosts:
    myamqdev01.company.net:
    myamqdev02.company.net:
    smx:
    mysmxdev01.company.net:
    mysmxdev02.company.net:
    intranet:
    amqintradev01.company.net:
    amqintradev02.company.net:
    smxintradev01.company.net:
    smxintradev02.company.net:
  </code></pre>
  
  <p>I think this command should only give the hosts, no?</p>
  
  <p>I am not sure what is the issue but I followed the example from the <a href="https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#inheriting-variable-values-group-variables-for-groups-of-groups" rel="nofollow noreferrer">official doc</a> and I think there's a problem with my hosts.yml file but cannot guess what I am missing.</p>
  
  <p><strong>UPDATE</strong>
  When I correct the nodeId variables according to the answer, the list <code>all</code> is working fine. However when I try to filter by an intermediate parent this is not working: </p>
  
  <pre><code>ansible -i inventory/dev --list-hosts intranet
  </code></pre>
  
  <p>does not return the intranet hosts but all.</p>
  
  <p>When I try: <code>ansible -i inventory/dev --list-hosts amq</code> 
  only amq server are properly returned.</p>