summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ansible.cfg1
-rw-r--r--common/vm-deploy.yml12
-rw-r--r--inventory/host_vars/ch-testvm-openwrt.yml29
-rw-r--r--library/wait_for_virt.py (renamed from roles/vm/guest/install/library/wait_for_virt.py)0
-rw-r--r--roles/vm/guest/deploy/defaults/main.yml7
-rw-r--r--roles/vm/guest/deploy/tasks/main.yml26
6 files changed, 49 insertions, 26 deletions
diff --git a/ansible.cfg b/ansible.cfg
index ef74d99c..e3b31768 100644
--- a/ansible.cfg
+++ b/ansible.cfg
@@ -7,6 +7,7 @@ log_path = ./log
remote_tmp = /tmp/.ansible/tmp
filter_plugins = ./filter_plugins
+library = ./library
gathering = smart
fact_caching = jsonfile
diff --git a/common/vm-deploy.yml b/common/vm-deploy.yml
index e7c9ded7..bc2e8039 100644
--- a/common/vm-deploy.yml
+++ b/common/vm-deploy.yml
@@ -22,11 +22,9 @@
when:
- (output_images | length) != 1
- - name: fetch infos from image file
- stat:
- path: "{{ output_images | first }}"
- get_mime: yes
- register: output_images_info
- - debug:
- var: output_images_info.stat
+- name: deploy vm
+ hosts: "{{ install_hostname }}"
+ gather_facts: no
+ roles:
+ - role: vm/guest/deploy
diff --git a/inventory/host_vars/ch-testvm-openwrt.yml b/inventory/host_vars/ch-testvm-openwrt.yml
index f14bd548..5a208b55 100644
--- a/inventory/host_vars/ch-testvm-openwrt.yml
+++ b/inventory/host_vars/ch-testvm-openwrt.yml
@@ -8,9 +8,8 @@ install:
primary: /dev/sda
scsi:
sda:
- type: zfs
- name: root
- size: 15g
+ type: image
+ path: /srv/nvme/ch-testvm-openwrt.img
interfaces:
- bridge: br-svc
name: svc0
@@ -98,20 +97,12 @@ openwrt_uci:
proto: static
ipaddr: "{{ network_zones.svc.prefix | ipaddr(network_zones.svc.offsets[inventory_hostname]) | ipaddr('address') }}"
netmask: "{{ network_zones.svc.prefix | ipaddr('netmask') }}"
+ gateway: "{{ network_zones.svc.gateway }}"
+ dns: "{{ network_zones.svc.dns }}"
-
-virsh_domxml: |
- <domain type='kvm'>
- <os>
- <kernel>/srv/ch-router/vmlinuz</kernel>
- <cmdline>console=ttyS0,115200n8 noinitrd root=/dev/vda</cmdline>
- <boot dev='hd'/>
- </os>
- <devices>
- <disk type='file' device='disk'>
- <driver name='qemu' type='raw' cache='none'/>
- <source file='/srv/ch-router/rootfs-ext4.img'/>
- <target dev='sda' bus='virtio'/>
- </disk>
- </devices>
- </domain>
+ - name: route 'lan'
+ options:
+ interface: svc
+ target: "{{ network_zones.lan.prefix | ipaddr('network') }}"
+ netmask: "{{ network_zones.lan.prefix | ipaddr('netmask') }}"
+ gateway: "{{ network_zones.svc.prefix | ipaddr(network_zones.svc.offsets['ch-gw-lan']) | ipaddr('address') }}"
diff --git a/roles/vm/guest/install/library/wait_for_virt.py b/library/wait_for_virt.py
index 6c49fae1..6c49fae1 100644
--- a/roles/vm/guest/install/library/wait_for_virt.py
+++ b/library/wait_for_virt.py
diff --git a/roles/vm/guest/deploy/defaults/main.yml b/roles/vm/guest/deploy/defaults/main.yml
new file mode 100644
index 00000000..c067ecbc
--- /dev/null
+++ b/roles/vm/guest/deploy/defaults/main.yml
@@ -0,0 +1,7 @@
+---
+vm_deploy_decompressors:
+ "application/octet-stream": cat
+ "application/gzip": gunzip
+ "application/zstd": unzstd
+ "application/x-bzip2": bunzip2
+ "application/x-xz": unxz
diff --git a/roles/vm/guest/deploy/tasks/main.yml b/roles/vm/guest/deploy/tasks/main.yml
new file mode 100644
index 00000000..cc9733ba
--- /dev/null
+++ b/roles/vm/guest/deploy/tasks/main.yml
@@ -0,0 +1,26 @@
+---
+- name: fetch infos from image file
+ delegate_to: localhost
+ stat:
+ path: "{{ output_images | first }}"
+ get_mime: yes
+ register: output_image_info
+
+ ## TODO: prepare directory for disk images
+ ## TODO: compute disk path based on install.disks.primary and install.disks.(scsi|virtio)
+ ## TODO: actually call this directly and make file replacement atomic!!
+- name: copy disk image
+ pause:
+ prompt: |
+ Please copy the image to the vm-host i.e. by calling this:
+
+ cat {{ output_image_info.stat.path }} | {{ vm_deploy_decompressors[output_image_info.stat.mimetype] }} | ssh {{ vm_host.name }} 'cat > {{ install.disks.scsi.sda.path }}'
+
+ When done press ENTER to continue or CTRL-C then A to abort.
+
+- name: define vm
+ vars:
+ vm_define_installer: no
+ delegate_to: "{{ vm_host.name }}"
+ import_role:
+ name: vm/guest/define