diff --git a/examples/common.yaml b/examples/common.yaml index c3777b64..0ab98c66 100644 --- a/examples/common.yaml +++ b/examples/common.yaml @@ -20,6 +20,9 @@ ceph::profile::params::osd_recovery_op_priority: '1' ceph::profile::params::osd_recovery_max_single_start: '1' ceph::profile::params::osd_max_scrubs: '1' ceph::profile::params::osd_op_threads: '2' +ceph::profile::params::fs_name: 'fs_name' +ceph::profile::params::fs_metadata_pool: 'metadata_pool' +ceph::profile::params::fs_data_pool: 'data_pool' ######## Keys ceph::profile::params::mon_key: 'AQATGHJTUCBqIBAA7M2yafV1xctn1pgr3GcKPg==' diff --git a/manifests/fs.pp b/manifests/fs.pp new file mode 100644 index 00000000..d8159d4e --- /dev/null +++ b/manifests/fs.pp @@ -0,0 +1,56 @@ +# +# Copyright 2016 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Author: Jan Provaznik +# +# Manages operations on the fs in the cluster, such as creating or deleting +# fs, setting PG/PGP numbers, number of replicas, ... +# +# == Define: ceph::fs +# +# The name of the fs. +# +# === Parameters: +# +# [*name*] Name of the filesystem. +# Optional. Default is cephfs. +# +# [*metadata_pool*] Name of a pool used for storing metadata. +# Mandatory. Get one with `ceph osd pool ls` +# +# [*data_pool*] Name of a pool used for storing data. +# Mandatory. Get one with `ceph osd pool ls` +# +# [*exec_timeout*] The default exec resource timeout, in seconds +# Optional. Defaults to $::ceph::params::exec_timeout +# +define ceph::fs ( + $metadata_pool, + $data_pool, + $exec_timeout = $::ceph::params::exec_timeout, +) { + Ceph_config<||> -> Exec["create-fs-${name}"] + Ceph::Pool<||> -> Exec["create-fs-${name}"] + + exec { "create-fs-${name}": + command => "/bin/true # comment to satisfy puppet syntax requirements +set -ex +ceph fs new ${name} ${metadata_pool} ${data_pool}", + unless => "/bin/true # comment to satisfy puppet syntax requirements +set -ex +ceph fs ls | grep 'name: ${name},'", + timeout => $exec_timeout, + } +} diff --git a/manifests/profile/fs.pp b/manifests/profile/fs.pp new file mode 100644 index 00000000..08bb71fe --- /dev/null +++ b/manifests/profile/fs.pp @@ -0,0 +1,29 @@ +# +# Copyright (C) 2016 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Author: Jan Provaznik +# +# == Class: ceph::profile::fs +# +# Profile for a Ceph fs +# +class ceph::profile::fs { + require ::ceph::profile::base + + ceph::fs { $ceph::profile::params::fs_name: + metadata_pool => $ceph::profile::params::fs_metadata_pool, + data_pool => $ceph::profile::params::fs_data_pool, + } +} diff --git a/manifests/profile/params.pp b/manifests/profile/params.pp index bd87a5ed..c2eba405 100644 --- a/manifests/profile/params.pp +++ b/manifests/profile/params.pp @@ -175,6 +175,16 @@ # # [*rbd_mirror_client_name*] Name of the cephx client key used for rbd mirroring # Optional. Default is undef +# +# [*fs_name*] The FS name. +# Optional but required when using fs. +# +# [*fs_metadata_pool*] The FS metadata pool name. +# Optional but required when using fs. +# +# [*fs_data_pool*] The FS data pool name. +# Optional but required when using fs. +# class ceph::profile::params ( @@ -219,6 +229,9 @@ class ceph::profile::params ( $rgw_keystone_admin_user = undef, $rgw_keystone_admin_password = undef, $rbd_mirror_client_name = undef, + $fs_metadata_pool = undef, + $fs_data_pool = undef, + $fs_name = undef, ) { validate_hash($client_keys) diff --git a/spec/classes/ceph_profile_fs_spec.rb b/spec/classes/ceph_profile_fs_spec.rb new file mode 100644 index 00000000..6533da0c --- /dev/null +++ b/spec/classes/ceph_profile_fs_spec.rb @@ -0,0 +1,39 @@ +# +# Copyright (C) 2016 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +require 'spec_helper' + +describe 'ceph::profile::fs' do + + shared_examples_for 'ceph profile fs' do + + it { is_expected.to contain_ceph__fs('fs_name').with( + 'metadata_pool' => 'metadata_pool', + 'data_pool' => 'data_pool' + )} + 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({:hostname => 'myhostname'})) + end + + it_behaves_like 'ceph profile fs' + end + end +end diff --git a/spec/defines/ceph_fs_spec.rb b/spec/defines/ceph_fs_spec.rb new file mode 100644 index 00000000..d498204d --- /dev/null +++ b/spec/defines/ceph_fs_spec.rb @@ -0,0 +1,52 @@ +# Copyright 2016 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'spec_helper' + +describe 'ceph::fs' do + + shared_examples_for 'ceph fs' do + describe "activated with custom params" do + let :title do + 'fsa' + end + + let :params do + { + :metadata_pool => 'metadata_pool', + :data_pool => 'data_pool' + } + end + + it { is_expected.to contain_exec('create-fs-fsa').with( + :command => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph fs new fsa metadata_pool data_pool", + :unless => "/bin/true # comment to satisfy puppet syntax requirements\nset -ex\nceph fs ls | grep 'name: fsa,'" + )} + end + 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({:hostname => 'myhostname'})) + end + + it_behaves_like 'ceph fs' + end + end + +end diff --git a/spec/fixtures/hieradata/common.yaml b/spec/fixtures/hieradata/common.yaml index b244d446..7448923e 100644 --- a/spec/fixtures/hieradata/common.yaml +++ b/spec/fixtures/hieradata/common.yaml @@ -23,6 +23,9 @@ ceph::profile::params::osd_recovery_op_priority: '1' ceph::profile::params::osd_recovery_max_single_start: '1' ceph::profile::params::osd_max_scrubs: '1' ceph::profile::params::osd_op_threads: '2' +ceph::profile::params::fs_name: 'fs_name' +ceph::profile::params::fs_metadata_pool: 'metadata_pool' +ceph::profile::params::fs_data_pool: 'data_pool' ######## Keys ceph::profile::params::mds_key: 'AQDLOh1VgEp6FRAAFzT7Zw+Y9V6JJExQAsRnRQ=='