/[adm]/puppet/modules/libvirtd/manifests/init.pp
ViewVC logotype

Contents of /puppet/modules/libvirtd/manifests/init.pp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1984 - (show annotations) (download)
Wed Aug 24 13:48:19 2011 UTC (12 years, 7 months ago) by misc
File size: 3907 byte(s)
fix syntax error
1 class libvirtd {
2 class base {
3 # make sure to use a recent enough version
4 # dnsmasq-base -> for nat network
5 # netcat-openbsd -> for ssh remote access
6 # iptables -> for dhcp, message error was quite puzzling
7 # python-* => needed for helper script
8 package { ["libvirt-utils","dnsmasq-base","netcat-openbsd","iptables","python-libvirt","python-IPy"]:
9 }
10
11 service { libvirtd:
12 ensure => running,
13 path => "/etc/init.d/libvirtd",
14 }
15
16 #TODO remove once libvirt package is fixed to manage the directory
17 file { "/etc/libvirt/storage":
18 ensure => directory,
19 require => Package['libvirt-utils'],
20 }
21
22 file { "/etc/libvirt/storage/autostart":
23 ensure => directory,
24 }
25
26 file { "/usr/local/bin/storage_add.py":
27 ensure => present,
28 owner => root,
29 group => root,
30 mode => 755,
31 source => "puppet:///modules/libvirtd/storage_add.py",
32 }
33
34 file { "/usr/local/bin/network_add.py":
35 ensure => present,
36 owner => root,
37 group => root,
38 mode => 755,
39 source => "puppet:///modules/libvirtd/network_add.py",
40 }
41
42 }
43
44 class kvm inherits base {
45 # pull cyrus-sasl, should be checked
46 package { "qemu":
47
48 }
49
50 }
51
52 # see http://wiki.libvirt.org/page/SSHPolicyKitSetup
53 define group_access() {
54 # to pull polkit and create the directory
55 include libvirtd::base
56 file { "/etc/polkit-1/localauthority/50-local.d/50-$name-libvirt-remote-access.pkla":
57 owner => root,
58 group => root,
59 mode => 644,
60 ensure => present,
61 content => template("libvirtd/50-template-libvirt-remote-access.pkla"),
62 require => Package['libvirt-utils'],
63 }
64 }
65
66 define storage($path, $autostart = true) {
67 include libvirtd::base
68
69 exec { "/usr/local/bin/storage_add.py $name $path":
70 creates => "/etc/libvirt/storage/$name.xml",
71 require => [File['/usr/local/bin/storage_add.py'],
72 Package["python-libvirt"] ]
73 }
74
75 #TODO use API of libvirt
76 file { "/etc/libvirt/storage/autostart/$name.xml":
77 ensure => $autostart ? {
78 true => "/etc/libvirt/storage/$name.xml",
79 false => "absent"
80 },
81 require => Package['libvirt-utils'],
82 }
83 }
84
85 define network( $bridge_name = 'virbr0',
86 $forward = 'nat',
87 $forward_dev = 'eth0',
88 $network = '192.168.122.0/24',
89 $tftp_root = '',
90 $disable_pxe = '',
91 $autostart = true,
92 $vm_type = 'qemu') {
93
94 exec { "/usr/local/bin/network_add.py":
95 environment => ["BRIDGE_NAME=$bridge_name",
96 "FORWARD=$forward",
97 "FORWARD_DEV=$forward_dev",
98 "NETWORK=$network",
99 "TFTP_ROOT=$tftp_root",
100 "DISABLE_PXE=\"$disable_pxe\""],
101
102 creates => "/etc/libvirt/$vm_type/networks/$name.xml",
103 require => [File['/usr/local/bin/network_add.py'],
104 Package['python-IPy'], Package["python-libvirt"] ]
105 }
106
107 #TODO use API of libvirt
108 file { "/etc/libvirt/$vm_type/networks/autostart/$name.xml":
109 ensure => $autostart ? {
110 true => "/etc/libvirt/$vm_type/networks/$name.xml",
111 false => "absent"
112 }
113 require => Package['libvirt-utils'],
114 }
115 }
116 }

  ViewVC Help
Powered by ViewVC 1.1.30