2 # Copyright (C) 2014 OpenStack Fondation
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
5 # Donald Talton <dotalton@cisco.com>
7 # Licensed under the Apache License, Version 2.0 (the "License"); you may
8 # not use this file except in compliance with the License. You may obtain
9 # a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16 # License for the specific language governing permissions and limitations
19 # == Class: nova::compute::rbd
21 # Configure nova-compute to store virtual machines on RBD
25 # [*libvirt_images_rbd_pool*]
26 # (optional) The RADOS pool in which rbd volumes are stored.
29 # [*libvirt_images_rbd_ceph_conf*]
30 # (optional) The path to the ceph configuration file to use.
31 # Defaults to '/etc/ceph/ceph.conf'.
33 # [*libvirt_rbd_user*]
34 # (Required) The RADOS client name for accessing rbd volumes.
36 # [*libvirt_rbd_secret_uuid*]
37 # (optional) The libvirt uuid of the secret for the rbd_user.
38 # Required to use cephx.
41 # [*libvirt_rbd_secret_key*]
42 # (optional) The cephx key to use as key for the libvirt secret,
43 # it must be base64 encoded; when not provided this key will be
44 # requested to the ceph cluster, which assumes the node is
45 # provided of the client.admin keyring as well.
49 # (optional) The keyring name to use when retrieving the RBD secret
50 # Default to 'client.nova'
53 class nova::compute::rbd (
55 $libvirt_rbd_secret_uuid = false,
56 $libvirt_rbd_secret_key = undef,
57 $libvirt_images_rbd_pool = 'rbd',
58 $libvirt_images_rbd_ceph_conf = '/etc/ceph/ceph.conf',
59 $rbd_keyring = 'client.nova',
65 'libvirt/images_type': value => 'rbd';
66 'libvirt/images_rbd_pool': value => $libvirt_images_rbd_pool;
67 'libvirt/images_rbd_ceph_conf': value => $libvirt_images_rbd_ceph_conf;
68 'libvirt/rbd_user': value => $libvirt_rbd_user;
71 if $libvirt_rbd_secret_uuid {
73 'libvirt/rbd_secret_uuid': value => $libvirt_rbd_secret_uuid;
76 file { '/etc/nova/secret.xml':
77 content => template('nova/secret.xml-compute.erb')
80 exec { 'get-or-set virsh secret':
81 command => '/usr/bin/virsh secret-define --file /etc/nova/secret.xml | /usr/bin/awk \'{print $2}\' | sed \'/^$/d\' > /etc/nova/virsh.secret',
82 creates => '/etc/nova/virsh.secret',
83 require => File['/etc/nova/secret.xml']
86 if $libvirt_rbd_secret_key {
87 $libvirt_key = $libvirt_rbd_secret_key
89 $libvirt_key = "$(ceph auth get-key ${rbd_keyring})"
91 exec { 'set-secret-value virsh':
92 command => "/usr/bin/virsh secret-set-value --secret ${libvirt_rbd_secret_uuid} --base64 ${libvirt_key}",
93 unless => "/usr/bin/virsh secret-get-value ${libvirt_rbd_secret_uuid}",
94 require => Exec['get-or-set virsh secret']