diff --git a/manifests/backend/ganesha.pp b/manifests/backend/ganesha.pp new file mode 100644 index 00000000..1ece2211 --- /dev/null +++ b/manifests/backend/ganesha.pp @@ -0,0 +1,94 @@ +# +# == Define: manila::ganesha +# +# Set NFS Ganesha options for share drivers +# +# === Parameters +# +# [*share_backend_name*] +# (optional) Name of the backend in manila.conf that +# these settings will reside in +# Defaults to: $name +# +# [*ganesha_config_dir*] +# (optional) Directory where Ganesha config files are stored. +# Defaults to $::os_service_default +# +# [*ganesha_config_path*] +# (optional) Path to main Ganesha config file. +# Defaults to $::os_service_default +# +# [*ganesha_service_name*] +# (optional) Name of the ganesha nfs service. +# Defaults to $::os_service_default +# +# [*ganesha_db_path*] +# (optional) Location of Ganesha database file (Ganesha module only). +# Defaults to $::os_service_default +# +# [*ganesha_export_dir*] +# (optional) Path to directory containing Ganesha export configuration. +# (Ganesha module only.) +# Defaults to $::os_service_default +# +# [*ganesha_export_template_dir*] +# (optional) Path to directory containing Ganesha export block templates. +# (Ganesha module only.) +# Defaults to $::os_service_default +# +# [*ganesha_rados_store_enable*] +# (optional) Persist Ganesha exports and export counter in Ceph RADOS objects +# Defaults to $::os_service_default +# +# [*ganesha_rados_store_pool_name*] +# (optional) Name of the Ceph RADOS pool to store Ganesha exports and export +# counter. +# Defaults to $::os_service_default +# +# [*ganesha_rados_export_counter*] +# (optional) Name of the CEPH RADOS object used as the Ganesha export counter. +# Defaults to $::os_service_default +# +# [*ganesha_rados_export_index*] +# (optional) Name of the CEPH RADOS object used to store a list of the export +# RADOS object URLs. +# Defaults to $::os_service_default +# +define manila::backend::ganesha ( + $share_backend_name = $name, + $ganesha_config_dir = $::os_service_default, + $ganesha_config_path = $::os_service_default, + $ganesha_service_name = $::os_service_default, + $ganesha_db_path = $::os_service_default, + $ganesha_export_dir = $::os_service_default, + $ganesha_export_template_dir = $::os_service_default, + $ganesha_rados_store_enable = $::os_service_default, + $ganesha_rados_store_pool_name = $::os_service_default, + $ganesha_rados_export_counter = $::os_service_default, + $ganesha_rados_export_index = $::os_service_default, +) { + + include manila::deps + + manila_config { + "${share_backend_name}/ganesha_config_dir": value => $ganesha_config_dir; + "${share_backend_name}/ganesha_config_path": value => $ganesha_config_path; + "${share_backend_name}/ganesha_service_name": value => $ganesha_service_name; + "${share_backend_name}/ganesha_db_path": value => $ganesha_db_path; + "${share_backend_name}/ganesha_export_dir": value => $ganesha_export_dir; + "${share_backend_name}/ganesha_export_template_dir": value => $ganesha_export_template_dir; + "${share_backend_name}/ganesha_rados_store_enable": value => $ganesha_rados_store_enable; + "${share_backend_name}/ganesha_rados_store_pool_name": value => $ganesha_rados_store_pool_name; + "${share_backend_name}/ganesha_rados_export_counter": value => $ganesha_rados_export_counter; + "${share_backend_name}/ganesha_rados_export_index": value => $ganesha_rados_export_index; + } + + if ($::osfamily == 'RedHat') { + ensure_packages( 'nfs-ganesha', { + ensure => present, + tag => ['openstack', 'manila-support-package'], + }) + } else { + warning("Unsupported osfamily ${::osfamily}, Red Hat is the only supported platform.") + } +} diff --git a/manifests/ganesha.pp b/manifests/ganesha.pp index 25cbad0e..2492d36d 100644 --- a/manifests/ganesha.pp +++ b/manifests/ganesha.pp @@ -41,21 +41,12 @@ class manila::ganesha ( include manila::deps - manila_config { - 'DEFAULT/ganesha_config_dir': value => $ganesha_config_dir; - 'DEFAULT/ganesha_config_path': value => $ganesha_config_path; - 'DEFAULT/ganesha_service_name': value => $ganesha_service_name; - 'DEFAULT/ganesha_db_path': value => $ganesha_db_path; - 'DEFAULT/ganesha_export_dir': value => $ganesha_export_dir; - 'DEFAULT/ganesha_export_template_dir': value => $ganesha_export_template_dir; - } - - if ($::osfamily == 'RedHat') { - package { 'nfs-ganesha': - ensure => present, - tag => ['openstack', 'manila-support-package'], - } - } else { - warning("Unsupported osfamily ${::osfamily}, Red Hat is the only supported platform.") + manila::backend::ganesha { 'DEFAULT': + ganesha_config_dir => $ganesha_config_dir, + ganesha_config_path => $ganesha_config_path, + ganesha_service_name => $ganesha_service_name, + ganesha_db_path => $ganesha_db_path, + ganesha_export_dir => $ganesha_export_dir, + ganesha_export_template_dir => $ganesha_export_template_dir, } } diff --git a/releasenotes/notes/backend-ganesha-opts-1879e014a3796efd.yaml b/releasenotes/notes/backend-ganesha-opts-1879e014a3796efd.yaml new file mode 100644 index 00000000..84df3ca7 --- /dev/null +++ b/releasenotes/notes/backend-ganesha-opts-1879e014a3796efd.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + The ``manila::backend::ganesha`` resource type has been added. This allows + configuring Ganesha share which is supported by some drivers like CephFS. diff --git a/spec/defines/manila_backend_ganesha_spec.rb b/spec/defines/manila_backend_ganesha_spec.rb new file mode 100644 index 00000000..9a8ee8b3 --- /dev/null +++ b/spec/defines/manila_backend_ganesha_spec.rb @@ -0,0 +1,73 @@ +require 'spec_helper' + +describe 'manila::backend::ganesha' do + + shared_examples_for 'manila::backend::ganesha' do + let(:title) {'ganesha'} + + context 'with defaults' do + let :params do + {} + end + + it 'set the default values' do + is_expected.to contain_manila_config('ganesha/ganesha_config_dir').with_value('') + is_expected.to contain_manila_config('ganesha/ganesha_config_path').with_value('') + is_expected.to contain_manila_config('ganesha/ganesha_service_name').with_value('') + is_expected.to contain_manila_config('ganesha/ganesha_db_path').with_value('') + is_expected.to contain_manila_config('ganesha/ganesha_export_dir').with_value('') + is_expected.to contain_manila_config('ganesha/ganesha_export_template_dir').with_value('') + is_expected.to contain_manila_config('ganesha/ganesha_rados_store_enable').with_value('') + is_expected.to contain_manila_config('ganesha/ganesha_rados_store_pool_name').with_value('') + is_expected.to contain_manila_config('ganesha/ganesha_rados_export_counter').with_value('') + is_expected.to contain_manila_config('ganesha/ganesha_rados_export_index').with_value('') + end + end + + context 'with specific parameters' do + let :params do + { + :ganesha_config_dir => '/etc/ganesha', + :ganesha_config_path => '/etc/ganesha/ganesha.conf', + :ganesha_service_name => 'ganesha.nfsd', + :ganesha_db_path => '$state_path/manila-ganesha.db', + :ganesha_export_dir => '/etc/ganesha/export.d', + :ganesha_export_template_dir => '/etc/manila/ganesha-export-templ.d', + :ganesha_rados_store_enable => true, + :ganesha_rados_store_pool_name => 'storepool', + :ganesha_rados_export_counter => 'ganesha-export-counter', + :ganesha_rados_export_index => 'ganesha-export-index', + } + end + + it 'Adds NFS Ganesha options to the share drivers' do + params.each_pair do |config,value| + is_expected.to contain_manila_config("ganesha/#{config}").with_value(value) + end + end + end + end + + shared_examples_for 'manila::backend::ganesha on RedHat' do + let(:title) {'ganesha'} + + it { is_expected.to contain_package('nfs-ganesha').with( + :name => 'nfs-ganesha', + :ensure => 'present', + ) } + end + + on_supported_os({ + :supported_os => OSDefaults.get_supported_os + }).each do |os,facts| + context "on #{os}" do + let (:facts) do + facts.merge!(OSDefaults.get_facts({ :fqdn => 'some.host.tld'})) + end + it_configures 'manila::backend::ganesha' + if facts[:osfamily] == 'RedHat' + it_configures 'manila::backend::ganesha on RedHat' + end + end + end +end