v0.0.20
This commit is contained in:
21
templates/interfaces.j2
Normal file
21
templates/interfaces.j2
Normal file
@@ -0,0 +1,21 @@
|
||||
# This file describes the network interfaces available on your system
|
||||
# and how to activate them. For more information, see interfaces(5).
|
||||
|
||||
source /etc/network/interfaces.d/*
|
||||
|
||||
# The loopback network interface
|
||||
auto lo
|
||||
iface lo inet loopback
|
||||
|
||||
# Libvirt networks
|
||||
{% for network in libvirt_networks %}
|
||||
{% if network.bridge.dev is defined %}
|
||||
auto {{ network.bridge.dev }}
|
||||
iface {{ network.bridge.dev }} inet manual
|
||||
|
||||
auto {{ network.bridge.name }}
|
||||
iface {{ network.bridge.name }} inet dhcp
|
||||
bridge_ports {{ network.bridge.dev }}
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
14
templates/libvirt-network.xml.j2
Normal file
14
templates/libvirt-network.xml.j2
Normal file
@@ -0,0 +1,14 @@
|
||||
<network>
|
||||
<name>{{ item.name }}</name>
|
||||
<forward mode='{{ item.forward.mode }}'/>
|
||||
{% if item.bridge.dev is defined %}
|
||||
<bridge name='{{ item.bridge.name }}' dev='{{ item.bridge.dev }}'/>
|
||||
{% else %}
|
||||
<bridge name='{{ item.bridge.name }}'/>
|
||||
<ip address='{{ item.ip.address }}' netmask='{{ item.ip.netmask }}'>
|
||||
<dhcp>
|
||||
<range start='{{ item.ip.dhcp.range.start }}' end='{{ item.ip.dhcp.range.end }}'/>
|
||||
</dhcp>
|
||||
</ip>
|
||||
{% endif %}
|
||||
</network>
|
||||
108
templates/libvirt-vm.xml.j2
Normal file
108
templates/libvirt-vm.xml.j2
Normal file
@@ -0,0 +1,108 @@
|
||||
<domain type='{{ domain.type }}'>
|
||||
<name>{{ domain.name }}</name>
|
||||
<memory unit='{{ domain.memory.unit }}'>{{ domain.memory.value }}</memory>
|
||||
<vcpu placement='{{ domain.vcpu.placement }}'>{{ domain.vcpu.value }}</vcpu>
|
||||
<os>
|
||||
<type arch='{{ domain.os.type.arch }}' machine='{{ domain.os.type.machine }}'>{{ domain.os.type.value }}</type>
|
||||
<boot dev='{{ domain.os.boot.dev }}'/>
|
||||
</os>
|
||||
<cpu mode='{{ domain.cpu.mode }}' check='{{ domain.cpu.check }}'/>
|
||||
<devices>
|
||||
<emulator>{{ domain.devices.emulator }}</emulator>
|
||||
{% if domain.devices.disks is defined %}
|
||||
{% for disk in domain.devices.disks %}
|
||||
<disk type='{{ disk.type }}' device='{{ disk.device }}'>
|
||||
<driver name='{{ disk.driver.name }}' type='{{ disk.driver.type }}'/>
|
||||
{% if disk.source.protocol is defined %}
|
||||
<source protocol='{{ disk.source.protocol }}' name='{{ disk.source.name }}'>
|
||||
<host name='{{ disk.source.host.name }}' port='{{ disk.source.host.port }}'/>
|
||||
</source>
|
||||
{% elif disk.source.dev is defined %}
|
||||
<source dev='{{ disk.source.dev }}'/>
|
||||
{% else %}
|
||||
<source file='{{ disk.source.file }}'/>
|
||||
{% endif %}
|
||||
<target dev='{{ disk.target.dev }}' bus='{{ disk.target.bus }}'/>
|
||||
{% if disk.address is defined %}
|
||||
<address type='{{ disk.address.type }}' domain='{{ disk.address.domain }}' bus='{{ disk.address.bus }}' slot='{{ disk.address.slot }}' function='{{ disk.address.function }}'/>
|
||||
{% endif %}
|
||||
</disk>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if domain.filesystems is defined %}
|
||||
{% for filesystem in domain.filesystems %}
|
||||
<filesystem type='{{ filesystem.type }}' accessmode='{{ filesystem.accessmode }}'>
|
||||
<source dir='{{ filesystem.source.dir }}'/>
|
||||
<target dir='{{ filesystem.target.dir }}'/>
|
||||
</filesystem>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if domain.devices.interfaces is defined %}
|
||||
{% for interface in domain.devices.interfaces %}
|
||||
<interface type='{{ interface.type }}'>
|
||||
<source network='{{ interface.source.network }}'/>
|
||||
<model type='{{ interface.model.type }}'/>
|
||||
{% if interface.address is defined %}
|
||||
<address type='{{ interface.address.type }}' domain='{{ interface.address.domain }}' bus='{{ interface.address.bus }}' slot='{{ interface.address.slot }}' function='{{ interface.address.function }}'/>
|
||||
{% endif %}
|
||||
</interface>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if domain.devices.channels is defined %}
|
||||
{% for channel in domain.devices.channels %}
|
||||
<channel type='{{ channel.type }}'>
|
||||
<target type='{{ channel.target.type }}' name='{{ channel.target.name }}'/>
|
||||
{% if channel.address is defined %}
|
||||
<address type='{{ channel.address.type }}' controller='{{ channel.address.controller }}' bus='{{ channel.address.bus }}' port='{{ channel.address.port }}'/>
|
||||
{% endif %}
|
||||
</channel>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if domain.devices.inputs is defined %}
|
||||
{% for input in domain.devices.inputs %}
|
||||
<input type='{{ input.type }}' bus='{{ input.bus }}'>
|
||||
{% if input.address is defined %}
|
||||
<address type='{{ input.address.type }}' bus='{{ input.address.bus }}' port='{{ input.address.port }}'/>
|
||||
{% endif %}
|
||||
</input>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if domain.devices.graphics is defined %}
|
||||
<graphics type='{{ domain.devices.graphics.type }}' autoport='{{ domain.devices.graphics.autoport }}'>
|
||||
<listen type='{{ domain.devices.graphics.listen.type }}'/>
|
||||
<image compression='{{ domain.devices.graphics.image.compression }}'/>
|
||||
</graphics>
|
||||
{% endif %}
|
||||
{% if domain.devices.video is defined %}
|
||||
<video>
|
||||
<model type='{{ domain.devices.video.model.type }}' ram='{{ domain.devices.video.model.ram }}' vram='{{ domain.devices.video.model.vram }}' vgamem='{{ domain.devices.video.model.vgamem }}' heads='{{ domain.devices.video.model.heads }}' primary='{{ domain.devices.video.model.primary }}'/>
|
||||
{% if domain.devices.video.address is defined %}
|
||||
<address type='{{ domain.devices.video.address.type }}' domain='{{ domain.devices.video.address.domain }}' bus='{{ domain.devices.video.address.bus }}' slot='{{ domain.devices.video.address.slot }}' function='{{ domain.devices.video.address.function }}'/>
|
||||
{% endif %}
|
||||
</video>
|
||||
{% endif %}
|
||||
{% if domain.devices.memballoon is defined %}
|
||||
<memballoon model='{{ domain.devices.memballoon.model }}'>
|
||||
{% if domain.devices.memballoon.address is defined %}
|
||||
<address type='{{ domain.devices.memballoon.address.type }}' domain='{{ domain.devices.memballoon.address.domain }}' bus='{{ domain.devices.memballoon.address.bus }}' slot='{{ domain.devices.memballoon.address.slot }}' function='{{ domain.devices.memballoon.address.function }}'/>
|
||||
{% endif %}
|
||||
</memballoon>
|
||||
{% endif %}
|
||||
{% if domain.devices.rng is defined %}
|
||||
<rng model='virtio'>
|
||||
<backend model='random'>/dev/urandom</backend>
|
||||
{% if domain.devices.rng.address is defined %}
|
||||
<address type='{{ domain.devices.rng.address.type }}' domain='{{ domain.devices.rng.address.domain }}' bus='{{ domain.devices.rng.address.bus }}' slot='{{ domain.devices.rng.address.slot }}' function='{{ domain.devices.rng.address.function }}'/>
|
||||
{% endif %}
|
||||
</rng>
|
||||
{% endif %}
|
||||
<serial type='pty'>
|
||||
<target type='isa-serial' port='0'>
|
||||
<model name='isa-serial'/>
|
||||
</target>
|
||||
</serial>
|
||||
<console type='pty'>
|
||||
<target type='serial' port='0'/>
|
||||
</console>
|
||||
</devices>
|
||||
</domain>
|
||||
2
templates/meta-data.j2
Normal file
2
templates/meta-data.j2
Normal file
@@ -0,0 +1,2 @@
|
||||
instance-id: {{ domain.instance_id }}
|
||||
local-hostname: {{ domain.name }}
|
||||
54
templates/qemu-vm.xml.j2
Normal file
54
templates/qemu-vm.xml.j2
Normal file
@@ -0,0 +1,54 @@
|
||||
<domain type='{{ item.domain.type }}'>
|
||||
<name>{{ item.domain.name }}</name>
|
||||
<memory unit='{{ item.domain.memory.unit }}'>{{ item.domain.memory.value }}</memory>
|
||||
<vcpu placement='{{ item.domain.vcpu.placement }}'>{{ item.domain.bcpu.value }}</vcpu>
|
||||
<os>
|
||||
<type arch='{{ item.domain.os.type.arch }}' machine='{{ item.domain.os.type.machine }}'>{{ item.domain.os.type.value }}</type>
|
||||
<boot dev='{{ item.domain.os.boot.dev }}'/>
|
||||
</os>
|
||||
<cpu mode='{{ item.domain.cpu.mode }}' check='{{ item.domain.cpu.check }}'/>
|
||||
<devices>
|
||||
<emulator>{{ item.domain.devices.emulator }}</emulator>
|
||||
{% for disk in item.domain.devices.disks %}
|
||||
<disk type='{{ disk.type }}' device='{{ disk.device }}'>
|
||||
<driver name='{{ disk.driver.name }}' type='{{ disk.driver.type }}'/>
|
||||
<source file='{{ disk.source.file }}'/>
|
||||
<target dev='{{ disk.target.dev }}' bus='{{ disk.target.bus }}'/>
|
||||
<address type='{{ disk.target.address.type }}' domain='{{ disk.target.address.domain }}' bus='{{ disk.target.address.bus }}' slot='{{ disk.target.address.slot }}' function='{{ disk.target.address.function }}'/>
|
||||
</disk>
|
||||
{% endfor %}
|
||||
{% for interface in item.domain.devices.interfaces %}
|
||||
<interface type='{{ interface.type }}'>
|
||||
<source network='{{ interface.source.network }}'/>
|
||||
<model type='{{ interface.model.type }}'/>
|
||||
<address type='{{ interface.target.address.type }}' domain='{{ interface.target.address.domain }}' bus='{{ interface.target.address.bus }}' slot='{{ interface.target.address.slot }}' function='{{ interface.target.address.function }}'/>
|
||||
</interface>
|
||||
{% endfor %}
|
||||
{% for channel in item.domain.devices.channels %}
|
||||
<channel type='channel.type'>
|
||||
<target type='{{ channel.target.type }}' name='{{ channel.target.name }}'/>
|
||||
<address type='{{ channel.address.type }}' controller='{{ channel.address.controller }}' bus='{{ channel.address.bus }}' port='{{ channel.address.port }}'/>
|
||||
</channel>
|
||||
{% end for %}
|
||||
{% for input in item.domain.devices.inputs %}
|
||||
<input type='{{ input.type }}' bus='{{ input.bus }}'>
|
||||
<address type='{{ input.address.type }}' bus='{{ input.address.bus }}' port='{{ input.address.port }}'/>
|
||||
</input>
|
||||
{% end for %}
|
||||
<graphics type='{{ item.domain.devices.graphics.type }}' autoport='{{ item.domain.devices.graphics.autoport }}'>
|
||||
<listen type='{{ item.domain.devices.graphics.listen.type }}'/>
|
||||
<image compression='{{ item.domain.devices.graphics.image.compression }}'/>
|
||||
</graphics>
|
||||
<video>
|
||||
<model type='{{ item.domain.devices.video.model.type }}' ram='{{ item.domain.devices.video.model.ram }}' vram='{{ item.domain.devices.video.model.vram }}' vgamem='{{ devices.video.model.vgamem }}' heads='{{ devices.video.model.heads }}' primary='{{ devices.video.model.primary }}'/>
|
||||
<address type='{{ item.domain.devices.video.address.type }}' domain='{{ item.domain.devices.video.address.domain }}' bus='{{ item.domain.devices.video.address.bus }}' slot='{{ item.domain.devices.video.address.slot }}' function='{{ item.domain.devices.video.address.function }}'/>
|
||||
</video>
|
||||
<memballoon model='{{ item.domain.devices.memballoon.model }}'>
|
||||
<address type='{{ item.domain.devices.memballoon.address.type }}' domain='{{ item.domain.devices.memballoon.address.domain }}' bus='{{ item.domain.devices.memballoon.address.bus }}' slot='{{ item.domain.devices.memballoon.address.slot }}' function='{{ item.domain.devices.memballoon.address.function }}'/>
|
||||
</memballoon>
|
||||
<rng model='virtio'>
|
||||
<backend model='random'>/dev/urandom</backend>
|
||||
<address type='{{ item.domain.devices.rng.address.type }}' domain='{{ item.domain.devices.rng.address.domain }}' bus='{{ item.domain.devices.rng.address.bus }}' slot='{{ item.domain.devices.rng.address.slot }}' function='{{ item.domain.devices.rng.address.function }}'/>
|
||||
</rng>
|
||||
</devices>
|
||||
</domain>
|
||||
@@ -1,52 +0,0 @@
|
||||
<domain type='kvm'>
|
||||
<name>{{ vm_name }}</name>
|
||||
<memory unit='MiB'>{{ vm_ram_mb }}</memory>
|
||||
<vcpu placement='static'>{{ vm_vcpus }}</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine='pc-q35-5.2'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<cpu mode='host-model' check='none'/>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu' type='qcow2'/>
|
||||
<source file='{{ libvirt_pool_dir }}/{{ vm_name }}.qcow2'/>
|
||||
<target dev='vda' bus='virtio'/>
|
||||
<address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
|
||||
</disk>
|
||||
<interface type='network'>
|
||||
<source network='{{ vm_net }}'/>
|
||||
<model type='virtio'/>
|
||||
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
|
||||
</interface>
|
||||
<channel type='unix'>
|
||||
<target type='virtio' name='org.qemu.guest_agent.0'/>
|
||||
<address type='virtio-serial' controller='0' bus='0' port='1'/>
|
||||
</channel>
|
||||
<channel type='spicevmc'>
|
||||
<target type='virtio' name='com.redhat.spice.0'/>
|
||||
<address type='virtio-serial' controller='0' bus='0' port='2'/>
|
||||
</channel>
|
||||
<input type='tablet' bus='usb'>
|
||||
<address type='usb' bus='0' port='1'/>
|
||||
</input>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<input type='keyboard' bus='ps2'/>
|
||||
<graphics type='spice' autoport='yes'>
|
||||
<listen type='address'/>
|
||||
<image compression='off'/>
|
||||
</graphics>
|
||||
<video>
|
||||
<model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
|
||||
</video>
|
||||
<memballoon model='virtio'>
|
||||
<address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
|
||||
</memballoon>
|
||||
<rng model='virtio'>
|
||||
<backend model='random'>/dev/urandom</backend>
|
||||
<address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
|
||||
</rng>
|
||||
</devices>
|
||||
</domain>
|
||||
41
templates/user-data.j2
Normal file
41
templates/user-data.j2
Normal file
@@ -0,0 +1,41 @@
|
||||
#cloud-config
|
||||
hostname: {{ domain.name }}
|
||||
create_hostname_file: true
|
||||
fqdn: {{ domain.name }}.eom.dev
|
||||
|
||||
apt:
|
||||
generate_mirrorlists: true
|
||||
|
||||
package_reboot_if_required: true
|
||||
package_update: true
|
||||
package_upgrade: true
|
||||
packages: {{ domain.packages }}
|
||||
|
||||
users:
|
||||
- name: eric
|
||||
lock_passwd: True
|
||||
gecos: Eric O'Neill Meehan
|
||||
groups: [adm, audio, cdrom, dialout, dip, floppy, netdev, plugdev, sudo, video]
|
||||
sudo: ALL=(ALL) NOPASSWD:ALL
|
||||
shell: /bin/bash
|
||||
ssh_authorized_keys: {{ eric_ssh_keys }}
|
||||
|
||||
chpasswd:
|
||||
expire: false
|
||||
users:
|
||||
- name: eric
|
||||
type: text
|
||||
password: 123abc
|
||||
|
||||
ssh_pwauth: false
|
||||
|
||||
growpart:
|
||||
mode: auto
|
||||
devices: ['/']
|
||||
resize_rootfs:
|
||||
type: 'growpart'
|
||||
resizefs: true
|
||||
|
||||
{% if mounts is defined %}
|
||||
mounts: {{ mounts }}
|
||||
{% endif %}
|
||||
@@ -1,52 +0,0 @@
|
||||
<domain type='kvm'>
|
||||
<name>{{ vm_name }}</name>
|
||||
<memory unit='MiB'>{{ vm_ram_mb }}</memory>
|
||||
<vcpu placement='static'>{{ vm_vcpus }}</vcpu>
|
||||
<os>
|
||||
<type arch='x86_64' machine='pc-q35-5.2'>hvm</type>
|
||||
<boot dev='hd'/>
|
||||
</os>
|
||||
<cpu mode='host-model' check='none'/>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||
<disk type='file' device='disk'>
|
||||
<driver name='qemu' type='qcow2'/>
|
||||
<source file='{{ libvirt_pool_dir }}/{{ vm_name }}.qcow2'/>
|
||||
<target dev='vda' bus='virtio'/>
|
||||
<address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
|
||||
</disk>
|
||||
<interface type='network'>
|
||||
<source network='{{ vm_net }}'/>
|
||||
<model type='virtio'/>
|
||||
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
|
||||
</interface>
|
||||
<channel type='unix'>
|
||||
<target type='virtio' name='org.qemu.guest_agent.0'/>
|
||||
<address type='virtio-serial' controller='0' bus='0' port='1'/>
|
||||
</channel>
|
||||
<channel type='spicevmc'>
|
||||
<target type='virtio' name='com.redhat.spice.0'/>
|
||||
<address type='virtio-serial' controller='0' bus='0' port='2'/>
|
||||
</channel>
|
||||
<input type='tablet' bus='usb'>
|
||||
<address type='usb' bus='0' port='1'/>
|
||||
</input>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<input type='keyboard' bus='ps2'/>
|
||||
<graphics type='spice' autoport='yes'>
|
||||
<listen type='address'/>
|
||||
<image compression='off'/>
|
||||
</graphics>
|
||||
<video>
|
||||
<model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
|
||||
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
|
||||
</video>
|
||||
<memballoon model='virtio'>
|
||||
<address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
|
||||
</memballoon>
|
||||
<rng model='virtio'>
|
||||
<backend model='random'>/dev/urandom</backend>
|
||||
<address type='pci' domain='0x0000' bus='0x07' slot='0x00' function='0x0'/>
|
||||
</rng>
|
||||
</devices>
|
||||
</domain>
|
||||
Reference in New Issue
Block a user