123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- class nova::compute::rbd (
- $libvirt_rbd_user,
- $libvirt_rbd_secret_uuid = false,
- $libvirt_rbd_secret_key = undef,
- $libvirt_images_rbd_pool = 'rbd',
- $libvirt_images_rbd_ceph_conf = '/etc/ceph/ceph.conf',
- $rbd_keyring = 'client.nova',
- $ephemeral_storage = true,
- $manage_ceph_client = true,
- $ceph_client_ensure = 'present',
- ) {
- include ::nova::deps
- include ::nova::params
- if $manage_ceph_client {
-
- package { 'ceph-client-package':
- ensure => $ceph_client_ensure,
- name => $nova::params::ceph_client_package_name,
- tag => ['openstack'],
- }
- }
- nova_config {
- 'libvirt/rbd_user': value => $libvirt_rbd_user;
- }
- if $libvirt_rbd_secret_uuid {
- nova_config {
- 'libvirt/rbd_secret_uuid': value => $libvirt_rbd_secret_uuid;
- }
- file { '/etc/nova/secret.xml':
- content => template('nova/secret.xml-compute.erb'),
- require => Anchor['nova::config::begin'],
- }
-
-
-
-
- $cm = '/usr/bin/virsh secret-define --file /etc/nova/secret.xml | /usr/bin/awk \'{print $2}\' | sed \'/^$/d\' > /etc/nova/virsh.secret'
- exec { 'get-or-set virsh secret':
- command => $cm,
- unless => "/usr/bin/virsh secret-list | grep ${libvirt_rbd_secret_uuid}",
- require => [File['/etc/nova/secret.xml'], Service['libvirt']],
- }
- if $libvirt_rbd_secret_key {
- $libvirt_key = $libvirt_rbd_secret_key
- } else {
- $libvirt_key = "$(ceph auth get-key ${rbd_keyring})"
- }
- exec { 'set-secret-value virsh':
- command => "/usr/bin/virsh secret-set-value --secret ${libvirt_rbd_secret_uuid} --base64 ${libvirt_key}",
- unless => "/usr/bin/virsh secret-get-value ${libvirt_rbd_secret_uuid} | grep ${libvirt_key}",
- require => Exec['get-or-set virsh secret'],
- before => Anchor['nova::config::end'],
- }
- }
- if $ephemeral_storage {
- nova_config {
- 'libvirt/images_type': value => 'rbd';
- 'libvirt/images_rbd_pool': value => $libvirt_images_rbd_pool;
- 'libvirt/images_rbd_ceph_conf': value => $libvirt_images_rbd_ceph_conf;
- }
- } else {
- nova_config {
- 'libvirt/images_rbd_pool': ensure => absent;
- 'libvirt/images_rbd_ceph_conf': ensure => absent;
- }
- }
- }
|