aboutsummaryrefslogtreecommitdiffstats
path: root/modules/libvirtd
diff options
context:
space:
mode:
authorMichael Scherer <misc@mageia.org>2011-03-31 01:49:37 +0000
committerMichael Scherer <misc@mageia.org>2011-03-31 01:49:37 +0000
commit13dad16194bd35c60bd51ce2aaa6a813e8238574 (patch)
tree2220186b0597bb1168dbbf39a5290cf60e0ac08d /modules/libvirtd
parent11e38deef6b8d95183eec29385153984b345626d (diff)
downloadpuppet-13dad16194bd35c60bd51ce2aaa6a813e8238574.tar
puppet-13dad16194bd35c60bd51ce2aaa6a813e8238574.tar.gz
puppet-13dad16194bd35c60bd51ce2aaa6a813e8238574.tar.bz2
puppet-13dad16194bd35c60bd51ce2aaa6a813e8238574.tar.xz
puppet-13dad16194bd35c60bd51ce2aaa6a813e8238574.zip
add a define for declaring network ( but a custom type would be better )
Diffstat (limited to 'modules/libvirtd')
-rw-r--r--modules/libvirtd/manifests/init.pp33
1 files changed, 32 insertions, 1 deletions
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"
+ }
+ }
+ }
}