Support agent backend and bind9 agent backend
This change introduces support for setting up agent backend[1] and bind9 agent backend. [1] https://docs.openstack.org/designate/latest/admin/backends/agent.html Related-Bug: #1961516 Change-Id: I5c65aa4853d8dfb4e54eaa4d65c871aa7968117c
This commit is contained in:
56
manifests/agent/bind9.pp
Normal file
56
manifests/agent/bind9.pp
Normal file
@@ -0,0 +1,56 @@
|
||||
# == Class designate::agent::bind9
|
||||
#
|
||||
# Configure bind9 as agent backend
|
||||
#
|
||||
# == Parameters
|
||||
#
|
||||
# [*rndc_host*]
|
||||
# (Optional) RNDC Host
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*rndc_port*]
|
||||
# (Optional) RNDC Port.
|
||||
# Defaults to 953.
|
||||
#
|
||||
# [*rndc_config_file*]
|
||||
# (Optional) Location of the rndc configuration file.
|
||||
# Defaults to '/etc/rndc.conf'
|
||||
#
|
||||
# [*rndc_key_file*]
|
||||
# (Optional) Location of the rndc key file.
|
||||
# Defaults to '/etc/rndc.key'
|
||||
#
|
||||
# [*rndc_timeout*]
|
||||
# (Optional) RNDC command timeout.
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*zone_file_path*]
|
||||
# (Optional) Path where zone files are stored.
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*query_destination*]
|
||||
# (Optional) Host to query when finding zones.
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
class designate::agent::bind9 (
|
||||
$rndc_host = $::os_service_default,
|
||||
$rndc_port = $::os_service_default,
|
||||
$rndc_config_file = '/etc/rndc.conf',
|
||||
$rndc_key_file = '/etc/rndc.key',
|
||||
$rndc_timeout = $::os_service_default,
|
||||
$zone_file_path = $::os_service_default,
|
||||
$query_destination = $::os_service_default,
|
||||
) {
|
||||
|
||||
include designate::deps
|
||||
|
||||
designate_config {
|
||||
'backend:agent:bind9/rndc_host' : value => $rndc_host;
|
||||
'backend:agent:bind9/rndc_port' : value => $rndc_port;
|
||||
'backend:agent:bind9/rndc_config_file' : value => $rndc_config_file;
|
||||
'backend:agent:bind9/rndc_key_file' : value => $rndc_key_file;
|
||||
'backend:agent:bind9/rndc_timeout' : value => $rndc_timeout;
|
||||
'backend:agent:bind9/zone_file_path' : value => $zone_file_path;
|
||||
'backend:agent:bind9/query_destination' : value => $query_destination;
|
||||
}
|
||||
}
|
59
manifests/backend/agent.pp
Normal file
59
manifests/backend/agent.pp
Normal file
@@ -0,0 +1,59 @@
|
||||
# == Class designate::backend::agent
|
||||
#
|
||||
# Configure agent as backend
|
||||
#
|
||||
# == Parameters
|
||||
#
|
||||
# [*agent_hosts*]
|
||||
# (Optional) Host running designate-agent service.
|
||||
# Defaults to ['127.0.0,1'].
|
||||
#
|
||||
# [*agent_port*]
|
||||
# (Optional) TCP port to connect to designate-agent service.
|
||||
# Defaults to 5358.
|
||||
#
|
||||
# [*mdns_hosts*]
|
||||
# (Optional) Array of hosts where designate-mdns service is running.
|
||||
# Defaults to ['127.0.0.1'].
|
||||
#
|
||||
# [*mdns_port*]
|
||||
# (Optional) TCP Port to connect to designate-mdns service.
|
||||
# Defaults to 5354.
|
||||
#
|
||||
# [*manage_pool*]
|
||||
# (Optional) Manage pools.yaml and update pools by designate-manage command
|
||||
# Defaults to true
|
||||
#
|
||||
class designate::backend::agent (
|
||||
$agent_hosts = ['127.0.0.1'],
|
||||
$agent_port = 5358,
|
||||
$mdns_hosts = ['127.0.0.1'],
|
||||
$mdns_port = 5354,
|
||||
$manage_pool = true,
|
||||
) {
|
||||
|
||||
include designate::deps
|
||||
include designate::params
|
||||
|
||||
if $manage_pool {
|
||||
file { '/etc/designate/pools.yaml':
|
||||
ensure => present,
|
||||
path => '/etc/designate/pools.yaml',
|
||||
owner => $designate::params::user,
|
||||
group => $designate::params::group,
|
||||
mode => '0640',
|
||||
content => template('designate/agent-pools.yaml.erb'),
|
||||
require => Anchor['designate::config::begin'],
|
||||
before => Anchor['designate::config::end'],
|
||||
}
|
||||
|
||||
exec { 'designate-manage pool update':
|
||||
command => 'designate-manage pool update',
|
||||
path => '/usr/bin',
|
||||
user => $designate::params::user,
|
||||
refreshonly => true,
|
||||
require => Anchor['designate::service::end'],
|
||||
subscribe => File['/etc/designate/pools.yaml'],
|
||||
}
|
||||
}
|
||||
}
|
5
releasenotes/notes/agent-backend-b2c70ceed54301e1.yaml
Normal file
5
releasenotes/notes/agent-backend-b2c70ceed54301e1.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Now puppet-designate supports setting up agent backend and bind9 agent
|
||||
backend.
|
57
spec/classes/designate_agent_bind9_spec.rb
Normal file
57
spec/classes/designate_agent_bind9_spec.rb
Normal file
@@ -0,0 +1,57 @@
|
||||
#
|
||||
# Unit tests for designate::agent::bind9
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'designate::agent::bind9' do
|
||||
|
||||
shared_examples 'designate::agent::bind9' do
|
||||
context 'with default params' do
|
||||
let :params do
|
||||
{}
|
||||
end
|
||||
|
||||
it 'configures the default parameters' do
|
||||
is_expected.to contain_designate_config('backend:agent:bind9/rndc_host').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_designate_config('backend:agent:bind9/rndc_port').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_designate_config('backend:agent:bind9/rndc_config_file').with_value('/etc/rndc.conf')
|
||||
is_expected.to contain_designate_config('backend:agent:bind9/rndc_key_file').with_value('/etc/rndc.key')
|
||||
is_expected.to contain_designate_config('backend:agent:bind9/rndc_timeout').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_designate_config('backend:agent:bind9/zone_file_path').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_designate_config('backend:agent:bind9/query_destination').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with parameters' do
|
||||
let :params do
|
||||
{
|
||||
:rndc_host => '10.0.0.42',
|
||||
:rndc_port => '1337',
|
||||
:rndc_timeout => 10,
|
||||
:zone_file_path => '/var/lib/designate/zones',
|
||||
:query_destination => '10.0.0.43',
|
||||
}
|
||||
end
|
||||
|
||||
it 'configures the parameters accordingly' do
|
||||
is_expected.to contain_designate_config('backend:agent:bind9/rndc_host').with_value('10.0.0.42')
|
||||
is_expected.to contain_designate_config('backend:agent:bind9/rndc_port').with_value('1337')
|
||||
is_expected.to contain_designate_config('backend:agent:bind9/rndc_timeout').with_value(10)
|
||||
is_expected.to contain_designate_config('backend:agent:bind9/zone_file_path').with_value('/var/lib/designate/zones')
|
||||
is_expected.to contain_designate_config('backend:agent:bind9/query_destination').with_value('10.0.0.43')
|
||||
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::agent::bind9'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
51
spec/classes/designate_backend_agent_spec.rb
Normal file
51
spec/classes/designate_backend_agent_spec.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
#
|
||||
# Unit tests for designate::backend::agent
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'designate::backend::agent' do
|
||||
|
||||
shared_examples 'designate-backend-agent' do
|
||||
context 'with default params' do
|
||||
it 'configures named and pool' do
|
||||
is_expected.to contain_file('/etc/designate/pools.yaml').with(
|
||||
:ensure => 'present',
|
||||
:path => '/etc/designate/pools.yaml',
|
||||
:owner => 'designate',
|
||||
:group => 'designate',
|
||||
:mode => '0640',
|
||||
)
|
||||
is_expected.to contain_exec('designate-manage pool update').with(
|
||||
:command => 'designate-manage pool update',
|
||||
:path => '/usr/bin',
|
||||
:user => 'designate',
|
||||
:refreshonly => true,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with pool management disabled' do
|
||||
let :params do
|
||||
{ :manage_pool => false }
|
||||
end
|
||||
it 'does not configure pool' do
|
||||
is_expected.to_not contain_file('/etc/designate/pools.yaml')
|
||||
is_expected.to_not contain_exec('designate-manage pool update')
|
||||
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-backend-agent'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
24
templates/agent-pools.yaml.erb
Normal file
24
templates/agent-pools.yaml.erb
Normal file
@@ -0,0 +1,24 @@
|
||||
---
|
||||
- name: default
|
||||
description: Default pool
|
||||
attributes: {}
|
||||
|
||||
targets:
|
||||
<% @agent_hosts.each do |agent_host| -%>
|
||||
- type: agent
|
||||
description: Agent Server <%= agent_host %>
|
||||
|
||||
masters:
|
||||
<% @mdns_hosts.each do |mdns_host| -%>
|
||||
- host: <%= mdns_host %>
|
||||
port: <%= @mdns_port.to_s %>
|
||||
<% end -%>
|
||||
|
||||
options:
|
||||
host: <%= agent_host %>
|
||||
port: <%= @dns_port.to_s %>
|
||||
rndc_host: <%= agent_host %>
|
||||
rndc_port: <%= @rndc_port %>
|
||||
rndc_config_file: <%= @rndc_config_file %>
|
||||
rndc_key_file: <%= @rndc_key_file %>
|
||||
<% end -%>
|
Reference in New Issue
Block a user