title: Loop through list variable in Ansable
body: <p>I am making an ansible script where a variable file will hold a list of servers, where I will loop through and power them down. It appears that Ansible is changing my list to a string, but maybe I am wrong.</p>
  
  <p>I've tried using "loop", "with_items", and having them on the same line. serverA and ServerB does indeed exist </p>
  
  <p>File dir:</p>
  
  <pre><code>taskName/vars/ServerListA.yaml
  
  taskName/tasks/main.yaml
  
  taskName/tasks/shutdown.yaml
  </code></pre>
  
  <p>ServerListA.yaml:</p>
  
  <pre><code>---
    evenServers:
      - serverB
      - serverA
  </code></pre>
  
  <p>main.yaml:</p>
  
  <pre><code>---
  - import_tasks: shutdown.yaml
  </code></pre>
  
  <p>shutdown.yaml:</p>
  
  <pre><code>---
    - name: get vars
      include_vars:
        file: ServerListA.yaml
        name: evenServers
  
    - name: shutdown guest
      vmware_guest_powerstate:
        hostname: virtualCenterName
        state: powered-on
        username: user
        name: "{{ item }}"
        password: pass
        validate_certs: no
      loop:
        - "{{ evenServers }}"
  </code></pre>
  
  <p><strong>output:</strong></p>
  
  <blockquote>
    <p>TASK [vCenter_Infra_HA_Test : shutdown guest]
    *********************************************************************************************************  [WARNING]: The value {'evenServers': ['serverA', 'serverB']} (type
    dict) in a string field was converted to u"{'evenServers': ['serverA',
    'serverB']}" (type string). If this does not look like what you
    expect, quote the entire value to ensure it does not change.</p>
    
    <p>failed: [localServer] (item={u'evenServers': [u'serverA',
    u'serverB']}) => {"ansible_loop_var": "item", "changed": false,
    "item": {"evenServers": ["serverA", "serverB"]}, "msg": "Unable to set
    power state for non-existing virtual machine : '{'evenServers':
    ['serverA', 'serverB']}'"}</p>
  </blockquote>