/[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 1957 - (show annotations) (download)
Wed Aug 17 22:52:34 2011 UTC (12 years, 8 months ago) by misc
File size: 3759 byte(s)
fix ordering
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 }
63 }
64
65 define storage($path, $autostart = true) {
66 include libvirtd::base
67
68 exec { "/usr/local/bin/storage_add.py $name $path":
69 creates => "/etc/libvirt/storage/$name.xml",
70 require => [File['/usr/local/bin/storage_add.py'],
71 Package["python-libvirt"] ]
72 }
73
74 #TODO use API of libvirt
75 file { "/etc/libvirt/storage/autostart/$name.xml":
76 ensure => $autostart ? {
77 true => "/etc/libvirt/storage/$name.xml",
78 false => "absent"
79 }
80 }
81 }
82
83 define network( $bridge_name = 'virbr0',
84 $forward = 'nat',
85 $forward_dev = 'eth0',
86 $network = '192.168.122.0/24',
87 $tftp_root = '',
88 $disable_pxe = '',
89 $autostart = true,
90 $vm_type = 'qemu') {
91
92 exec { "/usr/local/bin/network_add.py":
93 environment => ["BRIDGE_NAME=$bridge_name",
94 "FORWARD=$forward",
95 "FORWARD_DEV=$forward_dev",
96 "NETWORK=$network",
97 "TFTP_ROOT=$tftp_root",
98 "DISABLE_PXE=\"$disable_pxe\""],
99
100 creates => "/etc/libvirt/$vm_type/networks/$name.xml",
101 require => [File['/usr/local/bin/network_add.py'],
102 Package['python-IPy'], Package["python-libvirt"] ]
103 }
104
105 #TODO use API of libvirt
106 file { "/etc/libvirt/$vm_type/networks/autostart/$name.xml":
107 ensure => $autostart ? {
108 true => "/etc/libvirt/$vm_type/networks/$name.xml",
109 false => "absent"
110 }
111 }
112 }
113 }

  ViewVC Help
Powered by ViewVC 1.1.30