diff options
Diffstat (limited to 'roles/vmm/tasks/generate_disk.yml')
-rw-r--r-- | roles/vmm/tasks/generate_disk.yml | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/roles/vmm/tasks/generate_disk.yml b/roles/vmm/tasks/generate_disk.yml new file mode 100644 index 0000000..c8ec091 --- /dev/null +++ b/roles/vmm/tasks/generate_disk.yml @@ -0,0 +1,21 @@ + +# vmm ~~ tasks/generate_disk.yml + +--- + +- name: Check existence of disk directory + file: + path: "{{ vmm.disk.dir }}" + state: directory + +- name: Get existing disk file size + stat: + path: "{{ vmm.disk.dir }}/{{ hostvars[vm].ansible_host }}.{{ vmm.disk.format }}" + register: st + +- name: Generate vm disk + shell: | + disk="{{ vmm.disk.dir }}/{{ hostvars[vm].ansible_host }}.{{ vmm.disk.format }}" + rm "${disk}" + vmctl create -s {{ hostvars[vm].size }} "${disk}" + when: not st.stat.exists or st.stat.size == 0 |