# vmm ~~ tasks/init_vm.yml --- - include_role: name: serial - name: Stop vm if running shell: vmctl stop "{{ guest }}" ; vmctl stop vm-tmp ignore_errors: true - set_fact: iso: "{{ vms | selectattr('name', 'equalto', guest) | map(attribute='iso') | first }}" - debug: var: iso - include: set_facts.yml - name: Start temporary vm shell: vmctl start -r {{ iso_latest }} -d {{ disk_file }} -n {{ vmm.switch.name }} -m 1G vm-tmp - name: Pause 30 seconds for vm boot pause: seconds: 30 - name: Init vm via script script: init_vm_serial.py \ {{ guest }} \ {{ hostvars[guest].ip.out }} \ {{ hypervisor.gateway }} \ {{ hypervisor.mask }} \ {{ _i.dns[0] }} \ "{{ lookup('file', inventory_dir + '/files/pubkeys/rgoncalves.pub') }}" args: executable: "/usr/local/bin/python3"