Added Designate Pool Manager

Added classes and defines to manage the Designate Pool Manager.

Change-Id: I52c3789394bc8719c4251abd13e489b47111f0f4
This commit is contained in:
Arnoud de Jonge 2016-01-29 10:15:58 +00:00
parent c2220c928b
commit d3df6fdfd9
13 changed files with 799 additions and 24 deletions

View File

@ -12,35 +12,39 @@ class designate::params {
case $::osfamily {
'RedHat': {
# package name
$common_package_name = 'openstack-designate'
$api_package_name = 'openstack-designate-api'
$central_package_name = 'openstack-designate-central'
$agent_package_name = 'openstack-designate-agent'
$sink_package_name = 'openstack-designate-sink'
$mdns_package_name = 'openstack-designate-mdns'
$common_package_name = 'openstack-designate'
$api_package_name = 'openstack-designate-api'
$central_package_name = 'openstack-designate-central'
$agent_package_name = 'openstack-designate-agent'
$sink_package_name = 'openstack-designate-sink'
$pymysql_package_name = undef
$mdns_package_name = 'openstack-designate-mdns'
$pool_manager_package_name = 'openstack-designate-pool-manager'
# service names
$agent_service_name = 'openstack-designate-agent'
$api_service_name = 'openstack-designate-api'
$central_service_name = 'openstack-designate-central'
$sink_service_name = 'openstack-designate-sink'
$pymysql_package_name = undef
$mdns_service_name = 'openstack-designate-mdns'
$agent_service_name = 'openstack-designate-agent'
$api_service_name = 'openstack-designate-api'
$central_service_name = 'openstack-designate-central'
$sink_service_name = 'openstack-designate-sink'
$mdns_service_name = 'openstack-designate-mdns'
$pool_manager_service_name = 'openstack-designate-pool-manager'
}
'Debian': {
# package name
$common_package_name = 'designate-common'
$api_package_name = 'designate-api'
$central_package_name = 'designate-central'
$agent_package_name = 'designate-agent'
$sink_package_name = 'designate-sink'
$mdns_package_name = 'designate-mdns'
$common_package_name = 'designate-common'
$api_package_name = 'designate-api'
$central_package_name = 'designate-central'
$agent_package_name = 'designate-agent'
$sink_package_name = 'designate-sink'
$pymysql_package_name = 'python-pymysql'
$pool_manager_package_name = 'openstack-designate-pool-manager'
$mdns_package_name = 'designate-mdns'
# service names
$agent_service_name = 'designate-agent'
$api_service_name = 'designate-api'
$central_service_name = 'designate-central'
$sink_service_name = 'designate-sink'
$pymysql_package_name = 'python-pymysql'
$mdns_service_name = 'designate-mdns'
$agent_service_name = 'designate-agent'
$api_service_name = 'designate-api'
$central_service_name = 'designate-central'
$sink_service_name = 'designate-sink'
$mdns_service_name = 'designate-mdns'
$pool_manager_service_name = 'designate-pool-manager'
}
default: {
fail("Unsupported osfamily: ${::osfamily} operatingsystem")

32
manifests/pool.pp Normal file
View File

@ -0,0 +1,32 @@
# == Define: designate::pool
#
# Define a pool.
#
# === Parameters
#
# [*nameservers*]
# An array of UUID's of the nameservers in this pool
#
# [*targets*]
# An array of UUID's of the targets in this pool
#
# [*also_notifies*]
# (optional) List of hostnames and port numbers to also notify on zone changes.
#
define designate::pool(
$nameservers,
$targets,
$also_notifies = [],
){
validate_re($name, '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',
'Pool name should be a UUID.')
validate_array($nameservers)
validate_array($targets)
validate_array($also_notifies)
designate_config {
"pool:${name}/nameservers": value => join($nameservers,',');
"pool:${name}/targets": value => join($targets,',');
"pool:${name}/also-notifies": value => join($also_notifies,',');
}
}

149
manifests/pool_manager.pp Normal file
View File

@ -0,0 +1,149 @@
# == Class: designate::pool_manager
#
# Configure designate pool manager service
#
# == Parameters
#
# [*pool_id*]
# UUID of the pool to use.
#
# [*package_ensure*]
# (optional) The state of the package
# Defaults to 'present'
#
# [*manage_package*]
# Whether Puppet should manage the package. Default is true.
#
# [*pool_manager_package_name*]
# (optional) Name of the package containing pool manager
# resources. Defaults to pool_manager_package_name from
# designate::params
#
# [*enabled*]
# (optional) Whether to enable services.
# Defaults to true
#
# [*service_ensure*]
# (optional) Whether the designate pool manager service will
# be running.
# Defaults to 'running'
#
# [*workers*]
# (optional) Number of worker processes.
# Defaults to $::os_service_default
#
# [*threads*]
# (optional) Number of Pool Manager greenthreads to spawn
# Defaults to $::os_service_default
#
# [*threshold_percentage*]
# (optional) Threshold percentage.
# Defaults to $::os_service_default
#
# [*poll_timeout*]
# (optional) Poll timeout.
# Defaults to $::os_service_default
#
# [*poll_retry_interval*]
# (optional) Poll retry interval.
# Defaults to $::os_service_default
#
# [*poll_max_retries*]
# (optional) Poll max retries.
# Defaults to $::os_service_default
#
# [*poll_delay*]
# (optional) Poll delay.
# Defaults to $::os_service_default
#
# [*enable_recovery_timer*]
# (optional) Enable the recovery thread
# Defaults to $::os_service_default
#
# [*periodic_recovery_interval*]
# (optional) Periodic recovery interval.
# Defaults to $::os_service_default
#
# [*enable_sync_timer*]
# (optional) Enable the sync thread
# Defaults to $::os_service_default
#
# [*periodic_sync_interval*]
# (optional) Periodic sync interval.
# Defaults to $::os_service_default
#
# [*periodic_sync_seconds*]
# (optional) Periodic sync seconds.
# Defaults to $::os_service_default
#
# [*periodic_sync_max_attempts*]
# (optional) Zones Updated within last N seconds will be syncd. Use None to sync all zones
# Defaults to $::os_service_default
#
# [*periodic_sync_retry_interval*]
# (optional) Perform multiple update attempts during periodic_sync
# Defaults to $::os_service_default
#
class designate::pool_manager(
$pool_id,
$manage_package = true,
$package_ensure = present,
$pool_manager_package_name = undef,
$enabled = true,
$service_ensure = 'running',
$workers = $::os_service_default,
$threads = $::os_service_default,
$threshold_percentage = $::os_service_default,
$poll_timeout = $::os_service_default,
$poll_retry_interval = $::os_service_default,
$poll_max_retries = $::os_service_default,
$poll_delay = $::os_service_default,
$enable_recovery_timer = $::os_service_default,
$periodic_recovery_interval = $::os_service_default,
$enable_sync_timer = $::os_service_default,
$periodic_sync_interval = $::os_service_default,
$periodic_sync_seconds = $::os_service_default,
$periodic_sync_max_attempts = $::os_service_default,
$periodic_sync_retry_interval = $::os_service_default,
) {
include ::designate::params
if $pool_id !~ /^[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}$/ {
fail('pool_id should be a valid UUID')
}
if $manage_package {
package { 'designate-pool-manager':
ensure => $package_ensure,
name => pick($pool_manager_package_name, $::designate::params::pool_manager_service_name),
tag => ['openstack', 'designate-package'],
}
}
service { 'designate-pool-manager':
ensure => $service_ensure,
name => $::designate::params::pool_manager_service_name,
enable => $enabled,
hasstatus => true,
hasrestart => true,
tag => ['openstack', 'designate-service'],
}
designate_config {
'service:pool_manager/pool_id': value => $pool_id;
'service:pool_manager/workers': value => $workers;
'service:pool_manager/threads': value => $threads;
'service:pool_manager/threshold_percentage': value => $threshold_percentage;
'service:pool_manager/poll_timeout': value => $poll_timeout;
'service:pool_manager/poll_retry_interval': value => $poll_retry_interval;
'service:pool_manager/poll_max_retries': value => $poll_max_retries;
'service:pool_manager/poll_delay': value => $poll_delay;
'service:pool_manager/periodic_recovery_interval': value => $periodic_recovery_interval;
'service:pool_manager/periodic_sync_interval': value => $periodic_sync_interval;
'service:pool_manager/periodic_sync_seconds': value => $periodic_sync_seconds;
'service:pool_manager/enable_recovery_timer': value => $enable_recovery_timer;
'service:pool_manager/enable_sync_timer': value => $enable_sync_timer;
'service:pool_manager/periodic_sync_max_attempts': value => $periodic_sync_max_attempts;
'service:pool_manager/periodic_sync_retry_interval': value => $periodic_sync_retry_interval;
}
}

View File

@ -0,0 +1,26 @@
# == Class: designate::pool_manager_cache::memcache
#
# Configure Memcache as caching service for the pool manager.
#
# == Parameters
#
# [*memcached_servers*]
# (optional) Memcache servers.
# Defaults to ['127.0.0.1']
#
# [*expiration*]
# Cache expiration time.
# Defaults to $::os_service_default
#
class designate::pool_manager_cache::memcache(
$memcached_servers = ['127.0.0.1'],
$expiration = $::os_service_default,
){
validate_array($memcached_servers)
designate_config {
'service:pool_manager/cache_driver': value => 'memcache';
'pool_manager_cache:memcache/memcached_servers': value => join($memcached_servers,',');
'pool_manager_cache:memcache/expiration': value => $expiration;
}
}

View File

@ -0,0 +1,53 @@
# Class: designate::pool_manager_cache::sqlalchemy
#
# === Parameters
#
# [*connection*]
# Connection string for SQLAlchemy. For instance:
# sqlite:///$state_path/designate_pool_manager.sqlite
# Defaults to $::os_service_default
#
# [*connection_debug*]
# Wether to show debug information for SQLAlchemy.
# Defaults to $::os_service_default
#
# [*connection_trace*]
# Wether to show traces in SQLAlchemy.
# Defaults to $::os_service_default
#
# [*sqlite_synchronous*]
# Wether or not to enable synchronous queries in SQLite.
# Defaults to $::os_service_default
#
# [*idle_timeout*]
# (optional) Set idle timeout.
# Defaults to $::os_service_default
#
# [*max_retries*]
# (optional) Set max retries.
# Defaults to $::os_service_default
#
# [*retry_interval*]
# (optional) Set retry interval.
# Defaults to $::os_service_default
#
class designate::pool_manager_cache::sqlalchemy(
$connection = $::os_service_default,
$connection_debug = $::os_service_default,
$connection_trace = $::os_service_default,
$sqlite_synchronous = $::os_service_default,
$idle_timeout = $::os_service_default,
$max_retries = $::os_service_default,
$retry_interval = $::os_service_default,
){
designate_config {
'service:pool_manager/cache_driver': value => 'sqlalchemy';
'pool_manager_cache:sqlalchemy/connection': value => $connection;
'pool_manager_cache:sqlalchemy/connection_debug': value => $connection_debug;
'pool_manager_cache:sqlalchemy/connection_trace': value => $connection_trace;
'pool_manager_cache:sqlalchemy/sqlite_synchronous': value => $sqlite_synchronous;
'pool_manager_cache:sqlalchemy/idle_timeout': value => $idle_timeout;
'pool_manager_cache:sqlalchemy/max_retries': value => $max_retries;
'pool_manager_cache:sqlalchemy/retry_interval': value => $retry_interval;
}
}

View File

@ -0,0 +1,22 @@
# Define: designate::pool_nameserver
#
# === Parameters
#
# [*port*]
# Port number of the DNS server.
#
# [*host*]
# IP address or hostname of the DNS server.
#
define designate::pool_nameserver(
$port = 53,
$host = '127.0.0.1',
){
validate_re($name, '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',
'Name should be a UUID.')
designate_config {
"pool_nameserver:${name}/port": value => $port;
"pool_nameserver:${name}/host": value => $host;
}
}

53
manifests/pool_target.pp Normal file
View File

@ -0,0 +1,53 @@
# == Define: designate::pool_target
#
# Configure a target for the Designate Pool Manager.
#
# == Parameters
#
# [*options*]
# Options to be passed to the backend DNS server. This should include host and
# port. For instance for a bind9
# target this could be:
# rndc_host: 192.168.27.100, rndc_port: 953, rndc_config_file: /etc/bind/rndc.conf, rndc_key_file: /etc/bind/rndc.key, port: 53, host: 192.168.27.100
#
# [*type*]
# Port number of the target DNS server.
#
# [*masters*]
# (optional) IP addresses and ports of the master DNS server. This should point
# to the Designate mDNS servers and ports.
# Defaults to ['127.0.0.1:5354']
#
define designate::pool_target (
$options,
$type,
$masters = ['127.0.0.1:5354'],
) {
if target == 'powerdns' {
include ::powerdns
include ::powerdns::mysql
}
validate_re($name, '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')
validate_array($masters)
designate_config {
"pool_target:${name}/options": value => $options;
"pool_target:${name}/type": value => $type;
"pool_target:${name}/masters": value => join($masters,',');
}
if $type == 'powerdns' {
exec { "designate-powerdns-dbsync ${name}":
command => "${::designate::params::designate_manage} powerdns sync ${name}",
path => '/usr/bin',
user => 'root',
refreshonly => true,
logoutput => on_failure,
}
# Have to have a valid configuration file before running migrations
Designate_config<||> -> Exec["designate-powerdns-dbsync ${name}"]
Exec["designate-powerdns-dbsync ${name}"] ~> Service<| title == 'designate-pool-manager' |>
}
}

View File

@ -0,0 +1,61 @@
#
# Unit tests for designate::pool_manager
#
require 'spec_helper'
describe 'designate::pool_manager_cache::memcache' do
let :params do
{
}
end
shared_examples 'designate-pool-manager-cache-memcache' do
context 'with default parameters' do
it { is_expected.to contain_class('designate::pool_manager_cache::memcache') }
it 'configures designate-pool-manager with required parameters' do
is_expected.to contain_designate_config('service:pool_manager/cache_driver').with_value('memcache')
is_expected.to contain_designate_config('pool_manager_cache:memcache/memcached_servers').with_value(['127.0.0.1'])
is_expected.to contain_designate_config('pool_manager_cache:memcache/expiration').with_value('<SERVICE DEFAULT>')
end
end
context 'with all parameters' do
before do
params.merge!( { :memcached_servers => ['192.168.0.1'], :expiration => 123 } )
end
it { is_expected.to contain_class('designate::pool_manager_cache::memcache') }
it 'configures designate-pool-manager with required parameters' do
is_expected.to contain_designate_config('service:pool_manager/cache_driver').with_value('memcache')
is_expected.to contain_designate_config('pool_manager_cache:memcache/memcached_servers').with_value( params[:memcached_servers] )
is_expected.to contain_designate_config('pool_manager_cache:memcache/expiration').with_value( params[:expiration] )
end
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'
{
:pool_manager_package_name => 'designate-pool-manager',
:pool_manager_service_name => 'designate-pool-manager'
}
when 'RedHat'
{
:pool_manager_package_name => 'openstack-designate-pool-manager',
:pool_manager_service_name => 'openstack-designate-pool-manager'
}
end
end
it_behaves_like 'designate-pool-manager-cache-memcache'
end
end
end

View File

@ -0,0 +1,68 @@
#
# Unit tests for designate::pool_manager_cache::sqlalchemy
#
require 'spec_helper'
describe 'designate::pool_manager_cache::sqlalchemy' do
let :params do
{
}
end
let :params_all do
{
:connection => 'connection = sqlite:///$state_path/designate_pool_manager.sqlite',
:connection_debug => 100,
:connection_trace => true,
:sqlite_synchronous => true,
:idle_timeout => 3600,
:max_retries => 10,
:retry_interval => 10,
}
end
shared_examples 'designate-pool-manager-cache-sqlalchemy' do
context 'with default parameters' do
it { is_expected.to contain_class('designate::pool_manager_cache::sqlalchemy') }
it 'configures designate-pool-manager with required parameters' do
is_expected.to contain_designate_config('service:pool_manager/cache_driver').with_value('sqlalchemy')
is_expected.to contain_designate_config('pool_manager_cache:sqlalchemy/connection').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('pool_manager_cache:sqlalchemy/connection_debug').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('pool_manager_cache:sqlalchemy/connection_trace').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('pool_manager_cache:sqlalchemy/sqlite_synchronous').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('pool_manager_cache:sqlalchemy/idle_timeout').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('pool_manager_cache:sqlalchemy/max_retries').with_value('<SERVICE DEFAULT>')
is_expected.to contain_designate_config('pool_manager_cache:sqlalchemy/retry_interval').with_value('<SERVICE DEFAULT>')
end
end
context 'with all parameters' do
before do
params.merge!( params_all )
end
it 'configures designate-pool-manager with required parameters' do
is_expected.to contain_designate_config('pool_manager_cache:sqlalchemy/connection').with_value( params[:connection] )
is_expected.to contain_designate_config('pool_manager_cache:sqlalchemy/connection_debug').with_value( params[:connection_debug] )
is_expected.to contain_designate_config('pool_manager_cache:sqlalchemy/connection_trace').with_value( params[:connection_trace] )
is_expected.to contain_designate_config('pool_manager_cache:sqlalchemy/sqlite_synchronous').with_value( params[:sqlite_synchronous] )
is_expected.to contain_designate_config('pool_manager_cache:sqlalchemy/idle_timeout').with_value( params[:idle_timeout] )
is_expected.to contain_designate_config('pool_manager_cache:sqlalchemy/max_retries').with_value( params[:max_retries] )
is_expected.to contain_designate_config('pool_manager_cache:sqlalchemy/retry_interval').with_value( params[:retry_interval] )
end
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
it_behaves_like 'designate-pool-manager-cache-sqlalchemy'
end
end
end

View File

@ -0,0 +1,139 @@
#
# Unit tests for designate::pool_manager
#
require 'spec_helper'
describe 'designate::pool_manager' do
let :params do
{
:pool_id => '794ccc2c-d751-44fe-b57f-8894c9f5c842',
}
end
let :params_all do
{
:manage_package => true,
:package_ensure => 'present',
:pool_manager_package_name => nil,
:enabled => true,
:service_ensure => 'running',
:workers => 10,
:threads => 900,
:threshold_percentage => 90,
:poll_timeout => 15,
:poll_retry_interval => 10,
:poll_max_retries => 5,
:poll_delay => 1,
:enable_recovery_timer => false,
:periodic_recovery_interval => 60,
:enable_sync_timer => false,
:periodic_sync_interval => 900,
:periodic_sync_seconds => 5,
:periodic_sync_max_attempts => 1,
:periodic_sync_retry_interval => 15,
}
end
shared_examples 'designate-pool-manager' do
context 'with default parameters' do
it { is_expected.to contain_class('designate::pool_manager') }
it 'installs designate-pool-manager package and service' do
is_expected.to contain_service('designate-pool-manager').with(
:name => platform_params[:pool_manager_service_name],
:ensure => 'running',
:enable => 'true',
:tag => ['openstack', 'designate-service'],
)
is_expected.to contain_package('designate-pool-manager').with(
:name => platform_params[:pool_manager_package_name],
:ensure => 'present',
:tag => ['openstack', 'designate-package'],
)
end
it 'configures designate-pool-manager with default parameters' do
is_expected.to contain_designate_config('service:pool_manager/pool_id').with_value( params[:pool_id] )
is_expected.to contain_designate_config('service:pool_manager/workers').with_value( '<SERVICE DEFAULT>' )
is_expected.to contain_designate_config('service:pool_manager/threads').with_value( '<SERVICE DEFAULT>' )
is_expected.to contain_designate_config('service:pool_manager/threshold_percentage').with_value( '<SERVICE DEFAULT>' )
is_expected.to contain_designate_config('service:pool_manager/poll_timeout').with_value( '<SERVICE DEFAULT>' )
is_expected.to contain_designate_config('service:pool_manager/poll_retry_interval').with_value( '<SERVICE DEFAULT>' )
is_expected.to contain_designate_config('service:pool_manager/poll_max_retries').with_value( '<SERVICE DEFAULT>' )
is_expected.to contain_designate_config('service:pool_manager/poll_delay').with_value( '<SERVICE DEFAULT>' )
is_expected.to contain_designate_config('service:pool_manager/enable_recovery_timer').with_value( '<SERVICE DEFAULT>' )
is_expected.to contain_designate_config('service:pool_manager/periodic_recovery_interval').with_value( '<SERVICE DEFAULT>' )
is_expected.to contain_designate_config('service:pool_manager/enable_sync_timer').with_value( '<SERVICE DEFAULT>' )
is_expected.to contain_designate_config('service:pool_manager/periodic_sync_interval').with_value( '<SERVICE DEFAULT>' )
is_expected.to contain_designate_config('service:pool_manager/periodic_sync_seconds').with_value( '<SERVICE DEFAULT>' )
is_expected.to contain_designate_config('service:pool_manager/periodic_sync_max_attempts').with_value( '<SERVICE DEFAULT>' )
is_expected.to contain_designate_config('service:pool_manager/periodic_sync_retry_interval').with_value( '<SERVICE DEFAULT>' )
end
end
context 'with custom package name' do
before do
params.merge!({ :pool_manager_package_name => 'designate-pool-manager-custom-name' })
end
it 'configures using custom name' do
is_expected.to contain_package('designate-pool-manager').with(
:name => 'designate-pool-manager-custom-name',
:ensure => 'present',
:tag => ['openstack', 'designate-package'],
)
end
end
context 'with all params' do
before do
params.merge!( params_all )
end
it 'configures designate-pool-manager with all parameters' do
is_expected.to contain_designate_config('service:pool_manager/pool_id').with_value( params[:pool_id] )
is_expected.to contain_designate_config('service:pool_manager/workers').with_value( params[:workers] )
is_expected.to contain_designate_config('service:pool_manager/threads').with_value( params[:threads] )
is_expected.to contain_designate_config('service:pool_manager/threshold_percentage').with_value( params[:threshold_percentage] )
is_expected.to contain_designate_config('service:pool_manager/poll_timeout').with_value( params[:poll_timeout] )
is_expected.to contain_designate_config('service:pool_manager/poll_retry_interval').with_value( params[:poll_retry_interval] )
is_expected.to contain_designate_config('service:pool_manager/poll_max_retries').with_value( params[:poll_max_retries] )
is_expected.to contain_designate_config('service:pool_manager/poll_delay').with_value( params[:poll_delay] )
is_expected.to contain_designate_config('service:pool_manager/enable_recovery_timer').with_value( params[:enable_recovery_timer] )
is_expected.to contain_designate_config('service:pool_manager/periodic_recovery_interval').with_value( params[:periodic_recovery_interval] )
is_expected.to contain_designate_config('service:pool_manager/enable_sync_timer').with_value( params[:enable_sync_timer] )
is_expected.to contain_designate_config('service:pool_manager/periodic_sync_interval').with_value( params[:periodic_sync_interval] )
is_expected.to contain_designate_config('service:pool_manager/periodic_sync_seconds').with_value( params[:periodic_sync_seconds] )
is_expected.to contain_designate_config('service:pool_manager/periodic_sync_max_attempts').with_value( params[:periodic_sync_max_attempts] )
is_expected.to contain_designate_config('service:pool_manager/periodic_sync_retry_interval').with_value( params[:periodic_sync_retry_interval] )
end
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'
{
:pool_manager_package_name => 'designate-pool-manager',
:pool_manager_service_name => 'designate-pool-manager'
}
when 'RedHat'
{
:pool_manager_package_name => 'openstack-designate-pool-manager',
:pool_manager_service_name => 'openstack-designate-pool-manager'
}
end
end
it_behaves_like 'designate-pool-manager'
end
end
end

View File

@ -0,0 +1,53 @@
require 'spec_helper'
describe 'designate::pool_nameserver' do
let :facts do
@default_facts.merge({:osfamily => 'Debian'})
end
let :params do
{
}
end
let :pre_condition do
'include designate'
end
let :title do
'0f66b842-96c2-4189-93fc-1dc95a08b012'
end
shared_examples_for 'without parameters' do
it { is_expected.to contain_designate__pool_nameserver('0f66b842-96c2-4189-93fc-1dc95a08b012') }
it 'configures designate pool-nameserver with default parameters' do
is_expected.to contain_designate_config("pool_nameserver:0f66b842-96c2-4189-93fc-1dc95a08b012/host").with_value('127.0.0.1')
is_expected.to contain_designate_config("pool_nameserver:0f66b842-96c2-4189-93fc-1dc95a08b012/port").with_value(53)
end
end
shared_examples_for 'with all parameters' do
before { params.merge!( { :host => '192.168.0.1', :port => 5353 } ) }
it { is_expected.to contain_designate__pool_nameserver('0f66b842-96c2-4189-93fc-1dc95a08b012') }
it 'configures designate pool-nameserver with default parameters' do
is_expected.to contain_designate_config("pool_nameserver:0f66b842-96c2-4189-93fc-1dc95a08b012/host").with_value('192.168.0.1')
is_expected.to contain_designate_config("pool_nameserver:0f66b842-96c2-4189-93fc-1dc95a08b012/port").with_value(5353)
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
it_behaves_like 'without parameters'
it_behaves_like 'with all parameters'
end
end
end

View File

@ -0,0 +1,57 @@
require 'spec_helper'
describe 'designate::pool' do
let :facts do
@default_facts.merge({:osfamily => 'Debian'})
end
let :params do
{
:nameservers => ['0f66b842-96c2-4189-93fc-1dc95a08b012'],
:targets => ['f26e0b32-736f-4f0a-831b-039a415c481e'],
}
end
let :pre_condition do
'include designate'
end
let :title do
'794ccc2c-d751-44fe-b57f-8894c9f5c842'
end
shared_examples_for 'with only required parameters' do
it { is_expected.to contain_designate__pool('794ccc2c-d751-44fe-b57f-8894c9f5c842') }
it 'configures designate pool with default parameters' do
is_expected.to contain_designate_config("pool:794ccc2c-d751-44fe-b57f-8894c9f5c842/nameservers").with_value( params[:nameservers])
is_expected.to contain_designate_config("pool:794ccc2c-d751-44fe-b57f-8894c9f5c842/targets").with_value( params[:targets] )
is_expected.to contain_designate_config("pool:794ccc2c-d751-44fe-b57f-8894c9f5c842/also-notifies").with_value( "" )
end
end
shared_examples_for 'with all parameters' do
before { params.merge!( { :also_notifies => ["192.168.0.1"] } ) }
it { is_expected.to contain_designate__pool('794ccc2c-d751-44fe-b57f-8894c9f5c842') }
it 'configures designate pool with default parameters' do
is_expected.to contain_designate_config("pool:794ccc2c-d751-44fe-b57f-8894c9f5c842/nameservers").with_value( params[:nameservers])
is_expected.to contain_designate_config("pool:794ccc2c-d751-44fe-b57f-8894c9f5c842/targets").with_value( params[:targets] )
is_expected.to contain_designate_config("pool:794ccc2c-d751-44fe-b57f-8894c9f5c842/also-notifies").with_value( ["192.168.0.1"] )
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
it_behaves_like 'with only required parameters'
it_behaves_like 'with all parameters'
end
end
end

View File

@ -0,0 +1,58 @@
require 'spec_helper'
describe 'designate::pool_target' do
let :facts do
@default_facts.merge({:osfamily => 'Debian'})
end
let :params do
{
:options => 'rndc_host: 192.168.27.100, rndc_port: 953, rndc_config_file: /etc/bind/rndc.conf, rndc_key_file: /etc/bind/rndc.key, port: 53, host: 192.168.27.100',
:type => 'bind9',
:masters => ['127.0.0.1:5354'],
}
end
let :pre_condition do
'include designate'
end
let :title do
'f26e0b32-736f-4f0a-831b-039a415c481e'
end
shared_examples_for 'with only required parameters' do
it { is_expected.to contain_designate__pool_target('f26e0b32-736f-4f0a-831b-039a415c481e') }
it 'configures designate pool-manager pool with default parameters' do
is_expected.to contain_designate_config('pool_target:f26e0b32-736f-4f0a-831b-039a415c481e/options').with_value(params[:options])
is_expected.to contain_designate_config('pool_target:f26e0b32-736f-4f0a-831b-039a415c481e/type').with_value(params[:type])
is_expected.to contain_designate_config('pool_target:f26e0b32-736f-4f0a-831b-039a415c481e/masters').with_value(params[:masters])
end
end
shared_examples_for 'with all parameters' do
before { params.merge!( { :masters => ['192.168.0.1'] } ) }
it { is_expected.to contain_designate__pool_target('f26e0b32-736f-4f0a-831b-039a415c481e') }
it 'configures designate pool-manager pool with default parameters' do
is_expected.to contain_designate_config('pool_target:f26e0b32-736f-4f0a-831b-039a415c481e/options').with_value(params[:options])
is_expected.to contain_designate_config('pool_target:f26e0b32-736f-4f0a-831b-039a415c481e/type').with_value(params[:type])
is_expected.to contain_designate_config('pool_target:f26e0b32-736f-4f0a-831b-039a415c481e/masters').with_value(params[:masters])
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
it_behaves_like 'with only required parameters'
it_behaves_like 'with all parameters'
end
end
end