diff --git a/group_vars/openbsd.yml b/group_vars/openbsd.yml index a4aca09..a538de7 100644 --- a/group_vars/openbsd.yml +++ b/group_vars/openbsd.yml @@ -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 diff --git a/playbooks/include/vm-create.yml b/playbooks/include/vm-create.yml index e143a4e..cd3934b 100644 --- a/playbooks/include/vm-create.yml +++ b/playbooks/include/vm-create.yml @@ -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 }}