This add the cname_lookup middleware for swift proxy.

This commit add the manifest to install and use the cname_lookup
middleware for swift proxy pipeline.

It includes the cname_lookup middleware parameters available in
swift-proxy configuration file.
It also install the required dependency python-dnspython.

Change-Id: If68511fb97bae688e0201fb32928acc9cf68cafc
This commit is contained in:
Simeon Gourlin 2021-03-16 17:18:55 +01:00 committed by Takashi Kajinami
parent e2b35f10a4
commit fe039b7a04
4 changed files with 161 additions and 2 deletions

View File

@ -6,8 +6,9 @@ class swift::params {
include openstacklib::defaults
$pyvers = $::openstacklib::defaults::pyvers
$client_package = "python${pyvers}-swiftclient"
$service_provider = undef
$client_package = "python${pyvers}-swiftclient"
$dnspython_pakage_name = "python${pyvers}-dnspython"
$service_provider = undef
case $::osfamily {
'Debian': {

View File

@ -0,0 +1,80 @@
# == Class: swift::proxy::cname_lookup
#
# Configure CNAME Lookup middleware for swift
#
# === Parameters
#
# [*log_name*]
# The log name of cname_lookup.
# Default to $::os_service_default
#
# [*log_facility*]
# The log facility of cname_lookup.
# Default to $::os_service_default
#
# [*log_level*]
# The log level of cname_lookup.
# Default to $::os_service_default
#
# [*log_headers*]
# The log headers of cname_lookup.
# Default to $::os_service_default
#
# [*log_address*]
# The log address of cname_lookup.
# Default to $::os_service_default
#
# [*storage_domain*]
# Specify the storage_domain that match your cloud, multiple domains
# can be specified separated by a comma.
# Default to $::os_service_default
#
# [*lookup_depth*]
# Because CNAMES can be recursive, specifies the number of levels
# through which to search.
# Default to $::os_service_default
#
# [*nameservers*]
# Specify the nameservers to use to do the CNAME resolution. If unset, the
# system configuration is used. Multiple nameservers can be specified
# separated by a comma. Default port 53 can be overridden. IPv6 is accepted.
# Example: 127.0.0.1, 127.0.0.2, 127.0.0.3:5353, [::1], [::1]:5353
# Default to $::os_service_default
#
#
class swift::proxy::cname_lookup(
$log_name = $::os_service_default,
$log_facility = $::os_service_default,
$log_level = $::os_service_default,
$log_headers = $::os_service_default,
$log_address = $::os_service_default,
$storage_domain = $::os_service_default,
$lookup_depth = $::os_service_default,
$nameservers = $::os_service_default,
) {
include swift::deps
include swift::params
if defined(Service['swift-proxy-server']) {
Package['python3-dnspython'] -> Service['swift-proxy-server']
}
swift_proxy_config {
'filter:cname_lookup/use': value => 'egg:swift#cname_lookup';
'filter:cname_lookup/set log_name': value => $log_name;
'filter:cname_lookup/set log_facility': value => $log_facility;
'filter:cname_lookup/set log_level': value => $log_level;
'filter:cname_lookup/set log_headers': value => $log_headers;
'filter:cname_lookup/set log_address': value => $log_address;
'filter:cname_lookup/storage_domain' : value => $storage_domain;
'filter:cname_lookup/lookup_depth' : value => $lookup_depth;
'filter:cname_lookup/nameservers' : value => $nameservers;
}
package { 'python-dnspython':
ensure => 'present',
name => $::swift::params::dnspython_pakage_name,
tag => ['openstack', 'swift-support-package'],
}
}

View File

@ -0,0 +1,4 @@
---
features:
- |
Support for the cname_lookup middlehware has been added.

View File

@ -0,0 +1,74 @@
require 'spec_helper'
describe 'swift::proxy::cname_lookup' do
shared_examples 'swift::proxy::cname_lookup' do
describe "when using default parameters" do
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/set log_name').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/set log_facility').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/set log_level').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/set log_headers').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/set log_address').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/storage_domain').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/lookup_depth').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/nameservers').with_value('<SERVICE DEFAULT>') }
it { is_expected.to contain_package('python-dnspython').with(
:name => platform_params[:dnspython_package_name],
:ensure => 'present',
:tag => ['openstack','swift-support-package'],
) }
end
describe "when overriding default parameters" do
let :params do
{
:log_name => 'newcname_lookup',
:log_facility => 'LOG_LOCAL3',
:log_level => 'WARN',
:log_headers => 'True',
:log_address => '/var/log',
:storage_domain => 'example.com',
:lookup_depth => '2',
:nameservers => '8.8.8.8',
}
end
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/set log_name').with_value('newcname_lookup') }
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/set log_facility').with_value('LOG_LOCAL3') }
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/set log_level').with_value('WARN') }
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/set log_headers').with_value('True') }
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/set log_address').with_value('/var/log') }
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/storage_domain').with_value('example.com') }
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/lookup_depth').with_value('2') }
it { is_expected.to contain_swift_proxy_config('filter:cname_lookup/nameservers').with_value('8.8.8.8') }
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())
end
let(:platform_params) do
case facts[:osfamily]
when 'Debian'
{ :dnspython_package_name => 'python3-dnspython' }
when 'RedHat'
if facts[:operatingsystem] == 'Fedora'
{ :dnspython_package_name => 'python3-dnspython' }
else
if facts[:operatingsystemmajrelease] > '7'
{ :dnspython_package_name => 'python3-dnspython' }
else
{ :dnspython_package_name => 'python-dnspython' }
end
end
end
end
it_configures 'swift::proxy::cname_lookup'
end
end
end