Add designate::db::postgresql class.

This allows Designate to be used with PostgreSQL.

Change-Id: Ief63f88ba323e3f20300b8ff6a5148a78413ac3d
This commit is contained in:
Christian Rohmann 2021-03-17 11:34:27 +01:00
parent 7bd9ed7e4f
commit 747701570d
3 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,49 @@
# == Class: designate::db::postgresql
#
# Class that configures postgresql for designate
# Requires the Puppetlabs postgresql module.
#
# === Parameters
#
# [*password*]
# (Required) Password to connect to the database.
#
# [*dbname*]
# (Optional) Name of the database.
# Defaults to 'designate'.
#
# [*user*]
# (Optional) User to connect to the database.
# Defaults to 'designate'.
#
# [*encoding*]
# (Optional) The charset to use for the database.
# Default to undef.
#
# [*privileges*]
# (Optional) Privileges given to the database user.
# Default to 'ALL'
#
class designate::db::postgresql(
$password,
$dbname = 'designate',
$user = 'designate',
$encoding = undef,
$privileges = 'ALL',
) {
include designate::deps
::openstacklib::db::postgresql { 'designate':
password => $password,
dbname => $dbname,
user => $user,
encoding => $encoding,
privileges => $privileges,
}
Anchor['designate::db::begin']
~> Class['designate::db::postgresql']
~> Anchor['designate::db::end']
}

View File

@ -0,0 +1,4 @@
---
features:
- |
Add support for PostgreSQL database backend via designate::db::postgresql

View File

@ -0,0 +1,45 @@
require 'spec_helper'
describe 'designate::db::postgresql' do
shared_examples 'designate::db::postgresql' do
let :req_params do
{ :password => 'pw' }
end
let :pre_condition do
'include postgresql::server'
end
context 'with only required parameters' do
let :params do
req_params
end
it { is_expected.to contain_class('designate::deps') }
it { should contain_openstacklib__db__postgresql('designate').with(
:password => 'pw',
:dbname => 'designate',
:user => 'designate',
:encoding => nil,
:privileges => 'ALL',
)}
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({
:os_workers => 8,
:concat_basedir => '/var/lib/puppet/concat'
}))
end
it_configures 'designate::db::postgresql'
end
end
end