From 80b5d3d5b8846bd0396dbe38fe83f85c34f84ede Mon Sep 17 00:00:00 2001 From: binary Date: Mon, 9 Nov 2020 13:25:05 +0100 Subject: Start and stop vm --- roles/vmm/tasks/init_vm.yml | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'roles/vmm/tasks') diff --git a/roles/vmm/tasks/init_vm.yml b/roles/vmm/tasks/init_vm.yml index 4ded177..6b5cf4d 100644 --- a/roles/vmm/tasks/init_vm.yml +++ b/roles/vmm/tasks/init_vm.yml @@ -6,8 +6,24 @@ - 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 \ @@ -19,8 +35,4 @@ "{{ lookup('file', inventory_dir + '/files/pubkeys/rgoncalves.pub') }}" args: executable: "/usr/local/bin/python3" - register: rg -- name: Installation result - debug: - var: rg.stdout_lines -- cgit v1.2.3