aboutsummaryrefslogblamecommitdiffstats
path: root/roles/vmm/tasks/disk.yml
blob: 95427c6ac96581af870395acf01060c76f013232 (plain) (tree)
1
2
3
4
5



                                                                                  
                       









                                          













                                                       
- name: create disks
  command:
    cmd: vmctl create -s "{{ item.size }}" "{{ item.name }}.{{ vmm_disk_format }}"
    chdir: "{{ vmm_disk_dir }}"
  loop: "{{ vmm_vms }}"
  register: result
  changed_when: result.rc == 0
  failed_when:
    - result.rc != 0
    - "'File exists' not in result.stderr"

- name: retrieve existing disks
  find:
    path: "{{ vmm_disk_dir }}"
    patterns: "*.{{ vmm_disk_format }}"
  register: result

- name: append disks informations to vms facts
  set_fact:
    vmm_vms_tmp: >
      {{ vmm_vms_tmp | default([]) + [ item | combine({
        "disk": result.files
          | selectattr("path", "regex", item.name, )
      }) ] }}
  loop: "{{ vmm_vms }}"

- name: save variables
  set_fact:
    vmm_vms: "{{ vmm_vms_tmp }}"
remember that computers suck.