From 13dad16194bd35c60bd51ce2aaa6a813e8238574 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Thu, 31 Mar 2011 01:49:37 +0000 Subject: add a define for declaring network ( but a custom type would be better ) --- modules/libvirtd/manifests/init.pp | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'modules/libvirtd') diff --git a/modules/libvirtd/manifests/init.pp b/modules/libvirtd/manifests/init.pp index 948b95d9..0fc8cf90 100644 --- a/modules/libvirtd/manifests/init.pp +++ b/modules/libvirtd/manifests/init.pp @@ -6,7 +6,7 @@ class libvirtd { # netcat-openbsd -> for ssh remote access # iptables -> for dhcp, message error was quite puzzling # python-* => needed for helper script - package { ["libvirt-utils","dnsmasq-base","netcat-openbsd","iptables","python-libvirt"]: + package { ["libvirt-utils","dnsmasq-base","netcat-openbsd","iptables","python-libvirt","python-IPy"]: } service { libvirtd: @@ -79,4 +79,35 @@ class libvirtd { } } } + + define network( $bridge_name = 'virbr0', + $forward = 'nat', + $forward_dev = 'eth0', + $network = '192.168.122.0/24', + $tftp_root = '', + $disable_pxe = '', + $autostart = true, + $vm_type = 'qemu') { + + exec { "/usr/local/bin/network_add.py": + environment => ["BRIDGE_NAME=$bridge_name", + "FORWARD=$forward", + "FORWARD_DEV=$forward_dev", + "NETWORK=$network", + "TFTP_ROOT=$tftp_root", + "DISABLE_PXE=\"$disable_pxe\""], + + creates => "/etc/libvirt/$vm_type/networks/$name.xml", + require => [File['/usr/local/bin/network_add.py'], + Package['python-IPy'], Package["python-libvirt"] ] + } + + #TODO use API of libvirt + file { "/etc/libvirt/$vm_type/networks/autostart/$name.xml": + ensure => $autostart ? { + true => "/etc/libvirt/$vm_type/networks/$name.xml", + false => "absent" + } + } + } } -- cgit v1.2.1