From f95aa995f6e7b7ee2ad2f2124004cfedbc9ca61f Mon Sep 17 00:00:00 2001 From: Keith Schincke Date: Wed, 23 Nov 2016 15:46:26 -0500 Subject: [PATCH] Add support for installing Ceph rbd-mirror Change-Id: If00c85d69cb4b3d2c0c34dd6d2ee2c1fc3db4a2f --- manifests/mirror.pp | 72 +++++++++++++++++++ manifests/profile/mirror.pp | 30 ++++++++ manifests/profile/params.pp | 4 ++ manifests/profile/rgw.pp | 2 +- manifests/rgw/civetweb.pp | 2 +- .../notes/rbd-mirror-e8c13699bb0e71d8.yaml | 7 ++ spec/defines/ceph_rbd_mirror_spec.rb | 64 +++++++++++++++++ 7 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 manifests/mirror.pp create mode 100644 manifests/profile/mirror.pp create mode 100644 releasenotes/notes/rbd-mirror-e8c13699bb0e71d8.yaml create mode 100644 spec/defines/ceph_rbd_mirror_spec.rb diff --git a/manifests/mirror.pp b/manifests/mirror.pp new file mode 100644 index 00000000..084a3671 --- /dev/null +++ b/manifests/mirror.pp @@ -0,0 +1,72 @@ +# +# Copyright (C) 2016 Keith Schincke +# +# 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: Keith Schincke +# +# Configures a ceph rbd mirroring +# +# == Define: ceph::mirror +# +# === Parameters: +# +# [*pkg_mirror*] Package name for RBD mirroring +# Optional. Default is 'rbd-mirror' +# +# [*rbd_mirror_ensure*] Ensure RBD mirror is running +# Optional. Default is 'running' +# +# [*rbd_mirror_enable*] Enable the RBD mirror service on boot +# Optional. Default is true + +define ceph::mirror ( + $pkg_mirror = 'rbd-mirror', + $rbd_mirror_ensure = 'running', + $rbd_mirror_enable = true, +) { + + include ::stdlib + + ensure_resource( 'package', + $pkg_mirror, + { + ensure => present, + tag => [ 'ceph' ], + } + ) + + $service_name = "ceph-rbd-mirror@${name}" + + #Xenial reports 'debian' as the service provider + #'systemd' should cover supported RHEL type systems + if( ( $::service_provider == 'systemd' ) or + ( $::operatingsystemrelease == '16.04' ) ) + { + Service{ + name => $service_name, + enable => $rbd_mirror_enable, + } + } + else { + fail( 'Unsupported operating system. Ubuntu 16.04 and RedHat/CentOS 7 are supported' ) + } + + service { $service_name: + ensure => $rbd_mirror_ensure, + tag => ['ceph-rbd-mirror'] + } + + Ceph_config<||> ~> Service<| tag == 'ceph-rbd-mirror' |> + Package<| tag == 'ceph'|> -> Service<| tag == 'ceph-rbd-mirror' |> +} diff --git a/manifests/profile/mirror.pp b/manifests/profile/mirror.pp new file mode 100644 index 00000000..e22c1d5f --- /dev/null +++ b/manifests/profile/mirror.pp @@ -0,0 +1,30 @@ +# +# Copyright (C) 2016 Keith Schincke +# +# 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: Keith Schincke +# +# == Class: ceph::profile::mirror +# +# Profile for Ceph rbd mirror +# +class ceph::profile::mirror { + require ::ceph::profile::base + $rbd_name = $::ceph::profile::params::rbd_mirror_client_name ? { + undef => 'openstack', + default => $::ceph::profile::params::rbd_mirror_client_name, + } + ceph::mirror { $rbd_name: + } +} diff --git a/manifests/profile/params.pp b/manifests/profile/params.pp index 52c16eef..26d0ae6d 100644 --- a/manifests/profile/params.pp +++ b/manifests/profile/params.pp @@ -169,6 +169,9 @@ # # [*rgw_keystone_admin_password*] The password for OpenStack admin user # Required if is 'v3'. +# +# [*rbd_mirror_client_name*] Name of the cephx client key used for rbd mirroring +# Optional. Default is undef class ceph::profile::params ( @@ -211,6 +214,7 @@ class ceph::profile::params ( $rgw_keystone_admin_project = undef, $rgw_keystone_admin_user = undef, $rgw_keystone_admin_password = undef, + $rbd_mirror_client_name = undef, ) { validate_hash($client_keys) diff --git a/manifests/profile/rgw.pp b/manifests/profile/rgw.pp index 4bc45493..90bdd9ef 100644 --- a/manifests/profile/rgw.pp +++ b/manifests/profile/rgw.pp @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# Author: Keith Schincke +# Author: Keith Schincke # # == Class: ceph::profile::rgw # diff --git a/manifests/rgw/civetweb.pp b/manifests/rgw/civetweb.pp index 29403860..b29281d8 100644 --- a/manifests/rgw/civetweb.pp +++ b/manifests/rgw/civetweb.pp @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -# Author: Keith Schincke +# Author: Keith Schincke # # Configures a ceph radosgw using civetweb. # diff --git a/releasenotes/notes/rbd-mirror-e8c13699bb0e71d8.yaml b/releasenotes/notes/rbd-mirror-e8c13699bb0e71d8.yaml new file mode 100644 index 00000000..e5faea1f --- /dev/null +++ b/releasenotes/notes/rbd-mirror-e8c13699bb0e71d8.yaml @@ -0,0 +1,7 @@ +--- +features: + - Adds support for the rbd-mirror service including + package inistallation, service enable and service + start. Does not include support for generating the + client see as ceph::key or other processes creates + this key diff --git a/spec/defines/ceph_rbd_mirror_spec.rb b/spec/defines/ceph_rbd_mirror_spec.rb new file mode 100644 index 00000000..30f12849 --- /dev/null +++ b/spec/defines/ceph_rbd_mirror_spec.rb @@ -0,0 +1,64 @@ +# Copyright (C) 2016 Keith Schincke +# +# 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: Keith Schincke +# +require 'spec_helper' + +describe 'ceph::mirror' do + + context 'Ubuntu 16.04' do + + let :facts do + { + :osfamily => 'Debian', + :operatingsystem => 'Ubuntu', + :operatingsystemrelease => '16.04', + :service_provider => 'systemd', + } + end + + describe 'with default params' do + let :title do + 'A' + end + + it { is_expected.to contain_service('ceph-rbd-mirror@A').with('ensure' => 'running') } + + end + end + + context 'RHEL 7' do + + let :facts do + { + :osfamily => 'RedHat', + :operatingsystem => 'RedHat', + :operatingsystemrelease => '7.2', + :operatingsystemmajrelease => '7', + :service_provider => 'systemd', + } + end + + describe 'with default params' do + + let :title do + 'A' + end + + it { is_expected.to contain_service('ceph-rbd-mirror@A').with('ensure' => 'running') } + + end + end +end