title: ansible loop with failed_when on register variable list output
body: <p>Team, </p>
  
  <p>I have below task working fine when i only have one node or only one item but I need to modify it work for all items returned in the list that is stored in register variable.</p>
  
  <pre><code>      - name: "Fetch all CPU nodes from clusters using K8s beta.kubernetes.io/instance-type"
          k8s_info:
            kind: Node
            label_selectors:
            - "beta.kubernetes.io/instance-type={{ kube_cpu_node_class }}"
            verify_ssl: no
          register: cpu_class_list
          failed_when: not cpu_class_list.resources
  </code></pre>
  
  <p>How can i do this for all nodes in cpu_class_list variable with loop or with_items?</p>
  
  <p>proposed solution but does not work</p>
  
  <pre><code>      - name: "Fetch all CPU nodes from clusters using K8s beta.kubernetes.io/instance-type"
          k8s_info:
            kind: Node
            label_selectors:
            - "beta.kubernetes.io/instance-type={{ kube_cpu_node_class }}"
            verify_ssl: no
          register: cpu_class_list
          failed_when: not {{ item }}
          with_items: cpu_class_list.resources
  </code></pre>
  
  <p>sample output with two nodes is below </p>
  
  <pre><code>services-pre-install-checks : debug] 
  
  
  ok: [localhost] =&gt; {
      "cpu_class_list": {
          "changed": false,
          "deprecations": [
              {
                  "msg": "The 'k8s_facts' module has been renamed to 'k8s_info'",
                  "version": "2.13"
              }
          ],
          "failed": false,
          "failed_when_result": false,
          "resources": [
              {
                  "apiVersion": "v1",
                  "kind": "Node",
                  "metadata": {
                      "annotations": {
                          "volumes.kubernetes.io/controller-managed-attach-detach": "true"
                      },
                      "creationTimestamp": "2019-07-16T00:23:27Z",
                      "labels": {
                          "nodeType": "cpu"
                      },
                      "name": "node1",
                      "nodeInfo": {
                          "architecture": "amd64",
                      }
                  }
              },
  
  
  {
               {
                  "apiVersion": "v1",
                  "kind": "Node",
                  "metadata": {
                      "annotations": {
                          "volumes.kubernetes.io/controller-managed-attach-detach": "true"
                      },
                      "creationTimestamp": "2019-07-16T00:23:27Z",
                      "labels": {
                          "nodeType": "cpu"
                      },
                      "name": "node2",
                      "nodeInfo": {
                          "architecture": "amd64",
                      }
                  }
               }
          ]
      }
  }
  </code></pre>
  
  <p>Proposed Solution:</p>
  
  <pre><code>      - name: "Fetch all CPU nodes from clusters using K8s beta.kubernetes.io/instance-type"
          k8s_facts:
            kind: Node
            label_selectors:
            - "beta.kubernetes.io/instance-type={{ kube_cpu_node_class }}"
            verify_ssl: no
          register: cpu_class_list
          failed_when: not cpu_class_list.resources 
  
  #above to fail when none of the nodes has label, that is resources list is empty.
  
  #below to fail when any of the nodes has no label
  
         - debug:
            msg: "{{ item.metadata.labels.nodeType }}"
          loop: "{{ cpu_class_list.resources }}"
          loop_control:
            label: "{{ item.metadata.name }}"
          failed_when: not item.metadata.labels.nodeType
  </code></pre>