Add support to provision OpenBSD KVM guests

This commit is contained in:
Timo Makinen 2020-08-27 12:40:17 +00:00
parent d9f009565c
commit fc25e0a108
2 changed files with 14 additions and 2 deletions

View file

@ -14,3 +14,6 @@ tls_bundle: "{{ tls_certs }}/cert.pem"
dsk_size: 10
mem_size: 256
num_cpus: 1
# extra args for virt-install
virt_install_os_args: --cdrom https://www.foo.sh/ks/openbsd/openbsd.iso

View file

@ -13,6 +13,9 @@
dsk_opts: bus=virtio,cache=none,device=disk,format=raw
base: /srv/libvirt/hdd/{{ inventory_hostname }}
inject: >-
{% if not '--cdrom' in virt_install_os_args %}{{ true }}{% endif %}
virt_install_disks: >-
{% if datadisks is defined %}
{% for i in range(datadisks|count) %}
@ -44,7 +47,9 @@
state: directory
register: tmpdir
delegate_to: localhost
when: inventory_hostname not in result.list_vms
when:
- inventory_hostname not in result.list_vms
- inject is defined
- name: create inject file
copy:
@ -57,7 +62,9 @@
%end
dest: "{{ tmpdir.path }}/include.ks"
delegate_to: localhost
when: inventory_hostname not in result.list_vms
when:
- inventory_hostname not in result.list_vms
- inject is defined
- name: run virt-install
command: >
@ -69,7 +76,9 @@
--vcpus "sockets=1,cores={{ num_cpus }},threads=1,placement=auto" \
--memory {{ mem_size }} --cpu host-passthrough \
--disk {{ os_disk_image }},{{ dsk_opts }},size={{ dsk_size }} \
{% if inject -%}
--initrd-inject {{ tmpdir.path }}/include.ks \
{% endif -%}
{{ virt_install_disks }} \
{{ virt_install_network }} \
{{ virt_install_os_args }}