title: ansible when statement iterating over list
body: <p>trying to set a condition to restart an EC2 instance if reboot is requried after installing windows features.</p>
  
  <pre><code>  - name: Install IIS Web-Server
      win_feature:
        name: '{{ item }}'
        state: present
      loop: '{{ win_features }}'
      register: register_win_feature
  
     - debug:
        var: register_win_feature
  </code></pre>
  
  <p>the debug shows this:</p>
  
  <pre><code>      {
  "register_win_feature": {
      "msg": "All items completed",
      "changed": false,
      "results": [
          {
              "_ansible_parsed": true,
              "feature_result": [],
              "_ansible_item_result": true,
              "_ansible_item_label": "Web-Server",
              "success": true,
              "failed": false,
              "_ansible_no_log": false,
              "changed": false,
              "reboot_required": false,
              "item": "Web-Server",
              "restart_needed": false,
              "_ansible_ignore_errors": null,
              "exitcode": "NoChangeNeeded"
          },
          {
              "_ansible_parsed": true,
              "feature_result": [],
              "_ansible_item_result": true,
              "_ansible_item_label": "Web-Asp-Net45",
              "success": true,
              "failed": false,
              "_ansible_no_log": false,
              "changed": false,
              "reboot_required": false,
              "item": "Web-Asp-Net45",
              "restart_needed": false,
              "_ansible_ignore_errors": null,
              "exitcode": "NoChangeNeeded"
          },
          {
              "_ansible_parsed": true,
              "feature_result": [],
              "_ansible_item_result": true,
              "_ansible_item_label": "Web-Net-Ext45",
              "success": true,
              "failed": false,
              "_ansible_no_log": false,
              "changed": false,
              "reboot_required": false,
              "item": "Web-Net-Ext45",
              "restart_needed": false,
              "_ansible_ignore_errors": null,
              "exitcode": "NoChangeNeeded"
          },
          {
              "_ansible_parsed": true,
              "feature_result": [],
              "_ansible_item_result": true,
              "_ansible_item_label": "Web-Windows-Auth",
              "success": true,
              "failed": false,
              "_ansible_no_log": false,
              "changed": false,
              "reboot_required": false,
              "item": "Web-Windows-Auth",
              "restart_needed": false,
              "_ansible_ignore_errors": null,
              "exitcode": "NoChangeNeeded"
          }
      ]
  },
  "changed": false,
  "_ansible_verbose_always": true,
  "_ansible_no_log": false
  </code></pre>
  
  <p>}</p>
  
  <p>Then if i use this module:</p>
  
  <pre><code>    - name: reboot if installing Web-Server feature requires it
        win_reboot:
        when: register_win_feature.results.reboot_required == true
  </code></pre>
  
  <p>the module fails because the out put is a list</p>
  
  <pre><code>    "msg": "The conditional check 'register_win_feature.results.reboot_required == true' failed. The error was: error while evaluating conditional (register_win_feature.results.reboot_required == true): 'list object' has no attribute 'reboot_required'\n\nThe error appears to have been in '/var/lib/awx/projects/_5378__256_bowtie_test/roles/enx_bowtie_server/tasks/main.yml': line 35, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: reboot if installing Web-Server feature requires it\n  ^ here\n",
  "_ansible_no_log": false
  </code></pre>
  
  <p>if i add a [*] to loop over all the results list, it doesn't recognize it. It also fails:</p>
  
  <pre><code>  - name: reboot if installing Web-Server feature requires it
      win_reboot:
      when: register_win_feature.results[*].reboot_required == true
  
  
      "msg": "The conditional check 'register_win_feature.results[*].reboot_required == true' failed. The error was: template error while templating string: unexpected '*'. String: {% if register_win_feature.results[*].reboot_required == true %} True {% else %} False {% endif %}\n\nThe error appears to have been in '/var/lib/awx/projects/_5378__256_bowtie_test/roles/enx_bowtie_server/tasks/main.yml': line 35, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: reboot if installing Web-Server feature requires it\n  ^ here\n",
  "_ansible_no_log": false
  </code></pre>
  
  <p>Can't get it working. i have searhed the web for a similar issue but with no succes. </p>
  
  <p>:( any help would be much apprictaied. </p>