compute: allow more granularity on hypervisor nodes
- Allow to enable / disable RBD storage for: * Instances & Volumes * Volumes only (instances will be stored locally then) - Deprecate has_ceph param with backward compatibility - If RBD backend for instances is enabled on Red Hat, fail with a message. Closes-bug #486 Signed-off-by: Emilien Macchi <emilien.macchi@enovance.com>
This commit is contained in:
@@ -19,10 +19,14 @@
|
|||||||
#
|
#
|
||||||
# === Parameters:
|
# === Parameters:
|
||||||
#
|
#
|
||||||
# [*has_ceph]
|
# [*vm_rbd]
|
||||||
# (optional) Enable or not ceph capabilities on compute node.
|
# (optional) Enable or not ceph capabilities on compute node to store
|
||||||
# If Ceph is used as a backend for Cinder or Nova, this option should be
|
# nova instances on ceph storage.
|
||||||
# set to True.
|
# Default to false.
|
||||||
|
#
|
||||||
|
# [*volume_rbd]
|
||||||
|
# (optional) Enable or not ceph capabilities on compute node to attach
|
||||||
|
# cinder volumes backend by ceph on nova instances.
|
||||||
# Default to false.
|
# Default to false.
|
||||||
#
|
#
|
||||||
|
|
||||||
@@ -37,6 +41,9 @@ class cloud::compute::hypervisor(
|
|||||||
$cinder_rbd_user = 'cinder',
|
$cinder_rbd_user = 'cinder',
|
||||||
$nova_rbd_pool = 'vms',
|
$nova_rbd_pool = 'vms',
|
||||||
$nova_rbd_secret_uuid = undef,
|
$nova_rbd_secret_uuid = undef,
|
||||||
|
$vm_rbd = false,
|
||||||
|
$volume_rbd = false,
|
||||||
|
# DEPRECATED
|
||||||
$has_ceph = false
|
$has_ceph = false
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@@ -44,6 +51,17 @@ class cloud::compute::hypervisor(
|
|||||||
include 'cloud::telemetry'
|
include 'cloud::telemetry'
|
||||||
include 'cloud::network'
|
include 'cloud::network'
|
||||||
|
|
||||||
|
# Backward compatibility
|
||||||
|
# if has_ceph was enabled, we consider deployments run Ceph for Nova & Cinder
|
||||||
|
if $has_ceph {
|
||||||
|
warning('has_ceph parameter is deprecated. Please use vm_rbd and volume_rbd parameters.')
|
||||||
|
$vm_rbd_real = true
|
||||||
|
$volume_rbd_real = true
|
||||||
|
} else {
|
||||||
|
$vm_rbd_real = $vm_rbd
|
||||||
|
$volume_rbd_real = $volume_rbd
|
||||||
|
}
|
||||||
|
|
||||||
file{ '/var/lib/nova/.ssh':
|
file{ '/var/lib/nova/.ssh':
|
||||||
ensure => directory,
|
ensure => directory,
|
||||||
mode => '0700',
|
mode => '0700',
|
||||||
@@ -103,12 +121,9 @@ Host *
|
|||||||
notify => Service['libvirtd']
|
notify => Service['libvirtd']
|
||||||
}
|
}
|
||||||
# Nova support for RBD backend is not supported in Red Hat packages
|
# Nova support for RBD backend is not supported in Red Hat packages
|
||||||
if $has_ceph {
|
if $has_ceph or $vm_rbd {
|
||||||
warning('Red Hat does not support RBD backend for VMs.')
|
fail('Red Hat does not support RBD backend for VMs.')
|
||||||
}
|
}
|
||||||
$has_ceph_real = false
|
|
||||||
} else {
|
|
||||||
$has_ceph_real = $has_ceph
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if $::operatingsystem == 'Ubuntu' {
|
if $::operatingsystem == 'Ubuntu' {
|
||||||
@@ -125,14 +140,23 @@ Host *
|
|||||||
|
|
||||||
class { 'nova::compute::neutron': }
|
class { 'nova::compute::neutron': }
|
||||||
|
|
||||||
if $has_ceph_real {
|
if $vm_rbd_real or $volume_rbd_real {
|
||||||
|
|
||||||
$libvirt_disk_cachemodes_real = ['network=writeback']
|
|
||||||
include 'cloud::storage::rbd'
|
include 'cloud::storage::rbd'
|
||||||
|
|
||||||
class { 'nova::compute::rbd':
|
$libvirt_disk_cachemodes_real = ['network=writeback']
|
||||||
libvirt_rbd_user => $cinder_rbd_user,
|
|
||||||
libvirt_images_rbd_pool => $nova_rbd_pool
|
# when nova uses ceph for instances storage
|
||||||
|
if $vm_rbd_real {
|
||||||
|
class { 'nova::compute::rbd':
|
||||||
|
libvirt_rbd_user => $cinder_rbd_user,
|
||||||
|
libvirt_images_rbd_pool => $nova_rbd_pool
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
# when nova only needs to attach ceph volumes to instances
|
||||||
|
nova_config {
|
||||||
|
'libvirt/rbd_user': value => $cinder_rbd_user;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
# we don't want puppet-nova manages keyring
|
# we don't want puppet-nova manages keyring
|
||||||
nova_config {
|
nova_config {
|
||||||
|
@@ -74,6 +74,8 @@ describe 'cloud::compute::hypervisor' do
|
|||||||
:nova_ssh_private_key => 'secrete',
|
:nova_ssh_private_key => 'secrete',
|
||||||
:nova_ssh_public_key => 'public',
|
:nova_ssh_public_key => 'public',
|
||||||
:ks_nova_public_proto => 'http',
|
:ks_nova_public_proto => 'http',
|
||||||
|
:vm_rbd => false,
|
||||||
|
:volume_rbd => false,
|
||||||
:ks_nova_public_host => '10.0.0.1' }
|
:ks_nova_public_host => '10.0.0.1' }
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -221,6 +223,7 @@ describe 'cloud::compute::hypervisor' do
|
|||||||
|
|
||||||
it 'should not configure nova-compute for RBD backend' do
|
it 'should not configure nova-compute for RBD backend' do
|
||||||
should_not contain_nova_config('libvirt/rbd_user').with('value' => 'cinder')
|
should_not contain_nova_config('libvirt/rbd_user').with('value' => 'cinder')
|
||||||
|
should_not contain_nova_config('libvirt/images_type').with('value' => 'rbd')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'configure libvirt driver without disk cachemodes' do
|
it 'configure libvirt driver without disk cachemodes' do
|
||||||
@@ -255,7 +258,73 @@ describe 'cloud::compute::hypervisor' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with RBD backend on Debian plaforms' do
|
context 'with RBD backend for instances and volumes on Debian plaforms' do
|
||||||
|
before :each do
|
||||||
|
facts.merge!( :osfamily => 'Debian' )
|
||||||
|
params.merge!(
|
||||||
|
:vm_rbd => true,
|
||||||
|
:volume_rbd => true,
|
||||||
|
:cinder_rbd_user => 'cinder',
|
||||||
|
:nova_rbd_pool => 'nova',
|
||||||
|
:nova_rbd_secret_uuid => 'secrete' )
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configure nova-compute to support RBD backend' do
|
||||||
|
should contain_nova_config('libvirt/images_type').with('value' => 'rbd')
|
||||||
|
should contain_nova_config('libvirt/images_rbd_pool').with('value' => 'nova')
|
||||||
|
should contain_nova_config('libvirt/images_rbd_ceph_conf').with('value' => '/etc/ceph/ceph.conf')
|
||||||
|
should contain_nova_config('libvirt/rbd_user').with('value' => 'cinder')
|
||||||
|
should contain_nova_config('libvirt/rbd_secret_uuid').with('value' => 'secrete')
|
||||||
|
should contain_group('cephkeyring').with(:ensure => 'present')
|
||||||
|
should contain_exec('add-nova-to-group').with(
|
||||||
|
:command => 'usermod -a -G cephkeyring nova',
|
||||||
|
:unless => 'groups nova | grep cephkeyring'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configure libvirt driver' do
|
||||||
|
should contain_class('nova::compute::libvirt').with(
|
||||||
|
:libvirt_type => 'kvm',
|
||||||
|
:vncserver_listen => '0.0.0.0',
|
||||||
|
:migration_support => true,
|
||||||
|
:libvirt_disk_cachemodes => ['network=writeback']
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with RBD support only for volumes on Debian plaforms' do
|
||||||
|
before :each do
|
||||||
|
facts.merge!( :osfamily => 'Debian' )
|
||||||
|
params.merge!(
|
||||||
|
:vm_rbd => false,
|
||||||
|
:volume_rbd => true,
|
||||||
|
:cinder_rbd_user => 'cinder',
|
||||||
|
:nova_rbd_secret_uuid => 'secrete' )
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configure nova-compute to support RBD backend' do
|
||||||
|
should_not contain_nova_config('libvirt/images_type').with('value' => 'rbd')
|
||||||
|
should_not contain_nova_config('libvirt/images_rbd_pool').with('value' => 'nova')
|
||||||
|
should contain_nova_config('libvirt/rbd_user').with('value' => 'cinder')
|
||||||
|
should contain_nova_config('libvirt/rbd_secret_uuid').with('value' => 'secrete')
|
||||||
|
should contain_group('cephkeyring').with(:ensure => 'present')
|
||||||
|
should contain_exec('add-nova-to-group').with(
|
||||||
|
:command => 'usermod -a -G cephkeyring nova',
|
||||||
|
:unless => 'groups nova | grep cephkeyring'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configure libvirt driver' do
|
||||||
|
should contain_class('nova::compute::libvirt').with(
|
||||||
|
:libvirt_type => 'kvm',
|
||||||
|
:vncserver_listen => '0.0.0.0',
|
||||||
|
:migration_support => true,
|
||||||
|
:libvirt_disk_cachemodes => ['network=writeback']
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with RBD backend on Debian plaforms using deprecated parameter' do
|
||||||
before :each do
|
before :each do
|
||||||
facts.merge!( :osfamily => 'Debian' )
|
facts.merge!( :osfamily => 'Debian' )
|
||||||
params.merge!(
|
params.merge!(
|
||||||
@@ -289,6 +358,18 @@ describe 'cloud::compute::hypervisor' do
|
|||||||
end
|
end
|
||||||
|
|
||||||
context 'when trying to enable RBD backend on RedHat plaforms' do
|
context 'when trying to enable RBD backend on RedHat plaforms' do
|
||||||
|
before :each do
|
||||||
|
facts.merge!( :operatingsystem => 'RedHat' )
|
||||||
|
params.merge!(
|
||||||
|
:vm_rbd => true,
|
||||||
|
:cinder_rbd_user => 'cinder',
|
||||||
|
:nova_rbd_pool => 'nova',
|
||||||
|
:nova_rbd_secret_uuid => 'secrete' )
|
||||||
|
end
|
||||||
|
it_raises 'a Puppet::Error', /Red Hat does not support RBD backend for VMs./
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when trying to enable RBD backend with deprecated parameter on RedHat plaforms' do
|
||||||
before :each do
|
before :each do
|
||||||
facts.merge!( :operatingsystem => 'RedHat' )
|
facts.merge!( :operatingsystem => 'RedHat' )
|
||||||
params.merge!(
|
params.merge!(
|
||||||
@@ -297,17 +378,8 @@ describe 'cloud::compute::hypervisor' do
|
|||||||
:nova_rbd_pool => 'nova',
|
:nova_rbd_pool => 'nova',
|
||||||
:nova_rbd_secret_uuid => 'secrete' )
|
:nova_rbd_secret_uuid => 'secrete' )
|
||||||
end
|
end
|
||||||
|
it_raises 'a Puppet::Error', /Red Hat does not support RBD backend for VMs./
|
||||||
it 'configure libvirt driver without libvirt_disk_cachemodes' do
|
|
||||||
should contain_class('nova::compute::libvirt').with(
|
|
||||||
:libvirt_type => 'kvm',
|
|
||||||
:vncserver_listen => '0.0.0.0',
|
|
||||||
:migration_support => true,
|
|
||||||
:libvirt_disk_cachemodes => []
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'on Debian platforms' do
|
context 'on Debian platforms' do
|
||||||
|
Reference in New Issue
Block a user