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
58
58
59
59
- ` interfaces ` : a list of network interfaces to attach to the VM.
60
60
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 ` .
62
80
63
81
- ` console_log_enabled ` : if ` true ` , log console output to a file at the
64
82
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 10
10
when : console_log_enabled | bool
11
11
become : true
12
12
13
+ - name : Validate VM interfaces
14
+ include_tasks : check-interface.yml
15
+ vars :
16
+ interface : " {{ item }}"
17
+ with_items : " {{ vm.interfaces }}"
18
+
13
19
- name : Ensure the VM is defined
14
20
virt :
15
21
name : " {{ vm.name }}"
Original file line number Diff line number Diff line change 26
26
</disk >
27
27
{% endfor %}
28
28
{% 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 %}
29
33
<interface type =' network' >
30
34
<source network =' {{ interface.network }}' />
35
+ {% endif %}
31
36
<model type =' virtio' />
32
37
</interface >
33
38
{% endfor %}
You can’t perform that action at this time.
0 commit comments