summaryrefslogtreecommitdiff
path: root/roles/vm/guest/create/tasks
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2022-01-06 19:22:14 +0100
committerChristian Pointner <equinox@spreadspace.org>2022-01-06 19:22:14 +0100
commite3d0be5df3a8a43b19da0bb814c8174048cfc79f (patch)
treeadf9917fb0dbe94328c465da5e46b96317a3870d /roles/vm/guest/create/tasks
parentMerge branch 'topic/openwrt-deploy' (diff)
split up vm/define into remove and create
Diffstat (limited to 'roles/vm/guest/create/tasks')
-rw-r--r--roles/vm/guest/create/tasks/main.yml28
1 files changed, 28 insertions, 0 deletions
diff --git a/roles/vm/guest/create/tasks/main.yml b/roles/vm/guest/create/tasks/main.yml
new file mode 100644
index 00000000..d9215b40
--- /dev/null
+++ b/roles/vm/guest/create/tasks/main.yml
@@ -0,0 +1,28 @@
+---
+- name: define vm
+ delegate_to: "{{ vm_host.name }}"
+ virt:
+ command: define
+ xml: "{{ lookup('template', 'libvirt-domain.xml.j2') }}"
+
+- name: start new vm
+ when: vm_create_start | bool
+ delegate_to: "{{ vm_host.name }}"
+ block:
+ - name: start vm
+ virt:
+ name: "{{ inventory_hostname }}"
+ state: running
+
+ - name: wait for VM to start
+ wait_for_virt:
+ name: "{{ inventory_hostname }}"
+ states: running
+ timeout: 10
+
+- name: mark vm as autostarted
+ delegate_to: "{{ vm_host.name }}"
+ virt:
+ name: "{{ inventory_hostname }}"
+ autostart: "{{ vm_create_autostart }}"
+ command: info ## virt module needs either command or state