File tree Expand file tree Collapse file tree 4 files changed +51
-1
lines changed Expand file tree Collapse file tree 4 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,25 @@ Role Variables
5858
5959 - ` interfaces ` : a list of network interfaces to attach to the VM.
6060 Each network interface is defined with the following dict:
61- - ` network ` : Name of the network to which an interface should be attached.
61+
62+ - ` type ` : The type of the interface. Possible values:
63+
64+ - `network`: Attaches the interface to a named Libvirt virtual
65+ network. This is the default value.
66+ - `direct`: Directly attaches the interface to one of the host's
67+ physical interfaces, using the `macvtap` driver.
68+ - ` network ` : Name of the network to which an interface should be
69+ attached. Must be specified if and only if the interface ` type ` is
70+ ` network ` .
71+ - ` source ` : A dict defining the host interface to which this
72+ VM interface should be attached. Must be specified if and only if the
73+ interface ` type ` is ` direct ` . Includes the following attributes:
74+
75+ - ` dev ` : The name of the host interface to which this VM interface
76+ should be attached.
77+ - ` mode ` : options include ` vepa ` , ` bridge ` , ` private ` and
78+ ` passthrough ` . See ` man virsh ` for more details. Default is
79+ ` vepa ` .
6280
6381 - ` console_log_enabled ` : if ` true ` , log console output to a file at the
6482 path specified by ` console_log_path ` , ** instead of** to a PTY. If
Original file line number Diff line number Diff line change 1+ ---
2+ - name : Check network interface has a network name
3+ fail :
4+ msg : >
5+ The interface definition {{ interface }} has type 'network', but does not have
6+ a network name defined.
7+ when :
8+ - interface.type is not defined or
9+ interface.type == 'network'
10+ - interface.network is not defined
11+
12+ - name : Check direct interface has an interface device name
13+ fail :
14+ msg : >
15+ The interface definition {{ interface }} has type 'direct', but does not have
16+ a host source device defined.
17+ when :
18+ - interface.type is defined
19+ - interface.type == 'direct'
20+ - interface.source is not defined or
21+ interface.source.dev is not defined
Original file line number Diff line number Diff line change 1010 when : console_log_enabled | bool
1111 become : true
1212
13+ - name : Validate VM interfaces
14+ include_tasks : check-interface.yml
15+ vars :
16+ interface : " {{ item }}"
17+ with_items : " {{ vm.interfaces }}"
18+
1319- name : Ensure the VM is defined
1420 virt :
1521 name : " {{ vm.name }}"
Original file line number Diff line number Diff line change 2626 </disk >
2727{% endfor %}
2828{% for interface in interfaces %}
29+ {% if interface .type is defined and interface .type == 'direct' %}
30+ <interface type =' direct' >
31+ <source dev =' {{ interface.source.dev }}' mode =' {{ interface.source.mode | default(' vepa ' ) }}' />
32+ {% else %}
2933 <interface type =' network' >
3034 <source network =' {{ interface.network }}' />
35+ {% endif %}
3136 <model type =' virtio' />
3237 </interface >
3338{% endfor %}
You can’t perform that action at this time.
0 commit comments