# 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