get_user_vm_defs.yml 1.0 KB

12345678910111213141516171819202122
  1. ---
  2. # Parse user-provided VM specifications and store them in a list of dictionaries,
  3. # with each VM's specifications stored in a dictionary.
  4. - name: Read user-provided VM specs from {{ vm_data_tsv }}
  5. shell: /usr/bin/awk -F'~' '!/^#/ && !/^$/ && NR!=1 {print $0}' {{ vm_data_tsv }}
  6. register: tsvout
  7. - name: Load VM specs from tsv into the list user_vm_defs
  8. set_fact:
  9. user_vm_defs: "{{ user_vm_defs|default([]) + [ { \
  10. 'vm_name' : item.split('~').0, \
  11. 'vm_ip' : item.split('~').1, \
  12. 'vm_subnet_name' : item.split('~').2, \
  13. 'vm_image_name' : item.split('~').3, \
  14. 'vm_num_sockets' : item.split('~').4, \
  15. 'vm_memory' : item.split('~').5, \
  16. 'vm_disk_list' : item.split('~').6} ] }}"
  17. with_items: "{{ tsvout.stdout_lines }}"
  18. - name: Debug | User-provided VM Specifications
  19. debug:
  20. msg: "User-provided VM specifications: {{ user_vm_defs }}"
  21. when: global_debug|bool