torwachter: rm d3 key as he does no longer want access as told by ruru. Also better...
[noc.git] / ansible / roles / vm / define / templates / libvirt-domain.xml.j2
1 <domain type='kvm'>
2   <name>{{ hostname }}</name>
3   <memory>{{ hostvars[hostname].install_cooked.mem * 1024 }}</memory>
4   <currentMemory>{{ hostvars[hostname].install_cooked.mem * 1024 }}</currentMemory>
5   <vcpu>{{ hostvars[hostname].install_cooked.numcpu }}</vcpu>
6   <os>
7     <type arch='x86_64' machine='pc-0.12'>hvm</type>
8 {% if vm_define_installer %}
9     <kernel>{{ debian_installer_path }}/{{ install_distro }}-{{ install_codename }}/{{ hostvars[hostname].install_cooked.arch | default('amd64') }}/linux</kernel>
10     <initrd>{{ preseed_tmpdir }}/initrd.preseed.gz</initrd>
11     <cmdline>console=ttyS0,115200n8</cmdline>
12 {% endif %}
13     <boot dev='hd'/>
14   </os>
15   <features>
16     <acpi/>
17     <apic/>
18     <pae/>
19   </features>
20   <clock offset='utc'/>
21   <on_poweroff>destroy</on_poweroff>
22 {% if vm_define_installer %}
23   <on_reboot>destroy</on_reboot>
24   <on_crash>destroy</on_crash>
25 {% else %}
26   <on_reboot>restart</on_reboot>
27   <on_crash>restart</on_crash>
28 {% endif %}
29   <devices>
30     <emulator>/usr/bin/kvm</emulator>
31     <!-- Provide a virtualized RNG to the guest -->
32     <rng model='virtio'>
33       <!-- Allow consuming up to 10kb/s, measured over 2s -->
34       <rate period="2000" bytes="20480"/>
35       <backend model='random'>/dev/urandom</backend>
36     </rng>
37
38 {% if 'virtio' in hostvars[hostname].install_cooked.disks %}
39 {%   for device, lv in hostvars[hostname].install_cooked.disks.virtio.items() %}
40     <disk type='block' device='disk'>
41       <driver name='qemu' type='raw' cache='none' discard='unmap'/>
42       <source dev='/dev/mapper/{{ lv.vg | replace('-', '--') }}-{{ lv.lv | replace('-', '--') }}'/>
43       <target dev='{{ device }}' bus='virtio'/>
44     </disk>
45 {%   endfor %}
46 {% endif %}
47
48 {% if 'scsi' in hostvars[hostname].install_cooked.disks %}
49     <controller type='scsi' index='0' model='virtio-scsi'/>
50 {%   for device, lv in hostvars[hostname].install_cooked.disks.scsi.items() %}
51     <disk type='block' device='disk'>
52       <driver name='qemu' type='raw' cache='none' discard='unmap'/>
53       <source dev='/dev/mapper/{{ lv.vg | replace('-', '--') }}-{{ lv.lv | replace('-', '--') }}'/>
54       <target dev='{{ device }}' bus='scsi'/>
55     </disk>
56 {%   endfor %}
57 {% endif %}
58
59 {% if hostvars[hostname].install_cooked.interfaces %}
60 {%   for if in hostvars[hostname].install_cooked.interfaces %}
61     <interface type='bridge'>
62       <source bridge='{{ if.bridge }}'/>
63       <model type='virtio'/>
64       <address type='pci' domain='0x0000' bus='0x01' slot='0x0{{ loop.index }}' function='0x0'/>
65     </interface>
66 {%   endfor %}
67 {% endif %}
68
69     <serial type='pty'>
70       <target port='0'/>
71     </serial>
72     <console type='pty'>
73       <target type='serial' port='0'/>
74     </console>
75   </devices>
76 </domain>