4afe43ec7857ed25f8739c1e8ba11e8bef4b83bd
[mirror/dsa-puppet.git] / 3rdparty / modules / nova / manifests / compute.pp
1 # == Class: nova::compute
2 #
3 # Installs the nova-compute service
4 #
5 # === Parameters:
6 #
7 # [*enabled*]
8 #   (optional) Whether to enable the nova-compute service
9 #   Defaults to false
10 #
11 # [*manage_service*]
12 #   (optional) Whether to start/stop the service
13 #   Defaults to true
14 #
15 # [*ensure_package*]
16 #   (optional) The state for the nova-compute package
17 #   Defaults to 'present'
18 #
19 # [*vnc_enabled*]
20 #   (optional) Whether to use a VNC proxy
21 #   Defaults to true
22 #
23 # [*vncserver_proxyclient_address*]
24 #   (optional) The IP address of the server running the VNC proxy client
25 #   Defaults to '127.0.0.1'
26 #
27 # [*vncproxy_host*]
28 #   (optional) The host of the VNC proxy server
29 #   Defaults to false
30 #
31 # [*vncproxy_protocol*]
32 #   (optional) The protocol to communicate with the VNC proxy server
33 #   Defaults to 'http'
34 #
35 # [*vncproxy_port*]
36 #   (optional) The port to communicate with the VNC proxy server
37 #   Defaults to '6080'
38 #
39 # [*vncproxy_path*]
40 #   (optional) The path at the end of the uri for communication with the VNC proxy server
41 #   Defaults to '/vnc_auto.html'
42 #
43 # [*vnc_keymap*]
44 #   (optional) The keymap to use with VNC (ls -alh /usr/share/qemu/keymaps to list available keymaps)
45 #   Defaults to 'en-us'
46 #
47 # [*force_config_drive*]
48 #   (optional) Whether to force the config drive to be attached to all VMs
49 #   Defaults to false
50 #
51 # [*virtio_nic*]
52 #   (optional) Whether to use virtio for the nic driver of VMs
53 #   Defaults to false
54 #
55 # [*neutron_enabled*]
56 #   (optional) Whether to use Neutron for networking of VMs
57 #   Defaults to true
58 #
59 # [*network_device_mtu*]
60 #   (optional) The MTU size for the interfaces managed by nova
61 #   Defaults to undef
62 #
63 # [*instance_usage_audit*]
64 #   (optional) Generate periodic compute.instance.exists notifications.
65 #   Defaults to false
66 #
67 # [*instance_usage_audit_period*]
68 #   (optional) Time period to generate instance usages for.
69 #   Time period must be hour, day, month or year
70 #   Defaults to 'month'
71 #
72 #  [*force_raw_images*]
73 #   (optional) Force backing images to raw format.
74 #   Defaults to true
75 #
76 #  [*reserved_host_memory*]
77 #   Reserved host memory
78 #   The amount of memory in MB reserved for the host.
79 #   Defaults to '512'
80 #
81 #  [*compute_manager*]
82 #   Compute manager
83 #   The driver that will manage the running instances.
84 #   Defaults to nova.compute.manager.ComputeManager
85 #
86 #  [*pci_passthrough_whitelist*]
87 #   (optional) Pci passthrough hash in format of:
88 #   Defaults to undef
89 #   Example
90 #  "[ { 'vendor_id':'1234','product_id':'5678' },
91 #     { 'vendor_id':'4321','product_id':'8765','physical_network':'default' } ] "
92 #
93 #  [*default_availability_zone*]
94 #   (optional) Default compute node availability zone.
95 #   Defaults to nova
96 #
97 #  [*default_schedule_zone*]
98 #   (optional) Availability zone to use when user doesn't specify one.
99 #   Defaults to undef
100 #
101 #  [*internal_service_availability_zone*]
102 #   (optional) The availability zone to show internal services under.
103 #   Defaults to internal
104 #
105 class nova::compute (
106   $enabled                            = false,
107   $manage_service                     = true,
108   $ensure_package                     = 'present',
109   $vnc_enabled                        = true,
110   $vncserver_proxyclient_address      = '127.0.0.1',
111   $vncproxy_host                      = false,
112   $vncproxy_protocol                  = 'http',
113   $vncproxy_port                      = '6080',
114   $vncproxy_path                      = '/vnc_auto.html',
115   $vnc_keymap                         = 'en-us',
116   $force_config_drive                 = false,
117   $virtio_nic                         = false,
118   $neutron_enabled                    = true,
119   $network_device_mtu                 = undef,
120   $instance_usage_audit               = false,
121   $instance_usage_audit_period        = 'month',
122   $force_raw_images                   = true,
123   $reserved_host_memory               = '512',
124   $compute_manager                    = 'nova.compute.manager.ComputeManager',
125   $pci_passthrough                    = undef,
126   $default_availability_zone          = 'nova',
127   $default_schedule_zone              = undef,
128   $internal_service_availability_zone = 'internal',
129 ) {
130
131   include nova::params
132
133   nova_config {
134     'DEFAULT/reserved_host_memory_mb':  value => $reserved_host_memory;
135     'DEFAULT/compute_manager':          value => $compute_manager;
136   }
137
138   if ($vnc_enabled) {
139     include ::nova::vncproxy::common
140   }
141
142   nova_config {
143     'DEFAULT/vnc_enabled':                   value => $vnc_enabled;
144     'DEFAULT/vncserver_proxyclient_address': value => $vncserver_proxyclient_address;
145     'DEFAULT/vnc_keymap':                    value => $vnc_keymap;
146   }
147
148   if $neutron_enabled != true {
149     # Install bridge-utils if we use nova-network
150     package { 'bridge-utils':
151       ensure => present,
152       before => Nova::Generic_service['compute'],
153     }
154   }
155
156   nova::generic_service { 'compute':
157     enabled        => $enabled,
158     manage_service => $manage_service,
159     package_name   => $::nova::params::compute_package_name,
160     service_name   => $::nova::params::compute_service_name,
161     ensure_package => $ensure_package,
162     before         => Exec['networking-refresh']
163   }
164
165   if $force_config_drive {
166     nova_config { 'DEFAULT/force_config_drive': value => true }
167   } else {
168     nova_config { 'DEFAULT/force_config_drive': ensure => absent }
169   }
170
171   if $virtio_nic {
172     # Enable the virtio network card for instances
173     nova_config { 'DEFAULT/libvirt_use_virtio_for_bridges': value => true }
174   }
175
176   if $network_device_mtu {
177     nova_config {
178       'DEFAULT/network_device_mtu':   value => $network_device_mtu;
179     }
180   } else {
181     nova_config {
182       'DEFAULT/network_device_mtu':   ensure => absent;
183     }
184   }
185
186   if $instance_usage_audit and $instance_usage_audit_period in ['hour', 'day', 'month', 'year'] {
187     nova_config {
188       'DEFAULT/instance_usage_audit':        value => $instance_usage_audit;
189       'DEFAULT/instance_usage_audit_period': value => $instance_usage_audit_period;
190     }
191   } else {
192     nova_config {
193       'DEFAULT/instance_usage_audit':        ensure => absent;
194       'DEFAULT/instance_usage_audit_period': ensure => absent;
195     }
196   }
197
198   package { 'pm-utils':
199     ensure => present,
200   }
201
202   nova_config {
203     'DEFAULT/force_raw_images': value => $force_raw_images;
204   }
205
206   if ($pci_passthrough) {
207     nova_config {
208       'DEFAULT/pci_passthrough_whitelist': value => check_array_of_hash($pci_passthrough);
209     }
210   }
211
212   nova_config {
213     'DEFAULT/default_availability_zone':          value => $default_availability_zone;
214     'DEFAULT/internal_service_availability_zone': value => $internal_service_availability_zone;
215   }
216
217   if $default_schedule_zone {
218     nova_config {
219       'DEFAULT/default_schedule_zone': value => $default_schedule_zone;
220     }
221   }
222 }