Add support for independent designate-dashboard configurations
This change introduces the new horizon::dashboards::designate class, which allows users to manage the independent configuration file for designate dashboard (_1799_dns_settings.py). Depends-on: https://review.opendev.org/823238 Change-Id: Ie36d70b7b9fdde5f1ceb4be59cfb4f5c16981e7d
This commit is contained in:
parent
49a20369cb
commit
7577a23c65
@ -37,7 +37,7 @@ define horizon::dashboard (
|
|||||||
|
|
||||||
$dashboard = downcase($name)
|
$dashboard = downcase($name)
|
||||||
|
|
||||||
if $dashboard in ['heat', 'octavia', 'manila'] {
|
if $dashboard in ['designate', 'heat', 'octavia', 'manila'] {
|
||||||
warning("Use the horizon::dashboard::${dashboard} class instead. \
|
warning("Use the horizon::dashboard::${dashboard} class instead. \
|
||||||
The class allows more flexible customization of the ${dashboard} dashboard.")
|
The class allows more flexible customization of the ${dashboard} dashboard.")
|
||||||
}
|
}
|
||||||
|
88
manifests/dashboards/designate.pp
Normal file
88
manifests/dashboards/designate.pp
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
#
|
||||||
|
# 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: horizon::dashboards::designate
|
||||||
|
#
|
||||||
|
# Manage parameters of designate-dashboard
|
||||||
|
#
|
||||||
|
# === Parameters:
|
||||||
|
#
|
||||||
|
# [*policy_file*]
|
||||||
|
# (optional) Local copy of service policy files.
|
||||||
|
# Defaults to 'designate_policy.yaml'
|
||||||
|
#
|
||||||
|
# [*policies*]
|
||||||
|
# (optional) Set of policies to configure.
|
||||||
|
# Defaults to undef
|
||||||
|
#
|
||||||
|
class horizon::dashboards::designate(
|
||||||
|
$policy_file = 'designate_policy.yaml',
|
||||||
|
$policies = undef,
|
||||||
|
) {
|
||||||
|
|
||||||
|
include horizon::deps
|
||||||
|
include horizon::params
|
||||||
|
|
||||||
|
# The horizon class should be included so that some common parameters
|
||||||
|
# can be picked here.
|
||||||
|
if ! defined(Class[horizon]) {
|
||||||
|
fail('The horizon class should be included before the horizon::dashboards::designate class')
|
||||||
|
}
|
||||||
|
|
||||||
|
$log_handlers = $::horizon::log_handlers
|
||||||
|
$log_level = $::horizon::log_level
|
||||||
|
$policy_files = $::horizon::policy_files
|
||||||
|
|
||||||
|
if $policy_files and $policy_files['load-balancer'] {
|
||||||
|
$policy_file_real = $policy_files['load-balancer']
|
||||||
|
} else {
|
||||||
|
$policy_file_real = $policy_file
|
||||||
|
}
|
||||||
|
|
||||||
|
$config_file = "${::horizon::params::conf_d_dir}/_1799_dns_settings.py"
|
||||||
|
|
||||||
|
package { 'designate-dashboard':
|
||||||
|
ensure => $::horizon::package_ensure,
|
||||||
|
name => $::horizon::params::designate_dashboard_package_name,
|
||||||
|
tag => ['openstack', 'horizon-package'],
|
||||||
|
}
|
||||||
|
|
||||||
|
concat { $config_file:
|
||||||
|
mode => '0640',
|
||||||
|
owner => $::horizon::params::wsgi_user,
|
||||||
|
group => $::horizon::params::wsgi_group,
|
||||||
|
require => File[$::horizon::params::conf_d_dir],
|
||||||
|
tag => ['django-config'],
|
||||||
|
}
|
||||||
|
|
||||||
|
concat::fragment { '_1799_dns_settings.py':
|
||||||
|
target => $config_file,
|
||||||
|
content => template('horizon/_1799_dns_settings.py.erb'),
|
||||||
|
order => '50',
|
||||||
|
}
|
||||||
|
|
||||||
|
if $policies != undef {
|
||||||
|
# The horizon::policy class should be included so that some common
|
||||||
|
# parameters about policy management can be picked here
|
||||||
|
if !defined(Class[horizon::policy]){
|
||||||
|
fail('The horizon::policy class should be include in advance to customize policies')
|
||||||
|
}
|
||||||
|
|
||||||
|
horizon::policy::base { $policy_file_real:
|
||||||
|
policies => $policies,
|
||||||
|
file_mode => $::horizon::policy::file_mode,
|
||||||
|
file_format => $::horizon::policy::file_format,
|
||||||
|
purge_config => $::horizon::policy::purge_config,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,36 +10,38 @@ class horizon::params {
|
|||||||
|
|
||||||
case $::osfamily {
|
case $::osfamily {
|
||||||
'RedHat': {
|
'RedHat': {
|
||||||
$package_name = 'openstack-dashboard'
|
$package_name = 'openstack-dashboard'
|
||||||
$config_dir = '/etc/openstack-dashboard'
|
$config_dir = '/etc/openstack-dashboard'
|
||||||
$conf_d_dir = '/etc/openstack-dashboard/local_settings.d'
|
$conf_d_dir = '/etc/openstack-dashboard/local_settings.d'
|
||||||
$config_file = '/etc/openstack-dashboard/local_settings'
|
$config_file = '/etc/openstack-dashboard/local_settings'
|
||||||
$policy_dir = '/etc/openstack-dashboard'
|
$policy_dir = '/etc/openstack-dashboard'
|
||||||
$httpd_config_file = '/etc/httpd/conf.d/openstack-dashboard.conf'
|
$httpd_config_file = '/etc/httpd/conf.d/openstack-dashboard.conf'
|
||||||
$httpd_listen_config_file = '/etc/httpd/conf/httpd.conf'
|
$httpd_listen_config_file = '/etc/httpd/conf/httpd.conf'
|
||||||
$root_url = '/dashboard'
|
$root_url = '/dashboard'
|
||||||
$static_path = '/usr/share'
|
$static_path = '/usr/share'
|
||||||
$wsgi_user = 'apache'
|
$wsgi_user = 'apache'
|
||||||
$wsgi_group = 'apache'
|
$wsgi_group = 'apache'
|
||||||
$memcache_package = 'python3-memcached'
|
$memcache_package = 'python3-memcached'
|
||||||
$heat_dashboard_package_name = 'openstack-heat-ui'
|
$designate_dashboard_package_name = 'openstack-designate-ui'
|
||||||
$manila_dashboard_package_name = 'openstack-manila-ui'
|
$heat_dashboard_package_name = 'openstack-heat-ui'
|
||||||
$octavia_dashboard_package_name = 'openstack-octavia-ui'
|
$manila_dashboard_package_name = 'openstack-manila-ui'
|
||||||
|
$octavia_dashboard_package_name = 'openstack-octavia-ui'
|
||||||
}
|
}
|
||||||
'Debian': {
|
'Debian': {
|
||||||
$config_dir = '/etc/openstack-dashboard'
|
$config_dir = '/etc/openstack-dashboard'
|
||||||
$conf_d_dir = '/etc/openstack-dashboard/local_settings.d'
|
$conf_d_dir = '/etc/openstack-dashboard/local_settings.d'
|
||||||
$config_file = '/etc/openstack-dashboard/local_settings.py'
|
$config_file = '/etc/openstack-dashboard/local_settings.py'
|
||||||
$policy_dir = undef
|
$policy_dir = undef
|
||||||
$httpd_listen_config_file = '/etc/apache2/ports.conf'
|
$httpd_listen_config_file = '/etc/apache2/ports.conf'
|
||||||
$root_url = '/horizon'
|
$root_url = '/horizon'
|
||||||
$static_path = '/var/lib'
|
$static_path = '/var/lib'
|
||||||
$wsgi_user = 'horizon'
|
$wsgi_user = 'horizon'
|
||||||
$wsgi_group = 'horizon'
|
$wsgi_group = 'horizon'
|
||||||
$memcache_package = 'python3-memcache'
|
$memcache_package = 'python3-memcache'
|
||||||
$heat_dashboard_package_name = 'python3-heat-dashboard'
|
$designate_dashboard_package_name = 'python3-designate-dashboard'
|
||||||
$manila_dashboard_package_name = 'python3-manila-dashboard'
|
$heat_dashboard_package_name = 'python3-heat-dashboard'
|
||||||
$octavia_dashboard_package_name = 'python3-octavia-dashboard'
|
$manila_dashboard_package_name = 'python3-manila-dashboard'
|
||||||
|
$octavia_dashboard_package_name = 'python3-octavia-dashboard'
|
||||||
case $::operatingsystem {
|
case $::operatingsystem {
|
||||||
'Debian': {
|
'Debian': {
|
||||||
$package_name = 'openstack-dashboard-apache'
|
$package_name = 'openstack-dashboard-apache'
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
The new ``horizon::dashboards::designate`` class has been added. This class
|
||||||
|
can be used to manage parameters for designate-dashboard.
|
109
spec/classes/horizon_dashboards_designate_spec.rb
Normal file
109
spec/classes/horizon_dashboards_designate_spec.rb
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'horizon::dashboards::designate' do
|
||||||
|
|
||||||
|
let :params do
|
||||||
|
{}
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples_for 'horizon::dashboards::designate' do
|
||||||
|
|
||||||
|
context 'with default parameters' do
|
||||||
|
let(:pre_condition) do
|
||||||
|
<<-eos
|
||||||
|
class { 'horizon':
|
||||||
|
secret_key => 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0',
|
||||||
|
}
|
||||||
|
eos
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'installs designate-dashboard package' do
|
||||||
|
is_expected.to contain_package('designate-dashboard').with(
|
||||||
|
:ensure => 'present',
|
||||||
|
:name => platform_params[:designate_dashboard_package_name],
|
||||||
|
:tag => ['openstack', 'horizon-package']
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'generates _1799_dns_settings.py' do
|
||||||
|
verify_concat_fragment_contents(catalogue, '_1799_dns_settings.py', [
|
||||||
|
"settings.POLICY_FILES.update({",
|
||||||
|
" 'dns': 'designate_policy.yaml',",
|
||||||
|
"})"
|
||||||
|
])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'without the horizon class defined' do
|
||||||
|
it { should raise_error(Puppet::Error) }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with policy customization' do
|
||||||
|
let(:pre_condition) do
|
||||||
|
<<-eos
|
||||||
|
class { 'horizon':
|
||||||
|
secret_key => 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0',
|
||||||
|
policy_files_path => '/etc/openstack-dashboard',
|
||||||
|
}
|
||||||
|
class { 'horizon::policy': }
|
||||||
|
eos
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
params.merge!({
|
||||||
|
:policies => {}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configures policy' do
|
||||||
|
is_expected.to contain_horizon__policy__base('designate_policy.yaml').with(
|
||||||
|
:policies => {},
|
||||||
|
:file_mode => '0640',
|
||||||
|
:file_format => 'yaml',
|
||||||
|
:purge_config => false,
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with policy customization but without the horizon::policy class' do
|
||||||
|
let(:pre_condition) do
|
||||||
|
<<-eos
|
||||||
|
class { 'horizon':
|
||||||
|
secret_key => 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0',
|
||||||
|
policy_files_path => '/etc/openstack-dashboard',
|
||||||
|
}
|
||||||
|
eos
|
||||||
|
end
|
||||||
|
|
||||||
|
before do
|
||||||
|
params.merge!({
|
||||||
|
:policies => {}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
it { should raise_error(Puppet::Error) }
|
||||||
|
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'
|
||||||
|
{ :designate_dashboard_package_name => 'python3-designate-dashboard' }
|
||||||
|
when 'RedHat'
|
||||||
|
{ :designate_dashboard_package_name => 'openstack-designate-ui' }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'horizon::dashboards::designate'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
10
templates/_1799_dns_settings.py.erb
Normal file
10
templates/_1799_dns_settings.py.erb
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
|
settings.POLICY_FILES.update({
|
||||||
|
'dns': '<%= @policy_file_real %>',
|
||||||
|
})
|
||||||
|
|
||||||
|
settings.DEFAULT_POLICY_FILES.update({
|
||||||
|
'dns': 'default_policies/designate.yaml',
|
||||||
|
})
|
Loading…
Reference in New Issue
Block a user