I would like to take the value of the var and pass it into with_items and I 
am running into an issue / error, how can i pass just the value into 
with_items.  If i hardcode and put the value with_items: {{ small2019 }} in 
there are no issues.  Using include_vars / file which has the data, want to 
pass value into with items to get results.

Result:
************************************
- debug:
    var:  "{{ 'vm_config' }}"

okL  [(servername)] => {
  "vm_config": "small2019"
}

Using with_items with value, errors
********************************************
- name: Create VMs
  win_hyperv_guest:
    vmname: "{{ vm_name }}"
    hvhostname: "{{ hv_fullname }}"
    installmedia_source: "{{ item.InstallMedia.Source }}"
    installmedia_destination: "{{ item.InstallMedia.Destination }}"
    importvmoptions_path: "{{ item.ImportVMOptions.Path }}"
    importvmoptions_destination: "{{ item.ImportVMOptions.Destination }}"
    systemosdisksize: "{{ item.SystemOSDiskSize | default (omit) }}"
    vmmemory: "{{ item.VMMemory }}"
    vmprocessor: "{{ item.VMProcessor }}"
    vmnetworkadaptervlan: "{{ item.VMNetworkAdapterVlan }}"
    vmnetworkadapter: "{{ item.VMNetworkAdapter | default (omit) }}"
    additionaldisks: "{{ item.AdditionalDisks | default (omit) }}"
    failoverclusteradd: "{{ item.FailoverClusterAdd | default (omit) }}"
    removedvdrive: "{{ item.RemoveDVDrive | default (omit) }}"    
    bootordergen2networklast: "{{ item.BootOrderGen2NetworkLast | default 
(omit) }}"
    state: present
  with_items: "{{ 'vm_config' }}"
  register: new_vms

Using with_items with hardcoded - works
********************************************
- name: Create VMs
  win_hyperv_guest:
    vmname: "{{ vm_name }}"
    hvhostname: "{{ hv_fullname }}"
    installmedia_source: "{{ item.InstallMedia.Source }}"
    installmedia_destination: "{{ item.InstallMedia.Destination }}"
    importvmoptions_path: "{{ item.ImportVMOptions.Path }}"
    importvmoptions_destination: "{{ item.ImportVMOptions.Destination }}"
    systemosdisksize: "{{ item.SystemOSDiskSize | default (omit) }}"
    vmmemory: "{{ item.VMMemory }}"
    vmprocessor: "{{ item.VMProcessor }}"
    vmnetworkadaptervlan: "{{ item.VMNetworkAdapterVlan }}"
    vmnetworkadapter: "{{ item.VMNetworkAdapter | default (omit) }}"
    additionaldisks: "{{ item.AdditionalDisks | default (omit) }}"
    failoverclusteradd: "{{ item.FailoverClusterAdd | default (omit) }}"
    removedvdrive: "{{ item.RemoveDVDrive | default (omit) }}"    
    bootordergen2networklast: "{{ item.BootOrderGen2NetworkLast | default 
(omit) }}"
    state: present
  with_items: "{{ small2019 }}"
  register: new_vms

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/03761546-e9df-4a13-85f8-5a56331e8a53%40googlegroups.com.

Reply via email to