Add support for PowerDNS 4 backend
Change-Id: Ie9cc92622e1bf281fc07c97f480f5a3c16b7e6f3
This commit is contained in:
parent
717cd76592
commit
4d0a105c16
74
manifests/backend/pdns4.pp
Normal file
74
manifests/backend/pdns4.pp
Normal file
@ -0,0 +1,74 @@
|
||||
# == Class designate::backend::pdns4
|
||||
#
|
||||
# Configure PowerDNS 4 as backend
|
||||
#
|
||||
# == Parameters
|
||||
#
|
||||
# [*api_token*]
|
||||
# (Required) Token string to authenticate with the PowerDNS Authoritative
|
||||
# Server.
|
||||
#
|
||||
# [*pdns4_hosts*]
|
||||
# (Optional) Host running DNS service.
|
||||
# Defaults to ['127.0.0,1'].
|
||||
#
|
||||
# [*pdns4_port*]
|
||||
# (Optional) TCP port to connect to DNS service.
|
||||
# Defaults to 53.
|
||||
#
|
||||
# [*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.
|
||||
#
|
||||
# [*api_endpoint*]
|
||||
# (Optional) URL to access the PowerDNS Authoritative Server.
|
||||
# Defaults to 'http://127.0.0.1:8081'.
|
||||
#
|
||||
# [*tsigkey_name*]
|
||||
# (Optional) Name of TSIGKey.
|
||||
# Defaults to undef.
|
||||
#
|
||||
# [*manage_pool*]
|
||||
# (Optional) Manage pools.yaml and update pools by designate-manage command
|
||||
# Defaults to true
|
||||
#
|
||||
class designate::backend::pdns4 (
|
||||
$api_token,
|
||||
$pdns4_hosts = ['127.0.0.1'],
|
||||
$pdns4_port = 53,
|
||||
$mdns_hosts = ['127.0.0.1'],
|
||||
$mdns_port = 5354,
|
||||
$api_endpoint = 'http://127.0.0.1:8081',
|
||||
$tsigkey_name = undef,
|
||||
$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/pdns4-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/pdns4-07768cbace039aee.yaml
Normal file
5
releasenotes/notes/pdns4-07768cbace039aee.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The new ``designate::backend::pdns4`` class has been added. This class
|
||||
supports setting up PowerDNS 4 backend.
|
58
spec/classes/designate_backend_pdns4_spec.rb
Normal file
58
spec/classes/designate_backend_pdns4_spec.rb
Normal file
@ -0,0 +1,58 @@
|
||||
#
|
||||
# Unit tests for designate::backend::pdns4
|
||||
#
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'designate::backend::pdns4' do
|
||||
|
||||
shared_examples 'designate-backend-pdns4' do
|
||||
|
||||
let :params do
|
||||
{ :api_token => 'mytoken' }
|
||||
end
|
||||
|
||||
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
|
||||
before do
|
||||
params.merge!({
|
||||
: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-pdns4'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
25
templates/pdns4-pools.yaml.erb
Normal file
25
templates/pdns4-pools.yaml.erb
Normal file
@ -0,0 +1,25 @@
|
||||
---
|
||||
- name: default
|
||||
description: Default pool
|
||||
attributes: {}
|
||||
|
||||
targets:
|
||||
<% @pdns4_hosts.each do |pdns4_host| -%>
|
||||
- type: pdns4
|
||||
description: PowerDNS4 DNS Server <%= pdns4_host %>
|
||||
|
||||
masters:
|
||||
<% @mdns_hosts.each do |mdns_host| -%>
|
||||
- host: <%= mdns_host %>
|
||||
port: <%= @mdns_port.to_s %>
|
||||
<% end -%>
|
||||
|
||||
options:
|
||||
host: <%= pdns4_host %>
|
||||
port: <%= @dns_port.to_s %>
|
||||
api_endpoint: <%= @api_endpoint %>
|
||||
api_token: <%= @api_token %>
|
||||
<%- if @tsigkey_name -%>
|
||||
tsigkey_name: <%= @tsigkey_name %>
|
||||
<%- end -%>
|
||||
<% end -%>
|
Loading…
Reference in New Issue
Block a user