add support for defining multiple interfaces for virtual machines

This commit is contained in:
Timo Makinen 2019-05-17 14:28:38 +03:00
parent c42976919f
commit 4004a9ef68
3 changed files with 8 additions and 3 deletions

View file

@ -1,3 +1,3 @@
--- ---
mac_address: 52:54:00:ac:dc:18 interfaces: [[20, "52:54:00:ac:dc:18"]]
vmhost: vmhost02.home.foo.sh vmhost: vmhost02.home.foo.sh

View file

@ -1,3 +1,3 @@
--- ---
mac_address: 52:54:00:ac:dc:15 interfaces: [[20, "52:54:00:ac:dc:15"]]
vmhost: vmhost01.home.foo.sh vmhost: vmhost01.home.foo.sh

View file

@ -16,6 +16,11 @@
--disk /srv/libvirt/data/{{ inventory_hostname }}.{{ letters[num] }}.img,cache=none,format=raw,size={{ datadisk_size[num] }} --disk /srv/libvirt/data/{{ inventory_hostname }}.{{ letters[num] }}.img,cache=none,format=raw,size={{ datadisk_size[num] }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
virt_install_network: >-
{% for vlan, mac in interfaces %}
--network bridge=br{{ vlan }},mac={{ mac }},model=virtio
{% endfor %}
tasks: tasks:
- name: get vm list - name: get vm list
@ -61,7 +66,7 @@
--vcpus {{ num_cpus }} --cpu host-passthrough \ --vcpus {{ num_cpus }} --cpu host-passthrough \
--disk /srv/libvirt/os/{{ inventory_hostname }}.a.img,cache=none,format=raw,size={{ dsk_size }} \ --disk /srv/libvirt/os/{{ inventory_hostname }}.a.img,cache=none,format=raw,size={{ dsk_size }} \
{{ extra_disks }} --initrd-inject {{ tmpdir.path }}/include.ks \ {{ extra_disks }} --initrd-inject {{ tmpdir.path }}/include.ks \
--network bridge=br20,mac={{ mac_address }},model=virtio \ {{ virt_install_network }} \
{{ virt_install_os_args }} {{ virt_install_os_args }}
delegate_to: localhost delegate_to: localhost
when: inventory_hostname not in result.list_vms when: inventory_hostname not in result.list_vms