nfs: Ensure nova/glance permissions on nfs mount
Ensure filesystem_store_datadir is a directory with nova or glance permissions before creating the nfs mount. Change-Id: I06a0d95af3829cd803b0af0ebc52fd17b18ff2b3 Closes-Bug: #1443994
This commit is contained in:
@@ -170,6 +170,12 @@ class cloud::compute::hypervisor(
|
|||||||
# We mount the NFS share in filesystem_store_datadir to fake the
|
# We mount the NFS share in filesystem_store_datadir to fake the
|
||||||
# backend.
|
# backend.
|
||||||
if $nfs_device {
|
if $nfs_device {
|
||||||
|
file { $filesystem_store_datadir:
|
||||||
|
ensure => 'directory',
|
||||||
|
owner => 'nova',
|
||||||
|
group => 'nova',
|
||||||
|
mode => '0755'
|
||||||
|
}
|
||||||
nova_config { 'DEFAULT/instances_path': value => $filesystem_store_datadir; }
|
nova_config { 'DEFAULT/instances_path': value => $filesystem_store_datadir; }
|
||||||
$nfs_mount = {
|
$nfs_mount = {
|
||||||
"${filesystem_store_datadir}" => {
|
"${filesystem_store_datadir}" => {
|
||||||
@@ -180,7 +186,7 @@ class cloud::compute::hypervisor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ensure_resource('class', 'nfs', {})
|
ensure_resource('class', 'nfs', {})
|
||||||
create_resources('types::mount', $nfs_mount)
|
create_resources('types::mount', $nfs_mount, {require => File[$filesystem_store_datadir]})
|
||||||
|
|
||||||
# Not using /var/lib/nova/instances may cause side effects.
|
# Not using /var/lib/nova/instances may cause side effects.
|
||||||
if $filesystem_store_datadir != '/var/lib/nova/instances' {
|
if $filesystem_store_datadir != '/var/lib/nova/instances' {
|
||||||
|
@@ -260,6 +260,12 @@ class cloud::image::api(
|
|||||||
# We mount the NFS share in filesystem_store_datadir to fake the
|
# We mount the NFS share in filesystem_store_datadir to fake the
|
||||||
# backend.
|
# backend.
|
||||||
if $nfs_device {
|
if $nfs_device {
|
||||||
|
file { $filesystem_store_datadir:
|
||||||
|
ensure => 'directory',
|
||||||
|
owner => 'glance',
|
||||||
|
group => 'glance',
|
||||||
|
mode => '0755'
|
||||||
|
} ->
|
||||||
class { 'glance::backend::file':
|
class { 'glance::backend::file':
|
||||||
filesystem_store_datadir => $filesystem_store_datadir
|
filesystem_store_datadir => $filesystem_store_datadir
|
||||||
}
|
}
|
||||||
@@ -272,7 +278,7 @@ class cloud::image::api(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ensure_resource('class', 'nfs', {})
|
ensure_resource('class', 'nfs', {})
|
||||||
create_resources('types::mount', $nfs_mount)
|
create_resources('types::mount', $nfs_mount, {require => File[$filesystem_store_datadir]})
|
||||||
} else {
|
} else {
|
||||||
fail('When running NFS backend, you need to provide nfs_device parameter.')
|
fail('When running NFS backend, you need to provide nfs_device parameter.')
|
||||||
}
|
}
|
||||||
|
@@ -424,6 +424,12 @@ describe 'cloud::compute::hypervisor' do
|
|||||||
:nfs_options => 'noacl,fsid=123' )
|
:nfs_options => 'noacl,fsid=123' )
|
||||||
end
|
end
|
||||||
it 'configure nova instances path and NFS mount' do
|
it 'configure nova instances path and NFS mount' do
|
||||||
|
is_expected.to contain_file('/var/lib/nova/instances').with(
|
||||||
|
'ensure' => 'directory',
|
||||||
|
'owner' => 'nova',
|
||||||
|
'group' => 'nova',
|
||||||
|
'mode' => '0755'
|
||||||
|
)
|
||||||
is_expected.to contain_nova_config('DEFAULT/instances_path').with('value' => '/var/lib/nova/instances')
|
is_expected.to contain_nova_config('DEFAULT/instances_path').with('value' => '/var/lib/nova/instances')
|
||||||
is_expected.to contain_mount('/var/lib/nova/instances').with({
|
is_expected.to contain_mount('/var/lib/nova/instances').with({
|
||||||
'ensure' => 'mounted',
|
'ensure' => 'mounted',
|
||||||
|
@@ -125,6 +125,12 @@ describe 'cloud::image::api' do
|
|||||||
it 'configure Glance with NFS backend' do
|
it 'configure Glance with NFS backend' do
|
||||||
is_expected.to contain_class('glance::backend::file')
|
is_expected.to contain_class('glance::backend::file')
|
||||||
is_expected.not_to contain_class('glance::backend::rbd')
|
is_expected.not_to contain_class('glance::backend::rbd')
|
||||||
|
is_expected.to contain_file('/srv/images/').with(
|
||||||
|
'ensure' => 'directory',
|
||||||
|
'owner' => 'glance',
|
||||||
|
'group' => 'glance',
|
||||||
|
'mode' => '0755'
|
||||||
|
)
|
||||||
is_expected.to contain_glance_api_config('glance_store/filesystem_store_datadir').with('value' => '/srv/images/')
|
is_expected.to contain_glance_api_config('glance_store/filesystem_store_datadir').with('value' => '/srv/images/')
|
||||||
is_expected.to contain_glance_api_config('glance_store/default_store').with('value' => 'file')
|
is_expected.to contain_glance_api_config('glance_store/default_store').with('value' => 'file')
|
||||||
is_expected.to contain_mount('/srv/images/').with({
|
is_expected.to contain_mount('/srv/images/').with({
|
||||||
|
Reference in New Issue
Block a user