1 # == Class: nova::compute::libvirt
3 # Install and manage nova-compute guests managed
8 # [*libvirt_virt_type*]
9 # (optional) Libvirt domain type. Options are: kvm, lxc, qemu, uml, xen
10 # Replaces libvirt_type
13 # [*vncserver_listen*]
14 # (optional) IP address on which instance vncservers should listen
15 # Defaults to '127.0.0.1'
17 # [*migration_support*]
18 # (optional) Whether to support virtual machine migration
21 # [*libvirt_cpu_mode*]
22 # (optional) The libvirt CPU mode to configure. Possible values
23 # include custom, host-model, none, host-passthrough.
24 # Defaults to 'host-model' if libvirt_virt_type is set to either
25 # kvm or qemu, otherwise defaults to 'none'.
27 # [*libvirt_disk_cachemodes*]
28 # (optional) A list of cachemodes for different disk types, e.g.
29 # ["file=directsync", "block=none"]
30 # If an empty list is specified, the disk_cachemodes directive
31 # will be removed from nova.conf completely.
32 # Defaults to an empty list
34 # [*libvirt_inject_password*]
35 # (optional) Inject the admin password at boot time, without an agent.
38 # [*libvirt_inject_key*]
39 # (optional) Inject the ssh public key at boot time.
42 # [*libvirt_inject_partition*]
43 # (optional) The partition to inject to : -2 => disable, -1 => inspect
44 # (libguestfs only), 0 => not partitioned, >0 => partition
45 # number (integer value)
48 # [*remove_unused_base_images*]
49 # (optional) Should unused base images be removed?
50 # If undef is specified, remove the line in nova.conf
51 # otherwise, use a boolean to remove or not the base images.
54 # [*remove_unused_kernels*]
55 # (optional) Should unused kernel images be removed?
56 # This is only safe to enable if all compute nodes
57 # have been updated to support this option.
58 # If undef is specified, remove the line in nova.conf
59 # otherwise, use a boolean to remove or not the kernels.
62 # [*remove_unused_resized_minimum_age_seconds*]
63 # (optional) Unused resized base images younger
64 # than this will not be removed
65 # If undef is specified, remove the line in nova.conf
66 # otherwise, use a integer or a string to define after
67 # how many seconds it will be removed.
70 # [*remove_unused_original_minimum_age_seconds*]
71 # (optional) Unused unresized base images younger
72 # than this will not be removed
73 # If undef is specified, remove the line in nova.conf
74 # otherwise, use a integer or a string to define after
75 # how many seconds it will be removed.
78 # [*libvirt_service_name*]
79 # (optional) libvirt service name.
80 # Defaults to $::nova::params::libvirt_service_name
82 class nova::compute::libvirt (
83 $libvirt_virt_type = 'kvm',
84 $vncserver_listen = '127.0.0.1',
85 $migration_support = false,
86 $libvirt_cpu_mode = false,
87 $libvirt_disk_cachemodes = [],
88 $libvirt_inject_password = false,
89 $libvirt_inject_key = false,
90 $libvirt_inject_partition = -2,
91 $remove_unused_base_images = undef,
92 $remove_unused_kernels = undef,
93 $remove_unused_resized_minimum_age_seconds = undef,
94 $remove_unused_original_minimum_age_seconds = undef,
95 $libvirt_service_name = $::nova::params::libvirt_service_name,
96 # DEPRECATED PARAMETER
98 ) inherits nova::params {
102 Service['libvirt'] -> Service['nova-compute']
105 warning ('The libvirt_type parameter is deprecated, use libvirt_virt_type instead.')
106 $libvirt_virt_type_real = $libvirt_type
108 $libvirt_virt_type_real = $libvirt_virt_type
111 # libvirt_cpu_mode has different defaults depending on hypervisor.
112 if !$libvirt_cpu_mode {
113 case $libvirt_virt_type_real {
115 $libvirt_cpu_mode_real = 'host-model'
118 $libvirt_cpu_mode_real = 'none'
122 $libvirt_cpu_mode_real = $libvirt_cpu_mode
125 if($::osfamily == 'Debian') {
126 package { "nova-compute-${libvirt_virt_type_real}":
128 before => Package['nova-compute'],
129 require => Package['nova-common'],
130 tag => ['openstack', 'nova'],
134 if($::osfamily == 'RedHat' and $::operatingsystem != 'Fedora') {
135 service { 'messagebus':
138 provider => $::nova::params::special_service_provider,
140 Package['libvirt'] -> Service['messagebus'] -> Service['libvirt']
144 if $migration_support {
145 if $vncserver_listen != '0.0.0.0' and $vncserver_listen != '::0' {
146 fail('For migration support to work, you MUST set vncserver_listen to \'0.0.0.0\' or \'::0\'')
148 class { 'nova::migration::libvirt': }
154 name => $::nova::params::libvirt_package_name,
157 service { 'libvirt' :
160 name => $libvirt_service_name,
161 provider => $::nova::params::special_service_provider,
162 require => Package['libvirt'],
166 'DEFAULT/compute_driver': value => 'libvirt.LibvirtDriver';
167 'DEFAULT/vncserver_listen': value => $vncserver_listen;
168 'libvirt/virt_type': value => $libvirt_virt_type_real;
169 'libvirt/cpu_mode': value => $libvirt_cpu_mode_real;
170 'libvirt/inject_password': value => $libvirt_inject_password;
171 'libvirt/inject_key': value => $libvirt_inject_key;
172 'libvirt/inject_partition': value => $libvirt_inject_partition;
175 if size($libvirt_disk_cachemodes) > 0 {
177 'libvirt/disk_cachemodes': value => join($libvirt_disk_cachemodes, ',');
181 'libvirt/disk_cachemodes': ensure => absent;
185 if $remove_unused_kernels != undef {
187 'libvirt/remove_unused_kernels': value => $remove_unused_kernels;
191 'libvirt/remove_unused_kernels': ensure => absent;
195 if $remove_unused_resized_minimum_age_seconds != undef {
197 'libvirt/remove_unused_resized_minimum_age_seconds': value => $remove_unused_resized_minimum_age_seconds;
201 'libvirt/remove_unused_resized_minimum_age_seconds': ensure => absent;
205 if $remove_unused_base_images != undef {
207 'DEFAULT/remove_unused_base_images': value => $remove_unused_base_images;
211 'DEFAULT/remove_unused_base_images': ensure => absent;
215 if $remove_unused_original_minimum_age_seconds != undef {
217 'DEFAULT/remove_unused_original_minimum_age_seconds': value => $remove_unused_original_minimum_age_seconds;
221 'DEFAULT/remove_unused_original_minimum_age_seconds': ensure => absent;