Add support for cinder-backup GCS and S3 backends

This patch adds these new classes:
- tripleo::profile::base::cinder::backup::gcs
- tripleo::profile::base::cinder::backup::s3

Depends-On: I7fd2c745480086571d02b89d4adbaa02213a94fa
Change-Id: I06857dd2fb64071ea734a0d3ef68ada5e5d2c077
This commit is contained in:
Alan Bishop 2021-03-23 08:07:35 -07:00
parent dbe34c4b53
commit c06f6f3f1e
6 changed files with 245 additions and 0 deletions

View File

@ -0,0 +1,56 @@
# Copyright 2021 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.
#
# == Class: tripleo::profile::base::cinder::backup::gcs
#
# Cinder Backup Google Cloud Service (GCS) profile for tripleo
#
# === Parameters
#
# [*credentials*]
# (required) The GCS service account credentials, in JSON format.
#
# [*credential_file*]
# (Optional) Absolute path of GCS service account credential file, to
# be created with content from the credentials input.
# Defaults to '/etc/cinder/gcs-backup.json'
#
# [*step*]
# (Optional) The current step in deployment. See tripleo-heat-templates
# for more details.
# Defaults to hiera('step')
#
class tripleo::profile::base::cinder::backup::gcs (
$credentials,
$credential_file = '/etc/cinder/gcs-backup.json',
$step = Integer(hiera('step')),
) {
include tripleo::profile::base::cinder::backup
if $step >= 4 {
file { "${credential_file}" :
ensure => file,
content => to_json_pretty($credentials),
owner => 'root',
group => 'cinder',
mode => '0640',
}
class { 'cinder::backup::google':
backup_gcs_credential_file => $credential_file,
}
}
}

View File

@ -0,0 +1,36 @@
# Copyright 2021 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.
#
# == Class: tripleo::profile::base::cinder::backup::s3
#
# Cinder Backup S3 profile for tripleo
#
# === Parameters
#
# [*step*]
# (Optional) The current step in deployment. See tripleo-heat-templates
# for more details.
# Defaults to hiera('step')
#
class tripleo::profile::base::cinder::backup::s3 (
$step = Integer(hiera('step')),
) {
include tripleo::profile::base::cinder::backup
if $step >= 4 {
include cinder::backup::s3
}
}

View File

@ -0,0 +1,7 @@
---
features:
- |
New ``tripleo::profile::base::cinder::backup::gcs`` and
``tripleo::profile::base::cinder::backup::s3`` classes add support for
configuring the cinder backup service's GCS (Google Cloud service) and
Amazon S3 backends.

View File

@ -0,0 +1,84 @@
#
# Copyright (C) 2021 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'
# The JSON expected results for params[:credentials]
gcs_json_credentials = <<HEREDOC
{
"opt_1": "val_1",
"opt_2": "val_2"
}
HEREDOC
describe 'tripleo::profile::base::cinder::backup::gcs' do
let :params do
{
:credentials => { 'opt_1' => 'val_1', 'opt_2' => 'val_2', },
:credential_file => 'my-gcs-backup.json',
}
end
shared_examples_for 'tripleo::profile::base::cinder::backup::gcs' do
let(:pre_condition) do
<<-EOF
class { 'tripleo::profile::base::cinder': step => #{params[:step]}, oslomsg_rpc_hosts => ['127.0.0.1'] }
class { 'tripleo::profile::base::cinder::backup': step => #{params[:step]} }
EOF
end
context 'with step less than 4' do
before do
params.merge!({ :step => 3 })
end
it 'should do nothing' do
is_expected.to contain_class('tripleo::profile::base::cinder::backup::gcs')
is_expected.to contain_class('tripleo::profile::base::cinder::backup')
is_expected.to_not contain_class('cinder::backup::google')
end
end
context 'with step 4' do
before do
params.merge!({ :step => 4 })
end
it 'should trigger complete configuration' do
is_expected.to contain_file("#{params[:credential_file]}").with(
:content => gcs_json_credentials,
:owner => 'root',
:group => 'cinder',
:mode => '0640',
)
is_expected.to contain_class('cinder::backup::google').with(
:backup_gcs_credential_file => "#{params[:credential_file]}",
)
end
end
end
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge({ :hostname => 'node.example.com' })
end
it_behaves_like 'tripleo::profile::base::cinder::backup::gcs'
end
end
end

View File

@ -0,0 +1,59 @@
#
# Copyright (C) 2021 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 'tripleo::profile::base::cinder::backup::s3' do
shared_examples_for 'tripleo::profile::base::cinder::backup::s3' do
let(:pre_condition) do
<<-EOF
class { 'tripleo::profile::base::cinder': step => #{params[:step]}, oslomsg_rpc_hosts => ['127.0.0.1'] }
class { 'tripleo::profile::base::cinder::backup': step => #{params[:step]} }
EOF
end
context 'with step less than 4' do
let(:params) { { :step => 3 } }
it 'should do nothing' do
is_expected.to contain_class('tripleo::profile::base::cinder::backup::s3')
is_expected.to contain_class('tripleo::profile::base::cinder::backup')
is_expected.to_not contain_class('cinder::backup::s3')
end
end
context 'with step 4' do
let(:params) { {
:step => 4,
} }
it 'should trigger complete configuration' do
is_expected.to contain_class('cinder::backup::s3')
end
end
end
on_supported_os.each do |os, facts|
context "on #{os}" do
let(:facts) do
facts.merge({ :hostname => 'node.example.com' })
end
it_behaves_like 'tripleo::profile::base::cinder::backup::s3'
end
end
end

View File

@ -36,6 +36,9 @@ cinder_volume_short_node_names:
- 'node.example.com'
- 'c-vol-2'
cinder::backup::nfs::backup_share: '/mnt/backup'
cinder::backup::s3::backup_s3_endpoint_url: 'http://my.s3.server'
cinder::backup::s3::backup_s3_store_access_key: 1234
cinder::backup::s3::backup_s3_store_secret_key: 5678
cinder::rabbit_password: 'password'
cinder::keystone::authtoken::password: 'password'
# designate related items