--- # quite a lot of duplication, probably fix later # Gather info - name: Check if vm was created already stat: path: "{{userdata}}/{{vm.name}}" register: vmexists ignore_errors: true - name: Check for ubuntu iso stat: path: "{{role_path}}/files/ubuntu20_04.iso" register: isoexists ignore_errors: true - name: Check for ubuntu iso seed stat: path: "{{userdata}}/{{vm.name}}/seed.iso" register: seedexists ignore_errors: true # Setting up VM - name: Create directory for VM file: state: directory path: "{{userdata}}/{{vm.name}}" when: vmexists.stat.exists == false # didn't use get_url module since it broke with symlinks - name: Fetching ubuntu iso command: curl -o "{{role_path}}/files/ubuntu20_04.iso" https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-live-server-amd64.iso when: isoexists.stat.exists == false - name: Create disk images shell: cmd: "for i in {1..6}; do qemu-img create -f qcow2 {{userdata}}/{{vm.name}}/drive${i} {{vm.disk_size}}; done" when: vmexists.stat.exists == false - name: Creating cloud-init iso command: "genisoimage -output {{userdata}}/{{vm.name}}/seed.iso -volid cidata -joliet -rock {{role_path}}/files/user-data {{role_path}}/files/meta-data" when: seedexists.stat.exists == false